Opened 16 years ago

Closed 16 years ago

Last modified 14 years ago

#783 deleted Support Requests (None)

Can't compile anything with boost - undefined reference

Reported by: fafnr Owned by: nobody
Milestone: Component: build
Version: None Severity: Not Applicable
Keywords: Cc:

Description

I doubt this is a bug - it's highly likely it's me being stupid.
(Also, please bear in mind I've never really used c++ before... That probably means I'm not legally allowed to use Boost, but I'm kindda used to having filesystem operations, so I wanted to try it out... :-)

Anyway!

I downloaded boost from the website to my desktop, cd'ed to it, unpacked it and cd'ed inside. Then I ran:

>sudo bjam "-sTOOLS=gcc" install

and waited for it to complete...

So, after I did that, I figured I was ready to use boost...
I found a file-system example on http://www.boost.org/libs/filesystem/example/simple_ls.cpp
and tried compiling it:
> g++ simple_ls.cpp -o simple_ls

But that gives me the following output:
(WARNING! Pretty long copy-paste here...)
soren@soren-laptop:~$ g++ simple_ls.cpp -o simple_ls
/tmp/ccDCA1UI.o: In function `main':
simple_ls.cpp:(.text+0x89): undefined reference to `boost::filesystem::initial_path()'
simple_ls.cpp:(.text+0xb7): undefined reference to `boost::filesystem::native(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
simple_ls.cpp:(.text+0xc6): undefined reference to `boost::filesystem::path::path(char const*, bool (*)(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))'
simple_ls.cpp:(.text+0xd8): undefined reference to `boost::filesystem::system_complete(boost::filesystem::path const&)'
simple_ls.cpp:(.text+0x17a): undefined reference to `boost::filesystem::exists(boost::filesystem::path const&)'
simple_ls.cpp:(.text+0x193): undefined reference to `boost::filesystem::path::native_file_string() const'
simple_ls.cpp:(.text+0x208): undefined reference to `boost::filesystem::is_directory(boost::filesystem::path const&)'
simple_ls.cpp:(.text+0x222): undefined reference to `boost::filesystem::path::native_directory_string() const'
simple_ls.cpp:(.text+0x2b5): undefined reference to `boost::filesystem::is_directory(boost::filesystem::path const&)'
simple_ls.cpp:(.text+0x2d7): undefined reference to `boost::filesystem::path::leaf() const'
simple_ls.cpp:(.text+0x34a): undefined reference to `boost::filesystem::path::leaf() const'
simple_ls.cpp:(.text+0x3f1): undefined reference to `boost::filesystem::path::leaf() const'
simple_ls.cpp:(.text+0x56a): undefined reference to `boost::filesystem::path::native_file_string() const'
/tmp/ccDCA1UI.o: In function `boost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&)':
simple_ls.cpp:(.text._ZN5boost10filesystem18directory_iteratorC1ERKNS0_4pathE[boost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&)]+0x2b): undefined reference to `boost::filesystem::detail::dir_itr_init(boost::shared_ptr<boost::filesystem::detail::dir_itr_imp>&, boost::filesystem::path const&)'
/tmp/ccDCA1UI.o: In function `boost::filesystem::directory_iterator::dereference() const':
simple_ls.cpp:(.text._ZNK5boost10filesystem18directory_iterator11dereferenceEv[boost::filesystem::directory_iterator::dereference() const]+0xd): undefined reference to `boost::filesystem::detail::dir_itr_dereference(boost::shared_ptr<boost::filesystem::detail::dir_itr_imp> const&)'
/tmp/ccDCA1UI.o: In function `boost::filesystem::directory_iterator::increment()':
simple_ls.cpp:(.text._ZN5boost10filesystem18directory_iterator9incrementEv[boost::filesystem::directory_iterator::increment()]+0xd): undefined reference to `boost::filesystem::detail::dir_itr_increment(boost::shared_ptr<boost::filesystem::detail::dir_itr_imp>&)'
collect2: ld returned 1 exit status

this was run from the root of my home-dir...

To me it looks like it doesn't get the boost-files included somehow (thought it MUST find them, otherwise the compiler would have complained about missing files)...

Any thoughts?

/Søren

Change History (4)

comment:1 by nobody, 16 years ago

Logged In: NO 

You just forgot to link to the filesystem boost list, add smth like -lboost-filesystem to your linker flags or smth...
But really, this isn't a question to ask here, ask in a c++ channel on irc.

There's also #boost on freenode.

comment:2 by fafnr, 16 years ago

Status: assignedclosed

comment:3 by Daryle Walker, 14 years ago

Component: Nonebuild
Severity: Showstopper

comment:4 by Daryle Walker, 14 years ago

Severity: ShowstopperNot Applicable
Note: See TracTickets for help on using tickets.