C++ wxWidgets:对wxURL的未定义引用

C++ wxWidgets:对wxURL的未定义引用,c++,reference,wxwidgets,C++,Reference,Wxwidgets,创建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

创建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()'|
#包括
....
wxURL url(L)http://site.com/file.txt");
)]+0x8d)| |对“wxURL::wxURL(wxString const&)”的未定义引用|
)]+0xba)| |对“wxURL::~wxURL()”的未定义引用|
)]+0x15e)| |对“wxURL::~wxURL()”的未定义引用|

为什么会这样?

编译代码时,是否也链接了相应的
.cpp
文件/库(与
wxURL
相关)?这很重要,因为您的错误是链接时间我通过链接到wxNet库解决了它

在代码块cbp文件中:

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

....
....

这只是
wxURL
对象吗?你说得对!您需要链接wxNet(wxbase28_net.lib(release)或wxbase28d_net.lib(debug))库,以便使用wxURL、wxHTTP和其他网络类。