alelievr / libft-unit-test

456 stars 88 forks source link

dyld: warning: could not load inserted library './assets/malloc.dylib' #113

Open Florian-A opened 2 years ago

Florian-A commented 2 years ago

Hello guy.

I clone my repo in the goinfre and i started make command and ./run_test.

I have this message on ft_striteri:

dyld: warning: could not load inserted library './assets/malloc.dylib' into hardened process because no suitable image found. Did find: ./assets/malloc.dylib: code signature in (./assets/malloc.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. ./assets/malloc.dylib: stat() failed with errno=1

When i restart ./run_test this message vanish.

My ft_striteri :

#include "libft.h"

void    ft_striteri(char *s, void (*f)(unsigned int, char*))
{
    unsigned int    i;

    if (!s)
        return ;
    i = 0;
    while (s[i])
    {
        (*f)(i, &s[i]);
        i++;
    }
}

Thanks for your work !

github-actions[bot] commented 2 years ago

Hello! Thanks for contributing to the libft unit test.

Note that this repository is not maintained by the owner anymore, instead there is a bot that will automatically merge any reviewed pull requests. If you feel like it, here are some links that can help you submiting a change in the code base::

Sangyao42 commented 1 year ago

Hello guy.

I clone my repo in the goinfre and i started make command and ./run_test.

I have this message on ft_striteri:

dyld: warning: could not load inserted library './assets/malloc.dylib' into hardened process because no suitable image found. Did find: ./assets/malloc.dylib: code signature in (./assets/malloc.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. ./assets/malloc.dylib: stat() failed with errno=1

When i restart ./run_test this message vanish.

My ft_striteri :

#include "libft.h"

void  ft_striteri(char *s, void (*f)(unsigned int, char*))
{
  unsigned int    i;

  if (!s)
      return ;
  i = 0;
  while (s[i])
  {
      (*f)(i, &s[i]);
      i++;
  }
}

Thanks for your work

Hello, I am working on Libft and have the same problem. Could you please tell me how to solve it? Is it some problem with my functions?

chunkhang commented 3 months ago

I faced this issue too. After reading a bit about arm64e in macOS, I managed to fix it.

In Makefile, look for the definition of DYLIBFLAG variable:

ifeq ($(OS),Linux)
    DYLIBFLAG = -fPIC -shared -ldl
else
    DYLIBFLAG = -dynamiclib
endif

Update DYLIBFLAG for macOS from -dynamiclib to -dynamiclib -arch arm64e:

ifeq ($(OS),Linux)
    DYLIBFLAG = -fPIC -shared -ldl
else
    DYLIBFLAG = -dynamiclib -arch arm64e
endif

The new Makefile should compile assets/malloc.c into assets/malloc.dylib correctly, which you can verify:

$ file assets/malloc.dylib
assets/malloc.dylib: Mach-O 64-bit dynamically linked shared library arm64e

If you're interested to read more about arm64e: https://github.com/lelegard/arm-cpusysregs/blob/main/docs/arm64e-on-macos.md