wxWidgets链接错误,未定义的引用和未找到的wx-config

时间:2015-06-02 14:13:34

标签: eclipse windows linker wxwidgets

所以我尝试在Eclipse中编译和链接一个简单的wxWidgets示例,但每次我想使用wx-config --cxxflagswx-config --libs时,Eclipse都会告诉我没有这样的文件ro目录。不过没有那些标志,程序可以很好地编译,但链接给了我很多未定义的引用错误......我已经在Ubuntu上使用了wxWidgets,没有任何问题,但我在Windows上使用它是新的。

这是源代码:

#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class MyApp: public wxApp {
public:
virtual bool OnInit(){
    return true;
}
};

错误:

g++ "src\\TestMinimal.o" -mwindows -o TestMinimal.exe 
src\TestMinimal.o: In function `ZN8wxObjectaSERKS_':
C:/MinGW/msys/1.0/MinGW/include/wx-3.0/wx/object.h:374: undefined reference to `wxObject::Ref(wxObject const&)'
src\TestMinimal.o: In function `ZN23wxCriticalSectionLockerC1ER17wxCriticalSection':
C:/MinGW/msys/1.0/MinGW/include/wx-3.0/wx/thread.h:307: undefined reference to `wxCriticalSection::Enter()'
ect...

1 个答案:

答案 0 :(得分:0)

除非您使用Cygwin,否则您在Windows下不会拥有req,因此您需要手动将编译和链接选项指定为explained in the documentation