Boost static linking

I am using the Boost library with g++ on Linux. When I built this library, I executed this command: ./bjam (without parameters). My lib directory looks like this: libboost_thread.a libboost_thread.so libboost_thread.so.1.41.0 ... Building the project using Thread library, I added boost_thread to the linker dependencies list. Now my program depends on the shared library libboost_thread.so.1.41.0. For my purposes, I need to make static linking, to exclude runtime dependency. How can I do this? -- View this message in context: http://old.nabble.com/Boost-static-linking-tp27714367p27714367.html Sent from the Boost - Users mailing list archive at Nabble.com.

Tried this, got error message:
cannot find -llibboost_thread.a
(added libboost_thread.a to the likker libraries list in the Eclipse CDT
project).
On Thu, Feb 25, 2010 at 5:14 PM, David Kaplan
For my purposes, I need to make static linking, to exclude runtime dependency. How can I do this?
-l:libboost_system.a -l:libboost_thread.a _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On 27 February 2010 08:34, Alex Farber
Tried this, got error message: cannot find -llibboost_thread.a (added libboost_thread.a to the likker libraries list in the Eclipse CDT project).
You need to add ":libboost_thread.a" - with the colon... Eclipse will call the linked with -l:libboost_thread.a

Thank you. This is my command line:
g++ -o"MyProgram" ./main.o -l:libboost_thread.a
The result is huge number of messages like:
undefined reference to `pthread_key_create'
The same result as I got with this:
g++ -static -o"MyProgram" ./main.o -lboost_thread
Some problems with static library libboost_thread.a?
On Sat, Feb 27, 2010 at 6:26 PM, David Kaplan
On 27 February 2010 08:34, Alex Farber
wrote: Tried this, got error message: cannot find -llibboost_thread.a (added libboost_thread.a to the likker libraries list in the Eclipse CDT project).
You need to add ":libboost_thread.a" - with the colon... Eclipse will call the linked with -l:libboost_thread.a _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On 27 February 2010 20:08, Alex Farber
Thank you. This is my command line: g++ -o"MyProgram" ./main.o -l:libboost_thread.a
The result is huge number of messages like: undefined reference to `pthread_key_create'
The same result as I got with this: g++ -static -o"MyProgram" ./main.o -lboost_thread Some problems with static library libboost_thread.a?
Add -lpthread

Trying to access positional arguments with sample program bellow: If I run: "a.out one" Error: unknown option positional Same error I got on "a.out -h one" and "a.out one -h" If I run: "a.out one two" Error: too many positional options But "a.out -h works" Thanks \/. namespace po=boost::program_options; po::options_description cmds("Options"); cmds.add_options() ("help,h", "output help message"); po::positional_options_description positional; positional.add("positional", 1); po::variables_map vm; po::parsed_options parsed = po::command_line_parser(argc, argv).options(cmds).positional(positional).run(); po::store( parsed, vm); po::notify(vm); if (vm.count("help")) { cout << cmds << endl; return 0; } if(vm.count("positional") ) { cout << "positional"; } } catch(const std::exception& ex) { cout << "Error: " << ex.what() << endl; } =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ===============================================================================

Sakharuk, Vladimir wrote:
Trying to access positional arguments with sample program bellow:
If I run: "a.out one" Error: unknown option positional Same error I got on "a.out -h one" and "a.out one -h"
If I run: "a.out one two" Error: too many positional options
But "a.out -h works" Thanks \/.
namespace po=boost::program_options; po::options_description cmds("Options"); cmds.add_options() ("help,h", "output help message");
po::positional_options_description positional; positional.add("positional", 1);
po::variables_map vm; po::parsed_options parsed = po::command_line_parser(argc, argv).options(cmds).positional(positional).run();
Per documentation, this code only makes the first positional option be treated as option named 'positional'. You still need to define such an option inside an options_description object, since otherwise the library will have no idea what type it has and what to do with it. Does this help? - Volodya
participants (4)
-
Alex Farber
-
David Kaplan
-
Sakharuk, Vladimir
-
Vladimir Prus