Search code examples
c++boostnetbeanscygwingnuplot

Problems compiling using gnuplot-iostrem library in Netbeans with Windows/Cygwin


I am trying to use the library gnuplot-iostream in Netbeans with Windows/Cygwin, but merely including it in my source leads to compilation problems. I have already downloaded boost with the Cygwin interface. Yet, the message I get is:

mkdir -p dist/Debug/Cygwin_4.x-Windows
g++     -o dist/Debug/Cygwin_4.x-Windows/welcome_1 build/Debug/Cygwin_4.x-Windows/welcome.o -L../../../../../cygwin64 -L../../../../../cygwin64/lib/curl -L../../../../../cygwin64/bin -lcygcurl-4
build/Debug/Cygwin_4.x-Windows/welcome.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:222:(.text+0x51ca): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223:(.text+0x51d6): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
/usr/include/boost/system/error_code.hpp:224:(.text+0x51e2): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::system::system_category()'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin_4.x-Windows/welcome_1.exe' failed
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/welcome_1.exe] Error 1

I haven't made any reference to the library besides including it:

#include "gnuplot-iostream.h"

I also can't find any mention of this error. Does anybody know what I am doing wrong?

Thanks


Solution

  • I believe you are saying the problem is with not properly linking to the boost libraries, correct?

    You see that -lcygcurl-4? This actually links your code with the curl implementation. The library search -L<xxx> pathes you have for boost look fine, but you'll have still need to specify particular libraries found there and need being linked to your program.

    If you specify linking additional libraries using the -l<yyy> option, these are resolved as looking up lib<yyy>.a (or lib<yyy>.lib) in your actual build environment.

    As mentioned just applying an #include <yyy.hpp> isn't enough to tell the toolchain (linker) where the actual implementation comes from. Add the library the same way you've added that cygcurl-4 libraray with your IDE/build system.

    Transferred discussion from comments, to make this an answer (poor I know and I've marked the duplicates already. It's just because this simple clarification doesn't fit a comment very well apparently)