【问题标题】:AttachConsole has not been declaredAttachConsole 尚未声明
【发布时间】:2017-05-18 08:13:25
【问题描述】:

我从here 得到了 wxWidget 的 master 分支。我从here 下载了 tdm-gcc(我确定我使用的 mingw32-make 来自 tdm-gcc 内部)。按照wxWiki 的指示,我在powershell 上执行了(多次尝试)

mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release clean
mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release

但我不断收到错误

../../src/msw/app.cpp: In member function 'bool {anonymous}::wxConsoleStderr::DoInit()':
../../src/msw/app.cpp:416:11: error: '::AttachConsole' has not been declared
 if ( !::AttachConsole(ATTACH_PARENT_PROCESS) )
       ^
makefile.gcc:14269: recipe for target 'gcc_mswu\corelib_app.o' failed
mingw32-make: *** [gcc_mswu\corelib_app.o] Error 1
mingw32-make: *** Waiting for unfinished jobs....

【问题讨论】:

  • 你有哪个版本的 TDM-GCC?一定是很旧的或者很新的,但我不知道是哪个...
  • 尝试将include/wx/msw/setup0.h复制到include/wx/msw/setup.h并重复mingw32-exe命令。
  • @VZ。我用过tdm64-gcc-5.1.0-2,用tdm64-gcc-4.9.2-3至少让我摆脱了这个问题。
  • 很奇怪,我确实看到 x86_64-w64-mingw32\include\wincon.h 中的 AttachConsole() 声明作为 TDM-GCC 5.1.0 的一部分分发。不知道为什么编译器在那里找不到它,你能以某种方式破坏你的标题吗?

标签: c++ powershell gcc wxwidgets


【解决方案1】:

插入

#ifndef WINVER
    #define WINVER 0x0603
#endif

#ifndef _WIN32_WINNT
    #define _WIN32_WINNT 0x0603
#endif

#ifndef _WIN32_IE
    #define _WIN32_IE 0x0700
#endif

之前

#include <_mingw.h>

include/wx/msw/gccpriv.h。 (这将some of this GitHub pull request 应用于已分发的 wxWidgets 3.1.0。下一个 wxWidgets 版本,无论是 3.1.1 还是 3.2.0,都应该解决这个问题。)

【讨论】:

  • 谢谢!这为我修好了。我正在编译 wx v3.1.0。奇怪的是,它使用 TDM 的 64 位 gcc v5.1.0 开箱即用地编译,但使用 MinGW 的 32 位 gcc v6.3.0 时出现此错误。
猜你喜欢
  • 2011-01-22
  • 2017-07-05
  • 2019-09-19
  • 2012-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-20
相关资源
最近更新 更多