【问题标题】:wxWidgets project compilation fails on Windows 10 with TDM-GCCwxWidgets 项目编译在带有 TDM-GCC 的 Windows 10 上失败
【发布时间】:2016-08-30 04:56:59
【问题描述】:

我正在尝试使用 TDM-GCC 4.7.1 32 位在 Windows 10 上编译 wxWidgets 3.0.2 项目,我在下面收到此错误:

编译

mingw32-g++.exe -Wall -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wall -std=c++11 -g -Wall -std=c++11 -g -Ilibrary\xerces-c-3.1.1\src -Ilibrary\mupdf-1.6\include -Ilibrary\wxWidgets-3.0.2\include -Ilibrary\wxWidgets-3.0.2\lib\wx\include\msw-unicode-3.0\ -Iinclude -IC:\TDM471-32\include -IC:\TDM471-32\include -c F:\Proj\Document.cpp -o obj\Debug\Document.o

错误

In file included from library\wxWidgets-3.0.2\include/wx/string.h:45:0,
                 from library\wxWidgets-3.0.2\include/wx/memory.h:15,
                 from library\wxWidgets-3.0.2\include/wx/object.h:19,
                 from library\wxWidgets-3.0.2\include/wx/wx.h:15,
                 from F:\Proj\Document.h:4,
                 from F:\Proj\Document.cpp:1:
library\wxWidgets-3.0.2\include/wx/wxcrtbase.h: In function 'wchar_t* wxStrdup(const wchar_t*)':
library\wxWidgets-3.0.2\include/wx/wxcrtbase.h:680:68: error: 'wcsdup' was not declared in this scope
In file included from library\wxWidgets-3.0.2\include/wx/string.h:45:0,
                 from library\wxWidgets-3.0.2\include/wx/memory.h:15,
                 from library\wxWidgets-3.0.2\include/wx/object.h:19,
                 from library\wxWidgets-3.0.2\include/wx/wx.h:15,
                 from F:\Proj\Main.cpp:1:
library\wxWidgets-3.0.2\include/wx/wxcrtbase.h: In function 'wchar_t* wxStrdup(const wchar_t*)':
library\wxWidgets-3.0.2\include/wx/wxcrtbase.h:680:68: error: 'wcsdup' was not declared in this scope
In file included from library\wxWidgets-3.0.2\include/wx/crt.h:19:0,
In file included from library\wxWidgets-3.0.2\include/wx/crt.h:19:0,
                 from library\wxWidgets-3.0.2\include/wx/string.h:4305,
                 from library\wxWidgets-3.0.2\include/wx/memory.h:15,
                 from library\wxWidgets-3.0.2\include/wx/object.h:19,
                 from library\wxWidgets-3.0.2\include/wx/wx.h:15,
                 from F:\Proj\Document.h:4,
                 from F:\Proj\Document.cpp:1:
library\wxWidgets-3.0.2\include/wx/wxcrt.h: In function 'size_t wxStrnlen(const char*, size_t)':
library\wxWidgets-3.0.2\include/wx/wxcrt.h:173:92: error: 'strnlen' was not declared in this scope
library\wxWidgets-3.0.2\include/wx/wxcrt.h: In function 'size_t wxStrnlen(const wchar_t*, size_t)':
library\wxWidgets-3.0.2\include/wx/wxcrt.h:187:95: error: 'wcsnlen' was not declared in this scope
                 from library\wxWidgets-3.0.2\include/wx/string.h:4305,
                 from library\wxWidgets-3.0.2\include/wx/memory.h:15,
                 from library\wxWidgets-3.0.2\include/wx/object.h:19,
                 from library\wxWidgets-3.0.2\include/wx/wx.h:15,
                 from F:\Proj\Main.cpp:1:
library\wxWidgets-3.0.2\include/wx/wxcrt.h: In function 'size_t wxStrnlen(const char*, size_t)':
library\wxWidgets-3.0.2\include/wx/wxcrt.h:173:92: error: 'strnlen' was not declared in this scope
library\wxWidgets-3.0.2\include/wx/wxcrt.h: In function 'size_t wxStrnlen(const wchar_t*, size_t)':
library\wxWidgets-3.0.2\include/wx/wxcrt.h:187:95: error: 'wcsnlen' was not declared in this scope

【问题讨论】:

  • 你是先配置还是直接使用Makefile?
  • 什么意思? wxWidgets 已编译,我使用它作为库来编译与之链接的 cpp 项目。
  • 所以这些错误来自项目而不是库本身?你使用什么版本的 gcc?你是从哪里弄来的?您是否使用相同的编译器构建 wx?你如何构建你的项目?

标签: gcc wxwidgets


【解决方案1】:

我不确定这是否能解释您的问题,但无论如何,在命令行上使用 -DwxUSE_UNICODE 是错误的,所有 wxUSE_XXX 符号都应该定义为 0 或 1,而不是没有。但即使-DwxUSE_UNICODE=1 也是错误的,因为这可能导致 CRT/SDK 和 wxWidgets 标头之间不匹配。相反,您应该预定义 _UNICODE 和/或 UNICODE(前者由 CRT 使用,后者由 SDK 使用,但 SDK 也会选择带有下划线的版本)并且 wxWidgets 也会尊重它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 2014-03-18
    相关资源
    最近更新 更多