Boost logo

Boost Users :

Subject: [Boost-users] Boost Filesystem references in static/shared library
From: Miguel Guedes (miguel.a.guedes_at_[hidden])
Date: 2012-12-09 07:10:08


Hello List,

I was using boost::filesystem previously in a project that built an
executable but it has now grown and the requirements changed, and I now
have to build a portion of the code as a library; preferably an so.

Since I've started building code as a library I've been getting errors
about invalid references to boost::filesystem.

Here's how I'm building the library:

$ g++ -DBOOST_ALL_NO_LIB -fPIC -lrt -lstdc++ -shared -pthread
-lboost_system -lboost_thread -lboost_filesystem -L/usr/local/lib -ldl
-lpthread -lstdc++ -lclang -o libomnis.so cout.o
command_line_processor.o command_options_container.o
commands_container.o command_base.o command_option_base.o
command_option.o command_option_multi.o command_option_integer.o
command_option_flag.o command_serve.o command_send.o command_help.o
command_version.o register.o unsaved_file.o clang_parameters.o
ustring_vector.o string_vector.o request_strings.o source_file.o reply.o
omnisource.o omnis.o

As you can see I've tried building it with (as well as without) the
BOOST_ALL_NO_LIB macro defined.

I then compile the main executable as given:

$ g++ libomnis.so client.o omnis_command_line_processor.o
request_handler.o request_handler_1.0.o request_parser.o server.o
connection.o omnisource_loader.o omnis_app.o main.o -o omnis -pthread
-lboost_system -lboost_thread -lboost_filesystem -L/usr/local/lib -ldl
-lpthread -lstdc++ -lclang -L. -lomnis

And this results in the following output:

./libomnis.so: undefined reference to
`boost::filesystem2::detail::dir_itr_close(void*&, void*&)'
./libomnis.so: undefined reference to
`boost::filesystem2::detail::dir_itr_first(void*&, void*&, std::string
const&, std::string&, boost::filesystem2::file_status&,
boost::filesystem2::file_status&)'
./libomnis.so: undefined reference to
`boost::filesystem2::detail::dir_itr_increment(void*&, void*&,
std::string&, boost::filesystem2::file_status&,
boost::filesystem2::file_status&)'
./libomnis.so: undefined reference to
`boost::filesystem2::detail::status_api(std::string const&,
boost::system::error_code&)'
./libomnis.so: undefined reference to
`boost::filesystem2::detail::not_found_error()'
collect2: error: ld returned 1 exit status

What am I missing here?

PS: No errors occurred previously when I was just building the executable.

-- 
Miguel

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net