Static linking with Boost and ncurses

夙愿已清 提交于 2019-12-23 23:27:22

问题


I am in the process of making a basic role-playing game. I want to include the Boost libraries statically so that the people who run my game do not need to have them. I researched and looked-up that all you have to do is add -static to the command-line compile, so my command is like this:

$ g++ -static -o karthas *.o -lncurses -lmenu -lboost_system -lboost_filesystem

But apparently the -static is affecting ncurses. I am getting a whole bunch of errors, most of which are undefined reference to 'SP'.

Is it possible to just do a static link to Boost and not ncurses? How would I go about doing that?


回答1:


You can choose which libraries will be linked statically and which will be linked dynamically by putting either -Wl,-static or -Wl,-Bdynamic before their name.

For example, with:

g++  -o karthas *.o -Wl,-static -lmenu -lboost_system -lboost_filesystem -Wl,-Bdynamic -lncurses 

The menu, boost_system and boost_filesystem libraries will be linked statically and ncurses dynamically.

(But you can also distribute the boost dlls with your executable, and not link anything statically).




回答2:


But looking at this, it seems that you are not alone, either that, or I found your issue. But this, might have your solution, either way, good luck. Btw, some boost libraries are little more than inline functions that are imported when included in the file.



来源:https://stackoverflow.com/questions/9708086/static-linking-with-boost-and-ncurses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!