简体   繁体   English

编译wxWidgets时出错

[英]Errors compiling wxWidgets

I am trying to run the sample code shown here . 我正在尝试运行此处显示的示例代码。 I built wxWidgets from source using MinGW, with this command: mingw32-make -f makefile.gcc SHARED=1 UNICODE=0 BUILD=debug. 我使用以下命令从MinGW的源代码构建了wxWidgets:mingw32-make -f makefile.gcc SHARED = 1 UNICODE = 0 BUILD = debug。 In my Eclipse settings, I add -Iwx288/include, -Lwx288/lib, -lwxbase28d_gcc_custom and -lwxmsw28d_core_gcc_custom. 在我的Eclipse设置中,添加-Iwx288 / include,-Lwx288 / lib,-lwxbase28d_gcc_custom和-lwxmsw28d_core_gcc_custom。 I get very very confused, due to the number of ways to compile and inexperience with linkers. 由于链接器的编译方式和经验不足,我感到非常困惑。 I get these errors, what am I doing wrong? 我收到这些错误,我在做什么错? I'm not even citing wxMutex in my program. 我什至没有在程序中引用wxMutex。

23:15:19 **** Incremental Build of configuration Debug for project A ****
Info: Internal Builder is used for build
g++ "-IC:\\Files\\Programming\\C++\\A\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "include\\wx\\thrimpl.o" "..\\include\\wx\\thrimpl.cpp" 
..\include\wx\thrimpl.cpp:18:1: error: 'wxMutex' does not name a type
..\include\wx\thrimpl.cpp:29:1: error: 'wxMutex' does not name a type
..\include\wx\thrimpl.cpp:34:6: error: 'wxMutex' has not been declared
..\include\wx\thrimpl.cpp:34:22: error: non-member function 'bool IsOk()' cannot have cv-qualifier
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:36:12: error: 'm_internal' was not declared in this scope
..\include\wx\thrimpl.cpp:36:26: error: 'NULL' was not declared in this scope
..\include\wx\thrimpl.cpp: At global scope:
..\include\wx\thrimpl.cpp:39:1: error: 'wxMutexError' does not name a type
..\include\wx\thrimpl.cpp:47:1: error: 'wxMutexError' does not name a type
..\include\wx\thrimpl.cpp:55:1: error: 'wxMutexError' does not name a type
..\include\wx\thrimpl.cpp:224:1: error: 'wxCondition' does not name a type
..\include\wx\thrimpl.cpp:235:1: error: 'wxCondition' does not name a type
..\include\wx\thrimpl.cpp:240:6: error: 'wxCondition' has not been declared
..\include\wx\thrimpl.cpp:240:26: error: non-member function 'bool IsOk()' cannot have cv-qualifier
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:240:6: error: redefinition of 'bool IsOk()'
..\include\wx\thrimpl.cpp:34:6: error: 'bool IsOk()' previously defined here
..\include\wx\thrimpl.cpp:242:12: error: 'm_internal' was not declared in this scope
..\include\wx\thrimpl.cpp:242:26: error: 'NULL' was not declared in this scope
..\include\wx\thrimpl.cpp: At global scope:
..\include\wx\thrimpl.cpp:245:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:253:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:261:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:269:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:281:1: error: 'wxSemaphore' does not name a type
..\include\wx\thrimpl.cpp:291:1: error: 'wxSemaphore' does not name a type
..\include\wx\thrimpl.cpp:296:6: error: 'wxSemaphore' has not been declared
..\include\wx\thrimpl.cpp:296:26: error: non-member function 'bool IsOk()' cannot have cv-qualifier
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:296:6: error: redefinition of 'bool IsOk()'
..\include\wx\thrimpl.cpp:34:6: error: 'bool IsOk()' previously defined here
..\include\wx\thrimpl.cpp:298:12: error: 'm_internal' was not declared in this scope
..\include\wx\thrimpl.cpp:298:26: error: 'NULL' was not declared in this scope
..\include\wx\thrimpl.cpp: At global scope:
..\include\wx\thrimpl.cpp:301:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp:309:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp:317:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp:325:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:299:1: warning: control reaches end of non-void function [-Wreturn-type]
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:243:1: warning: control reaches end of non-void function [-Wreturn-type]
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]

23:15:20 Build Finished (took 657ms)

I'm guessing you are either missing something in your include path or some of the Defines required by wxWidgets in order to process wxWidgets Header-Files correctly 我猜想您要么缺少包含路径中的内容,要么缺少wxWidgets所需的一些Defines,以便正确处理wxWidgets Header-Files

WX comes with a tool called wx-config ( should be located somewhere in wxWidgets/bin if your build was successful) WX带有一个名为wx-config的工具(如果构建成功,则应位于wxWidgets/bin某个位置)

wx-config is a shell-script, you can execute it using mingw-msys wx-config是一个shell脚本,您可以使用mingw-msys执行它

wx-config --cxxflags produces all Include Paths and Defines needed to compile object files. wx-config --cxxflags生成编译目标文件所需的所有包含路径和定义。 wx-config --libs takes care of everything needed to link the program wx-config --libs处理链接程序所需的一切

I would recommend using wx-config in your makefile/builder/... . 我建议在您的makefile/builder/...使用wx-config or check the output produced by it and compare it to your build process 或检查其产生的输出并将其与构建过程进行比较

Samples form my current installation: 我当前安装的样本:

$ wx-config --cxxflags --static=no --debug=yes --unicode=no -I/wx/lib/wx/include/msw-ansi-debug-2.8 -I/wx/include/wx-2.8 -D_ WXDEBUG _ -DWXUSINGDLL -D_ WXMSW _ -mthreads

$ ./wx-config --libs --static=no --debug=yes --unicode=no -L/wx/lib -mthreads -Wl,--subsystem,windows -mwindows -lwx_mswd_richtext-2.8 -lwx_mswd_aui-2.8 -lwx_mswd_xrc-2.8 -lwx_mswd_qa-2.8 -lwx_mswd_html-2.8 -lwx_mswd_adv-2.8 -lwx_mswd_core-2.8 -lwx_based_xml-2.8 -lwx_based_net-2.8 -lwx_based-2.8

Why are you trying to compile include/wx/thrimpl.cpp ? 为什么要尝试编译include/wx/thrimpl.cpp It's not your file, it's part of wxWidgets and it shouldn't be compiled as part of your project. 它不是您的文件,而是wxWidgets的一部分,不应作为项目的一部分进行编译。 Just remove it from the list of project files. 只需将其从项目文件列表中删除即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM