0

I've recently switched from visual studio 2010 express to using NetBeans, and i'm already very impressed with the layout and simplicity, even though it did take a bit of nudging to compile right. However, i've got another problem. When i tested to see if boost would work as well, i included the file boost/signals.hpp in a main.cpp and then went to the additional library directories in the project options and added the lib directory of my boost install, same as i would do in visual studio. After all this, i get a bunch of undefined references anyway.

I'm using the mingw compiler with msys and i have boost version 1.47 if that makes any difference. I can confirm that this same install of boost works fine when using visual studio.

Here is the build log.

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory m`/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/syncopate5.exe
make[2]: Entering directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
mkdir -p dist/Debug/MinGW-Windows
g++.exe     -o dist/Debug/MinGW-Windows/syncopate5 build/Debug/MinGW-Windows/main.o -L/C/Program\ Files\ \(x86\)/boost/boost_1_47/lib 
build/Debug/MinGW-Windows/main.o: In function `ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvEEEED2Ev':
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:139: undefined reference to `boost::signals::trackable::~trackable()'
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:139: undefined reference to `boost::signals::detail::signal_base::~signal_base()'
make[2]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:139: undefined reference to `boost::signals::detail::signal_base::~signal_base()'
make[1]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
build/Debug/MinGW-Windows/main.o: In function `ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvEEEEC2ERKS2_RKS4_':
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:197: undefined reference to `boost::signals::detail::signal_base::signal_base(boost::function2<bool, boost::signals::detail::stored_group, boost::signals::detail::stored_group> const&, boost::any const&)'
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:197: undefined reference to `boost::signals::detail::signal_base::~signal_base()'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/syncopate5.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

Edit:

After trying to add the required lib file manually via the add libraries dialog in the project properties, i receive this error.

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/syncopate5.exe
make[2]: Entering directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
make[2]: *** No rule to make target `../../../../../../Program Files \(x86\)/boost/boost_1_47/lib/libboost_signals-vc100-mt-1_47.lib', needed by `dist/Debug/MinGW-Windows/syncopate5.exe'.  Stop.
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
make[1]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'

BUILD FAILED (exit value 2, total time: 9s)
FatalCatharsis
  • 3,407
  • 5
  • 44
  • 74
  • You've told NetBeans where _find_ the Boost libraries, but not to actually link with any. – Some programmer dude Feb 08 '13 at 07:24
  • so how would I instruct it to do so? and why did i never have to do it in visual studio? – FatalCatharsis Feb 08 '13 at 07:27
  • 1
    Somewhere in the project properties there should be a field where you can add libraries, the one you should add is `boost_signals`. You managed to add the library search folder (the `-L` argument seen in the linker command line in the provided log), the libraries should probably be on that page as well. As for Visual Studio, if you want to link with a non-standard library (like the Boost libraries) you need to add them manually as well. – Some programmer dude Feb 08 '13 at 07:52
  • tried to add that library manually, and i've added the error log to my question. In visual studio, i used to link to individual libraries, but then later discovered that after setting the directory of the libraries, it would load the relevant ones automatically. – FatalCatharsis Feb 08 '13 at 08:03

2 Answers2

1

This depends on how you built the project.

If you built the project from an existing makefile, your library paths and libraries should be present in the build environment.

If you built the project by hand by piece-mealing the source, include, and libraries in individually, you will need to explicitly add the libraries that you want.

Specifically, looking at your updated build log, it appears you're not linking the required library and instead added it as a target somehow.

Right click on your project, go to Properties, under the Build tab look toward Linker, Here is where you should specify your link path and your dynamic/static libraries.

Tyler Jandreau
  • 4,245
  • 1
  • 22
  • 47
  • I'll admit that i really don't understand much about the compilation process itself. I don't know what the importance of a makefile is or it's purpose. When i made the project, i selected the C/C++ Application project which made a makefile for me. Then i just created a main.cpp in the source folder there that included boost/signals.hpp and tried to link via project settings, via properties->build->linker and set additional library directories to the boost_1_47/lib and then selected the button next to libraries and located that lib. What have i done/not done correctly? – FatalCatharsis Feb 08 '13 at 15:34
  • I'm not sure. It looks like you've done everything I would have done to set the project up. Did you add `Library...` or `Library File...`? – Tyler Jandreau Feb 08 '13 at 16:07
  • i've tried both, and i've also tried the two different versions of the file, the .lib and the .dll . I was having some trouble installing mingw before. when i ran the download from their website and told it to also include msys, the msys folder didn't have make.exe and so i uninstalled the whole thing, and then installed mingw and msys seperately, specifying the make.exe in c:\msys\1.0\bin\make.exe as my make command for netbeans. That allowed me to build a hello world just fine. could this change be related to my problem? like i said, i don't know much about makefiles :\. – FatalCatharsis Feb 08 '13 at 17:06
  • Also an interesting tidbit, the only way i am able to select the .lib file in their select library dialogue, is by telling it to look for files of type: all files. The only options available are .a and .dll . And even with .dll selected, the .dll files in the lib folder don't appear. Could this whole problem be because netbeans 7.2.1 doesn't recognize .lib or is maybe just buggy? reinstalling it again right now. – FatalCatharsis Feb 08 '13 at 17:12
0

After hours of googling and reading, i have discovered a little more about boost and finally found and understand my problem. When i originally obtained my install of boost, it was from BoostPro which has all the header only objects, as well as precompiled binaries for vc++ ONLY. After obtaining the most recent version of boost, and boost.build to create gcc versions of the libraries and linking against them, it worked without a hitch. Thanks Tyler Jandreau an Joachim Pileborg for answering my inherently flawed question :.

FatalCatharsis
  • 3,407
  • 5
  • 44
  • 74