C++ Boost on linux via Netbeans remote developement: undefined reference to boost::filesystem::path::codecvt()

StackOverflow https://stackoverflow.com/questions/20883319

Question

So I installed Netbeans on windows7 and configured the Ubuntu box with samba to share the developement directory where I have the sources and the boost library. I compiled the boost library to be able to link to boost_filesystem but I still get this error when I try to compile the application:

Copying project files to /home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/ at nms@ophelia.tele2.net
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/mr_deamon
make[2]: Entering directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-     Windows-x86_64/Z/mr_deamon'
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/mr_deamon.o.d"
g++    -c -g -I/opt/mail-relay/mr_deamon/boost_1_55_0 -I/opt/mail-relay/mr_deamon/mysql_connector_cpp/include -MMD -MP -MF "build/Debug/GNU-Linux-x86/mr_deamon.o.d" -o build/Debug/GNU-Linux-x86/mr_deamon.o mr_deamon.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/mr_deamon build/Debug/GNU-Linux-x86/mr_deamon.o -L/opt/mail-relay/mr_deamon/mysql_connector_cpp/lib -L/opt/mail-relay/mr_deamon/boost_1_55_0/bin.v2/libs -lmysqlcppconn-static -lmysqlclient -lboost_system -lboost_filesystem
build/Debug/GNU-Linux-x86/mr_deamon.o: In function `boost::filesystem::file_size(boost::filesystem::path const&)':
/opt/mail-relay/mr_deamon/boost_1_55_0/boost/filesystem/operations.hpp:447: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&,   boost::system::error_code*)'
build/Debug/GNU-Linux-x86/mr_deamon.o: In function `path<char*>':
/opt/mail-relay/mr_deamon/boost_1_55_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/mr_deamon] Error 1
make[2]: Leaving directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
make: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 2s)

I thought I got the linking right. Here is the program code:

#include <iostream>
#include <boost/filesystem.hpp>
//using namespace std;
using namespace boost::filesystem;
int main(int argc, char**argv)
{
    std::cout << file_size(argv[0]);

    return EXIT_SUCCESS;
}

The sql part works fine with linking and all, but only including the boost filesystem is enough to get a build error, can't get how to use remote developement with netbeans on windows to Linux. What am I doing wrong?

A new try without netbeans, just on Ubuntu with the example from Boost filesystem link ... and with compile command: g++ -pthread mr.cpp -lboost_filesystem-mt -lboost_system-mt the output is /tmp/ccIZaqeX.o: In function boost::filesystem::file_size(boost::filesystem::path const&)': mr.cpp: (.text._ZN5boost10filesystem9file_sizeERKNS0_4pathE[boost::filesystem::file_size(boost::filesystem::path const&)]+0x19): undefined reference toboost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)' /tmp/ccIZaqeX.o: In function boost::filesystem::path::path<char*>(char* const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<char*>::type>, void>::type*)': mr.cpp: (.text._ZN5boost10filesystem4pathC2IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x22): undefined reference toboost::filesystem::path::codecvt()' collect2: ld returned 1 exit status

I don't get it..

Was it helpful?

Solution

I got the same problem just yesterday:

How I solved:

First: if you installed Boost by source, make sure you are compiling it to right compiler toolset that you are using at netbeans. For instance, I tested it with MinGW @ Windows 8 Boost/MingW.

Second: In Netbeans (I used 7.4 version), I added the libraries I want by hand:

Project Properties > Linker > Libraries > Add Library > Select the .a files.

EDIT:

This link maybe be useful: undefined reference with boost when I try to compile

OTHER TIPS

Great, so finally it worked, here is what I did: 1- Installed gcc 4.8 (not sure if this is relevant). 2- downloaded and unpacked boost into /usr/local 3- ran bootstrap.sh 4- modify toolset parameter in project-config.jam into using gcc : 4.8.1 : g++-4.8 ; 5- run ./b2 --with-system 6- run ./b2 --with-filesystem both step 5 and 6 are done with user root. 7- compile the source file like this:

# g++-4.8 mr.cpp -L /usr/local/boost_1_55_0/stage/lib -I /usr/local/boost_1_55_0 -lboost_system -lboost_filesystem -o mr

Jee, finally, I was few minutes from quitting Boost.

What I think made a difference is the consistency of the compiler (toolset) and the install path, and specially those two "-L /usr/local/boost_1_55_0/stage/lib -I /usr/local/boost_1_55_0"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top