-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Shared Library Build Target #412
Comments
You can already do that by passing in |
EDIT: It works but I also needed to add the @thomasantony thanks, I wasn't aware of those flags, however this doesn't seem to be working for me. Running the following from the mkdir build
cd build
cmake .. -DLLAMA_STATIC=Off -DBUILD_SHARED_LIBS=On
make gives me a linking error (maybe I'm missing an additional flag?) However, if I add a shared library build target to the add_library(llamacpp SHARED
llama
ggml) |
this is supposed to work, so I'm marking this as a bug.
cmake needs fixing. you should not need to link against ggml agains here :) add_library(llamacpp SHARED
llama
ggml) |
I'm still having issues with GLIBC dependencies when compiling this as a library
Any clue if this is also a bug or if I'm missing something? Chain of command is:
Which fails with this error |
Seems like something fails with the import of "math.h" intest-quantize |
try to link with math ( |
Linking with math certainly helps, yet I don't know if this is a proper way: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 157d733..5767b8b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,7 @@
function(llama_add_test source)
get_filename_component(TEST_TARGET ${source} NAME_WE)
add_executable(${TEST_TARGET} ${source})
- target_link_libraries(${TEST_TARGET} PRIVATE llama)
+ target_link_libraries(${TEST_TARGET} PRIVATE llama m)
add_test(NAME ${TEST_TARGET} COMMAND $<TARGET_FILE:${TEST_TARGET}> ${ARGN})
endfunction() |
I wonder why this is only sometimes a problem. |
It's worth noting that for me I'm seeing linking issues if using BUILD_SHARED_LIBS with OpenBLAS enabled.
OpenBLAS was not linked properly and libllama was not usable. I had to link it in CMakeLists.txt:247 |
I think you need to specify the options before the path. This worked for me: |
Dumb question, I'm a C/C++ n00b -- after I run |
The "DBUILD_SHARED_LIBS=ON" option will make it a shared library, so dynamically linked only. If you need to statically link it, set "DBUILD_SHARED_LIBS=OFF" and you'll get a static library file. |
With the C API now merged it would be very useful to have build targets for
make
andcmake
that produce shared library versions ofllama.cpp
. This wayllama.cpp
can just be dynamically linked in other applications.The text was updated successfully, but these errors were encountered: