alelievr / libft-unit-test

455 stars 88 forks source link

collect2: error #97

Open tjohnna opened 3 years ago

tjohnna commented 3 years ago

By running 'make f' I encountered the following error: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function _start': (.text+0x24): undefined reference tomain'
collect2: error: ld returned 1 exit status
make[1]: [Makefile:51: so] Error 1 make[1]: Leaving directory '/mnt/c/Curs21/lvl1/libft' make: [Makefile:162: libft.so] Error 2

I am working on WLS Ubuntu 20.04.2 LTS Win10 20H2 64bit

bh90210 commented 3 years ago

hello @tjohnna I see u passed ur libft successfully so congrats :tada:

I had the same issue and for posterity the solution was to use the -nostartfiles flag as per this suggestion https://stackoverflow.com/questions/11116399/crt1-o-in-function-start-undefined-reference-to-main-in-linux

so:
    $(CC) -nostartfiles -fPIC $(CFLAGS) $(SRC)
    gcc -nostartfiles -shared -o libft.so $(OBJ)
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::