【问题标题】:wxWidgets linking error, undefined references and wx-config not foundwxWidgets 链接错误,未定义的引用和 wx-config 未找到
【发布时间】:2015-06-02 14:13:34
【问题描述】:

所以我尝试在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...

【问题讨论】:

    标签: eclipse windows linker wxwidgets


    【解决方案1】:

    除非你使用Cygwin,否则Windows下不会有wx-config,所以你需要手动将编译和链接选项都指定为explained in the documentation

    【讨论】:

    • 我这样做了,错误消失了。但是,当我尝试运行 .exe 文件时,系统抱怨缺少 dll 文件。所以我将 dll 文件复制到目录中,程序启动没有错误,但没有做任何事情(没有显示窗口,我正在从 wxWidgets 编译 hello world 顺便说一句)
    • DLL 需要位于 PATH 中或与程序位于同一目录中,这正是 Windows 的工作方式。至于你上面的程序,它什么都不做,所以不清楚你期望发生什么。
    猜你喜欢
    • 2020-08-10
    • 2016-06-10
    • 2015-01-23
    • 2022-09-24
    • 2014-02-13
    • 2014-04-21
    • 2013-03-15
    • 2023-04-10
    • 1970-01-01
    相关资源
    最近更新 更多