c++ - 在带有 Windows/Cygwin 的 Netbeans 中使用 gnuplot-iostrem 库进行编译时出现问题

标签 c++ boost netbeans cygwin gnuplot

<分区>

我试图在 Netbeans 中使用库 gnuplot-iostream 和 Windows/Cygwin,但仅仅将它包含在我的源代码中会导致编译问题。我已经使用 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"

我也找不到任何提及此错误的信息。有人知道我做错了什么吗?

谢谢

最佳答案

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

你看到了-lcygcurl-4 ?这实际上将您的代码与 curl 链接在一起执行。图书馆搜索-L<xxx>用于 boost 的路径看起来不错,但您仍然需要指定在那里找到的特定库并且需要链接到您的程序。

如果您指定使用 -l<yyy> 链接其他库选项,这些被解析为查找lib<yyy>.a (或 lib<yyy>.lib )在您的实际构建环境中。

如前所述,只需应用 #include <yyy.hpp>不足以告诉工具链(链接器)实际实现来自哪里。添加库的方式与添加 cygcurl-4 的方式相同库与您的 IDE/构建系统。

从评论中转移讨论,使其成为一个答案(可怜我知道,我已经标记了重复项。这只是因为这个简单的澄清显然不太适合评论)

关于c++ - 在带有 Windows/Cygwin 的 Netbeans 中使用 gnuplot-iostrem 库进行编译时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24374019/

相关文章:

c++ - 为什么 Boost Format 和 printf 在相同的格式字符串上表现不同

android - 将 Android 平台添加到 NetBeans 6.9 时出现问题

java - Java 中的 GridView

c++ - 如何在 SDL 2.0 中清除屏幕的一部分

c++ - 在 C++ 函数中多次使用数组

c++ - c++ 中的 get() 和 getline() 对换行符的处理方式不同吗?

java - 使用 Netbeans 和 JSF 搭建 ManyToMany 关联

c++在子字符串的最后一个匹配之后删除子字符串

c++ - 我可以在 Boost 中使用 std::function (C++11 lambda) 吗?

c++ - 我可以使用 Boost::program_options 将可猜测和不可猜测的选项一起解析吗?