Linking GSL statically using Cmake
up vote
1
down vote
favorite
I'm linking GNU GSL with a pybind11 module. It works if GSL is linked as a shared library:
cmake_minimum_required(VERSION 2.8.12)
project(st)
# Paths
set(CMAKE_MODULE_PATH $CMAKE_MODULE_PATH "$CMAKE_SOURCE_DIR/cmake/")
# Packages
add_subdirectory(pybind11)
find_package(GSL REQUIRED)
# Includes
set(DIRS $GSL_INCLUDE_DIRS $GSLCBLAS_INCLUDE_DIRS)
include_directories($DIRS)
# Python module
pybind11_add_module(st src/st.cpp)
# Libraries
set(LIBS $LIBS $GSL_LIBRARIES $GSLCBLAS_LIBRARIES)
target_link_libraries(st PRIVATE $LIBS)
How can I link it statically? I've tried a lot of different options but it doesn't work.
cmake compilation gsl pybind11
add a comment |
up vote
1
down vote
favorite
I'm linking GNU GSL with a pybind11 module. It works if GSL is linked as a shared library:
cmake_minimum_required(VERSION 2.8.12)
project(st)
# Paths
set(CMAKE_MODULE_PATH $CMAKE_MODULE_PATH "$CMAKE_SOURCE_DIR/cmake/")
# Packages
add_subdirectory(pybind11)
find_package(GSL REQUIRED)
# Includes
set(DIRS $GSL_INCLUDE_DIRS $GSLCBLAS_INCLUDE_DIRS)
include_directories($DIRS)
# Python module
pybind11_add_module(st src/st.cpp)
# Libraries
set(LIBS $LIBS $GSL_LIBRARIES $GSLCBLAS_LIBRARIES)
target_link_libraries(st PRIVATE $LIBS)
How can I link it statically? I've tried a lot of different options but it doesn't work.
cmake compilation gsl pybind11
"it doesn't work" isn't a problem description. Note, that unlike to a shared library, a static library doesn't track its dependencies. So, if a GSL library uses some other libraries, then you need to link with them manually. One may suggest thatfind_package
should care of the library's dependencies, but most of existentFindXXX.cmake
scripts do not do that.
– Tsyvarev
Nov 11 at 11:24
I have the exact same question. I triedcmake -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ..
but to no avail. GSL is still linked dynamically.
– Henri Menke
Nov 11 at 23:28
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm linking GNU GSL with a pybind11 module. It works if GSL is linked as a shared library:
cmake_minimum_required(VERSION 2.8.12)
project(st)
# Paths
set(CMAKE_MODULE_PATH $CMAKE_MODULE_PATH "$CMAKE_SOURCE_DIR/cmake/")
# Packages
add_subdirectory(pybind11)
find_package(GSL REQUIRED)
# Includes
set(DIRS $GSL_INCLUDE_DIRS $GSLCBLAS_INCLUDE_DIRS)
include_directories($DIRS)
# Python module
pybind11_add_module(st src/st.cpp)
# Libraries
set(LIBS $LIBS $GSL_LIBRARIES $GSLCBLAS_LIBRARIES)
target_link_libraries(st PRIVATE $LIBS)
How can I link it statically? I've tried a lot of different options but it doesn't work.
cmake compilation gsl pybind11
I'm linking GNU GSL with a pybind11 module. It works if GSL is linked as a shared library:
cmake_minimum_required(VERSION 2.8.12)
project(st)
# Paths
set(CMAKE_MODULE_PATH $CMAKE_MODULE_PATH "$CMAKE_SOURCE_DIR/cmake/")
# Packages
add_subdirectory(pybind11)
find_package(GSL REQUIRED)
# Includes
set(DIRS $GSL_INCLUDE_DIRS $GSLCBLAS_INCLUDE_DIRS)
include_directories($DIRS)
# Python module
pybind11_add_module(st src/st.cpp)
# Libraries
set(LIBS $LIBS $GSL_LIBRARIES $GSLCBLAS_LIBRARIES)
target_link_libraries(st PRIVATE $LIBS)
How can I link it statically? I've tried a lot of different options but it doesn't work.
cmake compilation gsl pybind11
cmake compilation gsl pybind11
asked Nov 11 at 10:00
Medical physicist
72321326
72321326
"it doesn't work" isn't a problem description. Note, that unlike to a shared library, a static library doesn't track its dependencies. So, if a GSL library uses some other libraries, then you need to link with them manually. One may suggest thatfind_package
should care of the library's dependencies, but most of existentFindXXX.cmake
scripts do not do that.
– Tsyvarev
Nov 11 at 11:24
I have the exact same question. I triedcmake -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ..
but to no avail. GSL is still linked dynamically.
– Henri Menke
Nov 11 at 23:28
add a comment |
"it doesn't work" isn't a problem description. Note, that unlike to a shared library, a static library doesn't track its dependencies. So, if a GSL library uses some other libraries, then you need to link with them manually. One may suggest thatfind_package
should care of the library's dependencies, but most of existentFindXXX.cmake
scripts do not do that.
– Tsyvarev
Nov 11 at 11:24
I have the exact same question. I triedcmake -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ..
but to no avail. GSL is still linked dynamically.
– Henri Menke
Nov 11 at 23:28
"it doesn't work" isn't a problem description. Note, that unlike to a shared library, a static library doesn't track its dependencies. So, if a GSL library uses some other libraries, then you need to link with them manually. One may suggest that
find_package
should care of the library's dependencies, but most of existent FindXXX.cmake
scripts do not do that.– Tsyvarev
Nov 11 at 11:24
"it doesn't work" isn't a problem description. Note, that unlike to a shared library, a static library doesn't track its dependencies. So, if a GSL library uses some other libraries, then you need to link with them manually. One may suggest that
find_package
should care of the library's dependencies, but most of existent FindXXX.cmake
scripts do not do that.– Tsyvarev
Nov 11 at 11:24
I have the exact same question. I tried
cmake -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ..
but to no avail. GSL is still linked dynamically.– Henri Menke
Nov 11 at 23:28
I have the exact same question. I tried
cmake -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ..
but to no avail. GSL is still linked dynamically.– Henri Menke
Nov 11 at 23:28
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247599%2flinking-gsl-statically-using-cmake%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"it doesn't work" isn't a problem description. Note, that unlike to a shared library, a static library doesn't track its dependencies. So, if a GSL library uses some other libraries, then you need to link with them manually. One may suggest that
find_package
should care of the library's dependencies, but most of existentFindXXX.cmake
scripts do not do that.– Tsyvarev
Nov 11 at 11:24
I have the exact same question. I tried
cmake -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ..
but to no avail. GSL is still linked dynamically.– Henri Menke
Nov 11 at 23:28