llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

add ptread link to fix cmake build under linux

Open mmyjona opened this issue 1 year ago • 3 comments

Fix the CMake build on Linux to prevent it from failing with an error message.

/usr/bin/ld: libggml.a(ggml.c.o): in function `ggml_graph_compute':
ggml.c:(.text+0x16960): undefined reference to `pthread_create'
/usr/bin/ld: ggml.c:(.text+0x169c3): undefined reference to `pthread_join'
/usr/bin/ld: libggml.a(ggml.c.o): in function `ggml_graph_compute':
ggml.c:(.text+0x16960): undefined reference to `pthread_create'
/usr/bin/ld: ggml.c:(.text+0x169c3): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/llama.dir/build.make:119: llama] Error 1
make[1]: *** [CMakeFiles/Makefile2:153: CMakeFiles/llama.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/quantize.dir/build.make:119: quantize] Error 1
make[1]: *** [CMakeFiles/Makefile2:126: CMakeFiles/quantize.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

mmyjona avatar Mar 14 '23 04:03 mmyjona

That's a good catch, I think we should also add to the CI the cmake builds of the other OSes...

etra0 avatar Mar 14 '23 13:03 etra0

@mmyjona Want to do what @etra0 suggests here, or we just merge it like this and do it later?

ggerganov avatar Mar 15 '23 19:03 ggerganov

@mmyjona Want to do what @etra0 suggests here, or we just merge it like this and do it later?

Please merge it first, because I saw another major CMake overhaul PR in the queue. I just saw matrix multi-OS build config is commented out in https://github.com/ggerganov/llama.cpp/blob/master/.github/workflows/build.yml, and I don't know the reason behind it.

mmyjona avatar Mar 16 '23 02:03 mmyjona

I personally think that the CMake run and the Make run should be different, as they're totally different build systems thus if cmake fails doesn't means the project won't build at all

etra0 avatar Mar 16 '23 22:03 etra0

i still have this error: (base) jupyter@cuda-11-0-20230324-133223:~/llama.cpp/build$ cmake --build . --config Release [ 5%] Built target ggml [ 16%] Built target llama [ 22%] Linking CXX executable ../bin/test-quantize /usr/bin/ld: ../libllama.a(ggml.c.o): in function ggml_graph_compute': ggml.c:(.text+0x19793): undefined reference to pthread_create' /usr/bin/ld: ggml.c:(.text+0x1a653): undefined reference to `pthread_join' collect2: error: ld returned 1 exit status make[2]: *** [tests/CMakeFiles/test-quantize.dir/build.make:85: bin/test-quantize] Error 1 make[1]: *** [CMakeFiles/Makefile2:1064: tests/CMakeFiles/test-quantize.dir/all] Error 2 make: *** [Makefile:95: all] Error 2

zachary62 avatar Apr 18 '23 04:04 zachary62

@zachary62 relates to #1042

Green-Sky avatar Apr 18 '23 16:04 Green-Sky