C++ GNU 链接器错误
我正在尝试通过 Cygwin 使用编译命令在 Windows 上编译我的程序:
g++ ping.cpp -I./include -L./lib -lchartdir50
我正在使用一个名为 ChartDirector 的 API,它为我绘制图表。我以前从未以这种方式链接过库(通常我通过 Visual Studio 进行),所以我对此有点陌生。我有一个非常大的错误列表,所以我不会全部列出,但我会列出一个只是为了澄清我收到的链接器错误的类型:
(.text$_ZN9BaseChartD1Ev[BaseChart::~BaseChart()]+0x4f):对“_CBaseChart_destroy”的未定义引用
所有这些都是对 'xxx' 错误的未定义引用。
我在 ./include 中有一堆头文件,在 ./lib 中有一个名为 chartdir50.lib 的库。
我的编译行有什么问题?
I'm trying to compile my program on Windows via Cygwin with the compilation command:
g++ ping.cpp -I./include -L./lib -lchartdir50
I'm using an API called ChartDirector which draws charts for me. I've never linked libraries this way before (usually I do it through Visual Studio), so I’m a little new to this. I've got a really large list of errors, so I won't list them all, but I’ll list one just to clarify the type of linker errors I’m getting:
(.text$_ZN9BaseChartD1Ev[BaseChart::~BaseChart()]+0x4f): undefined reference to '_CBaseChart_destroy'
All of these are undefined reference to 'xxx' errors.
I've got a bunch of header files in ./include and a library called chartdir50.lib in ./lib.
What’s wrong with my compilation line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我以前从未使用过该库,但是当我谷歌搜索它,我注意到其他人尝试-lchartdir 而不是 -lchartdir50,所以你应该给出尝试一下。
I never use that library before, but when I googled it, I noticed that other people trying like -lchartdir instead of -lchartdir50, so you should give it a try.
我不确定,但是
.lib
是用 Visual C++ 编译的吗?如果是的话,我认为它与 GCC 不兼容。您必须使用 GCC/G++ 编译库并使用该文件,或者如果您无权访问源代码,则必须使用兼容的二进制文件。
I am not sure, but
.lib
have been compiled with Visual C++?If yes, I don't think it's compatible with GCC. You have to compile the library with GCC/G++ and use that file or to use a compatible binary if you don't have access to the source.
嗯……这很奇怪。我使用的是 64 位系统,但由于某种原因我尝试使用 32 位库并编译它。谢谢!
Hmm... that’s odd. I'm using a 64-bit system, but for some reason I tried it with the 32-bit library and it compiled. Thanks!
我假设该库也是用 GCC 创建的。
据我所知,.lib 是一个静态库,因此您不必使用 -l 编译器开关来指向它。
只需将其用作命令行上的另一个文件,例如
I assume that library was also created with GCC.
As far as I know, .lib is a static library, so you don't have to point it with the -l compiler switch.
Just use it as another file on the command line, like