boost filesystem library files can not be linked

My ubuntu is 10.04. boost was installed from apt-get.
I compiled the following code. But the library is not available to
link. Would you please let me know how what link option I should use?
$ cat main.cpp
#include

I run boost on Windows but the first things to check should be similar:
1. Does apt-get get the compiled version of boost or just get the
sources ? Are the compiled shared and lib files there ?
2. In case the files are there, is the directory included in the
search path for the linker ?
Best regards,
Mau.
2010/6/14 Peng Yu
My ubuntu is 10.04. boost was installed from apt-get.
I compiled the following code. But the library is not available to link. Would you please let me know how what link option I should use?
$ cat main.cpp #include
#include <iostream> #include <string> int main() { boost::filesystem::path path1("/tmp/dir1/test1.c "); boost::filesystem::path path2("/tmp/dir1/.test1.profile"); std::string result1 = boost::filesystem::basename (path1); std::string result2 = boost::filesystem::basename (path2); std::cout << result1 << std::endl; std::cout << result2 << std::endl; return 0; }
$g++ -o main.exe main.cpp /tmp/ccSvyGYq.o: In function `__static_initialization_and_destruction_0(int, int)': main.cpp:(.text+0x15d): undefined reference to `boost::system::get_system_category()' main.cpp:(.text+0x169): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x175): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x181): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x18d): undefined reference to `boost::system::get_system_category()' collect2: ld returned 1 exit status make: *** [main.exe] Error 1
-- Regards, Peng _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Mauricio Gomes Pensar Digital 55-11-9698-1683 (Brazil - mobile)

On Mon, 14 Jun 2010 15:26:21 -0700, Peng Yu
My ubuntu is 10.04. boost was installed from apt-get.
I compiled the following code. But the library is not available to link. Would you please let me know how what link option I should use?
$ cat main.cpp #include
#include <iostream> #include <string> int main() { boost::filesystem::path path1("/tmp/dir1/test1.c "); boost::filesystem::path path2("/tmp/dir1/.test1.profile"); std::string result1 = boost::filesystem::basename (path1); std::string result2 = boost::filesystem::basename (path2); std::cout << result1 << std::endl; std::cout << result2 << std::endl; return 0; }
$g++ -o main.exe main.cpp /tmp/ccSvyGYq.o: In function `__static_initialization_and_destruction_0(int, int)': main.cpp:(.text+0x15d): undefined reference to `boost::system::get_system_category()' main.cpp:(.text+0x169): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x175): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x181): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x18d): undefined reference to `boost::system::get_system_category()' collect2: ld returned 1 exit status make: *** [main.exe] Error 1
In addition to the boost_filesystem lib, you also need to link against the boost_system lib. I believe this should solve your problem. Regards, Mostafa

On Mon, 14 Jun 2010 15:56:26 -0700, Peng Yu
In addition to the boost_filesystem lib, you also need to link against the boost_system lib. I believe this should solve your problem.
If I use g++, I should compile it like this, right?
g++ -o main.exe main.cpp -lboost_filesystem -lboost_system
You may also need to specify the -L option if your boost libs are not in
the linkers default search path. Something like this:
g++ -o main.exe main.cpp -L
participants (3)
-
Mauricio Gomes
-
Mostafa
-
Peng Yu