0

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..

Aus
  • 1,183
  • 11
  • 27
  • I just added -lboost_system which eliminates the other error message, but still the boost_filesystem complaines. – Aus Jan 02 '14 at 12:49

2 Answers2

1

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

Community
  • 1
  • 1
wesley.mesquita
  • 795
  • 5
  • 12
  • I use g++ for both the linux box and in netbeans' remotehost toolchain. The resulted compiled boost library are in boost_1_55_0/bin.v2/.... and that directory is shared with samba, I picked up those .a libraries in netbeans as you said, you can see them in the build log I posted. Still I get the same error. – Aus Jan 02 '14 at 13:11
  • Did you add boost_system file? I only saw '-lmysqlcppconn-static -lmysqlclient -lboost_filesystem' – wesley.mesquita Jan 02 '14 at 13:16
  • Yes I added it which solved the other exceptions I had in the build log, but this message keep comming: build/Debug/GNU-Linux-x86/mr_deamon.o: In function `path': /opt/mail-relay/mr_deamon/boost_1_55_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()' – Aus Jan 02 '14 at 13:23
  • Please, copy the contents of `Project Properties > Linker > Libraries`. In advance, I read somewhere about the needs to add multthreaded libs (with '-mt') for some environments, maybe it can be your case. – wesley.mesquita Jan 02 '14 at 13:45
  • Now I started from scratch on the ubuntu box, the source file is [link](http://www.boost.org/doc/libs/1_55_0b1/libs/filesystem/example/tut1.cpp) 'this' and the compile command is this g++ -pthread mr.cpp -lboost_filesystem -lboost_system I still get the same error!!! – Aus Jan 02 '14 at 14:03
  • I also tried as you said: g++ -pthread mr.cpp -lboost_filesystem-mt -lboost_system-mt still doesn't make any difference in the compile output – Aus Jan 02 '14 at 14:08
  • Please, if you got things working post here! I working on projects using Netbens/C++11/Boost. Any complement is helpful! – wesley.mesquita Jan 02 '14 at 16:09
  • The procedure below is applicable if you're compiling with GCC locally on linux. if you do remote or local Netbeans, then make sure that you adjust the compiler name in project properties->build->c++compiler to g++-4.8 and add -std=c++11 in the Additional options. then update the compiler name again in Build->Linker, then under Tools->Options->Build Tools update c++compiler to /usr/bin/g++-4.8. also make sure you select the boost .a libraries from /usr/local/boost_1_55_0/stage/lib. – Aus Jan 03 '14 at 08:36
1

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"

Aus
  • 1,183
  • 11
  • 27