wxWidgets:对 wxURL 的未定义引用

wxWidgets: undefined reference to wxURL

本文关键字:未定义 引用 wxURL wxWidgets      更新时间:2023-10-16

当我创建一个wxURL对象时,我收到一个未定义的引用错误:

#include <wx/url.h>
....
wxURL url(L"http://site.com/file.txt");
)]+0x8d)||undefined reference to `wxURL::wxURL(wxString const&)'|
)]+0xba)||undefined reference to `wxURL::~wxURL()'|
)]+0x15e)||undefined reference to `wxURL::~wxURL()'|

为什么会这样呢?

当你编译你的代码时,你是否也链接了相应的.cpp文件/库(与wxURL有关)?这是必不可少的,因为您的错误是链接时间

我通过链接到wxNet库解决了它。

在 CodeBlocks cbp 文件中:

<Linker>
    ....
<Add library="libwxbase29u_net.a" />
    ....
</Linker>