C++ GNU 链接器错误

发布于 2024-08-12 19:58:09 字数 558 浏览 11 评论 0原文

我正在尝试通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

萌面超妹 2024-08-19 19:58:09

我以前从未使用过该库,但是当我谷歌搜索它,我注意到其他人尝试-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.

辞慾 2024-08-19 19:58:09

我不确定,但是 .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.

九八野马 2024-08-19 19:58:09

嗯……这很奇怪。我使用的是 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!

桜花祭 2024-08-19 19:58:09

我假设该库也是用 GCC 创建的。

据我所知,.lib 是一个静态库,因此您不必使用 -l 编译器开关来指向它。

只需将其用作命令行上的另一个文件,例如

g++ ping.cpp -I./include -L./lib {path to lib here}/chartdir50.lib

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

g++ ping.cpp -I./include -L./lib {path to lib here}/chartdir50.lib
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文