boost build problem?...
I wrote a few lines of code just for start with a library of boost (program_options). Before I did it I had built boost library as prescribed and *.a and *.so files were created in my /home/krzysztof/Documents/Projects/boost/lib directory. However, compilation fails because of undefined references of some external symbols which belongs to program_options library. Could anyone help me with it? Below, there is the code and g++ output. (Linux 64b, Qt Creator and Code::Blocks used as IDE) #include "boost/program_options.hpp" using namespace boost::program_options; using namespace std; int main(int argc, char *argv[]) { options_description opd; opd.add_options() ("help","Display help") ("input_file,if",value<string>(),"Specifies input file") ("fet_file",value<string>(),"definitions file") ("output_file,of",value<string>(),"file after edition"); } g++ -o fetxedit main.o -L/usr/lib -L/home/krzysztof/Documents/Projects/boost/lib -lQtCore -lpthread main.o: In function `main': /home/krzysztof/Documents/Projects/fetxedit-build-desktop/../fetxedit/main.cpp:8: undefined reference to `boost::program_options::options_description::m_default_line_length' /home/krzysztof/Documents/Projects/fetxedit-build-desktop/../fetxedit/main.cpp:8: undefined reference to `boost::program_options::options_description::m_default_line_length' /home/krzysztof/Documents/Projects/fetxedit-build-desktop/../fetxedit/main.cpp:8: undefined reference to `boost::program_options::options_description::options_description(unsigned int, unsigned int)' /home/krzysztof/Documents/Projects/fetxedit-build-desktop/../fetxedit/main.cpp:14: undefined reference to `boost::program_options::options_description::add_options()' /home/krzysztof/Documents/Projects/fetxedit-build-desktop/../fetxedit/main.cpp:14: undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)' ... and so on -- Regards Krzysztof Jasieński
two things you should do: 1) remove -L/usr/lib on the compile command since gcc should already know about it 2) add the following option to include the program options library: -lboost_program_options In general, "undefined reference" means you are missing a pre-compiled library (.a or .so) when linking. -- View this message in context: http://boost.2283326.n4.nabble.com/boost-build-problem-tp3478348p3478561.htm... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
johann
-
Krzysztof