Linking GSL statically using Cmake









up vote
1
down vote

favorite
1












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.










share|improve this question





















  • "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














up vote
1
down vote

favorite
1












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.










share|improve this question





















  • "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












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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
















  • "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















"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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto