【发布时间】:2014-08-13 23:18:25
【问题描述】:
我正在尝试在带有 Windows/Cygwin 的 Netbeans 中使用库 gnuplot-iostream,但仅将其包含在我的源代码中会导致编译问题。我已经下载了带有 Cygwin 界面的 boost。然而,我得到的信息是:
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
除了包含它之外,我没有对库进行任何引用:
#include "gnuplot-iostream.h"
我也找不到任何有关此错误的信息。有人知道我做错了什么吗?
谢谢
【问题讨论】:
-
'除了包含它之外,我没有对库进行任何引用:' 那么这可能很好地回答了你的问题:What is an undefined reference/unresolved external symbol error and how do I fix it?
-
其实我不相信包含一个不会被使用的库会导致任何错误。只是为了确保我尝试编译 gnuplot-iostream 主页上的第一个示例,但仍然得到基本相同的错误。
-
'其实我不相信包含一个不会被使用的库......'链接器明确声明它被使用来自
/usr/include/boost/system/error_code.hpp,您的代码 'infected' 带有此标头!那么为什么不简单地为您的链接器添加一个-lboost_system选项呢? -
我对库的唯一提及是
#include命令。无论如何,我如何添加这个-lboost_system选项?它应该怎么做?抱歉,我对 C++(和 Netbeans)完全陌生。 -
你没有用
#include声明来编造任何关于'只是提到'它的自动链接。如果它不是一个明确声明的 header only 库,您需要指定从何处获取包含的头文件中声明的实现。再次转到我在第一条评论中给你的那个链接,以获得更深入的解释。
标签: c++ boost netbeans cygwin gnuplot