gpt4 book ai didi

C++ wxWidgets Code::Blocks 自定义项目 "normal"编译和 C++11 启用期间的交叉编译链接错误

转载 作者:行者123 更新时间:2023-11-28 06:44:26 25 4
gpt4 key购买 nike

我使用 Lubuntu 14.04 LTS AMD64。
通过这种方式,我在 that tutorial 的帮助下编译了 wxWidgets 3.0.1(我更改了全局编译器设置,而不是目标设置 - 我的 Win 目标名称是 Windows):

/home/tomasz/Pobrane/src/wxWidgets-3.0.1/configure prefix=/usr/local/i386-mingw32 --host=i386-mingw32 --build=x86_64-linux --enable-unicode --disable-shared --disable-debug --with-msw --enable-stl

然后我使用 make -j3 并安装 make。一切还好。但是,链接存在问题:

obj/Windows/main.o:main.cpp:(.text+0x23): undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'
obj/Windows/main.o:main.cpp:(.text+0x81): undefined reference to wxAppConsoleBase::CheckBuildOptions(char const*, char const*)'

我认为问题与 wx/app.h 有关,因为当我禁用它时,没有像那些错误那样的错误。

整个日志:

-------------- Build: Windows in Symulator Kostek (compiler: MingW32 Compiler)---------------

i386-mingw32-g++ -I/usr/local/i386-mingw32/include/ -c "/home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.cpp" -o obj/Windows/panels.o
i386-mingw32-g++ -L/usr/local/i386-mingw32/lib/ -o "bin/Windows/Symulator Kostek.exe" obj/Windows/main.o obj/Windows/main_frame.o obj/Windows/panels.o
In file included from /usr/local/i386-mingw32/include/wx/msw/gccpriv.h:61:0,
from /usr/local/i386-mingw32/include/wx/platform.h:456,
from /usr/local/i386-mingw32/include/wx/defs.h:27,
from /usr/local/i386-mingw32/include/wx/event.h:14,
from /usr/local/i386-mingw32/include/wx/window.h:18,
from /usr/local/i386-mingw32/include/wx/panel.h:19,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.h:4,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.cpp:1:
/usr/local/i386-mingw32/include/w32api.h:27:2: warning: #warning WARNING - The w32api.h header file is deprecated and will be removed. [-Wcpp]
#warning WARNING - The w32api.h header file is deprecated and will be removed.
^
obj/Windows/main.o:main.cpp:(.text+0x23): undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'
obj/Windows/main.o:main.cpp:(.text+0x81): undefined reference to `wxAppConsoleBase::CheckBuildOptions(char const*, char const*)'
/usr/local/lib/gcc/i386-mingw32/4.9.1/../../../../i386-mingw32/bin/ld: obj/Windows/main.o: zły adres przemieszczenia 0xf w sekcji `.text$_ZN8wxString7ImplStrEPKw[__ZN8wxString7ImplStrEPKw]'
/usr/local/lib/gcc/i386-mingw32/4.9.1/../../../../i386-mingw32/bin/ld: final link failed: Nieprawidłowa operacja
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 4 second(s))
2 error(s), 1 warning(s) (0 minute(s), 4 second(s))

当我尝试使用 C++11 时(由于存储库中的旧编译器,我手动编译 MinGW 的原因):

/usr/local/i386-mingw32/include/io.h:301:14: error: ‘off64_t’ does not name a type
/usr/local/i386-mingw32/include/io.h:302:14: error: ‘off64_t’ does not name a type
/usr/local/i386-mingw32/include/wx/wxcrtbase.h:680:68: error: ‘wcsdup’ was not declared in this scope

以及整个日志:

-------------- Build: Windows in Symulator Kostek (compiler: MingW32 Compiler)---------------

i386-mingw32-g++ -std=c++11 -I/usr/local/i386-mingw32/include/ -c "/home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.cpp" -o obj/Windows/panels.o
i386-mingw32-g++ -L/usr/local/i386-mingw32/lib/ -o "bin/Windows/Symulator Kostek.exe" obj/Windows/main.o obj/Windows/main_frame.o obj/Windows/panels.o
In file included from /usr/local/i386-mingw32/include/wx/msw/gccpriv.h:61:0,
from /usr/local/i386-mingw32/include/wx/platform.h:456,
from /usr/local/i386-mingw32/include/wx/defs.h:27,
from /usr/local/i386-mingw32/include/wx/event.h:14,
from /usr/local/i386-mingw32/include/wx/window.h:18,
from /usr/local/i386-mingw32/include/wx/panel.h:19,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.h:4,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.cpp:1:
/usr/local/i386-mingw32/include/w32api.h:27:2: warning: #warning WARNING - The w32api.h header file is deprecated and will be removed. [-Wcpp]
#warning WARNING - The w32api.h header file is deprecated and will be removed.
^
In file included from /usr/local/i386-mingw32/include/wx/wxcrtbase.h:41:0,
from /usr/local/i386-mingw32/include/wx/string.h:45,
from /usr/local/i386-mingw32/include/wx/memory.h:15,
from /usr/local/i386-mingw32/include/wx/object.h:19,
from /usr/local/i386-mingw32/include/wx/event.h:16,
from /usr/local/i386-mingw32/include/wx/window.h:18,
from /usr/local/i386-mingw32/include/wx/panel.h:19,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.h:4,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.cpp:1:
/usr/local/i386-mingw32/include/io.h:301:14: error: ‘off64_t’ does not name a type
__CRT_INLINE off64_t lseek64 (int, off64_t, int);
^
/usr/local/i386-mingw32/include/io.h:302:14: error: ‘off64_t’ does not name a type
__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) {
^
In file included from /usr/local/i386-mingw32/include/wx/string.h:45:0,
from /usr/local/i386-mingw32/include/wx/memory.h:15,
from /usr/local/i386-mingw32/include/wx/object.h:19,
from /usr/local/i386-mingw32/include/wx/event.h:16,
from /usr/local/i386-mingw32/include/wx/window.h:18,
from /usr/local/i386-mingw32/include/wx/panel.h:19,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.h:4,
from /home/tomasz/Dropbox/Programy/Linux/wxWidgets/Symulator Kostek/panels.cpp:1:
/usr/local/i386-mingw32/include/wx/wxcrtbase.h: In function ‘wchar_t* wxStrdup(const wchar_t*)’:
/usr/local/i386-mingw32/include/wx/wxcrtbase.h:680:68: error: ‘wcsdup’ was not declared in this scope
inline wchar_t* wxStrdup(const wchar_t *s) { return wxCRT_StrdupW(s); }
^
Process terminated with status 1 (0 minute(s), 5 second(s))
3 error(s), 1 warning(s) (0 minute(s), 5 second(s))

最佳答案

这里有两个完全不同的问题:

  1. 链接错误只是因为根本没有与 wxWidgets 库链接——您的命令行没有在任何地方提及它们。在您的 makefile 中使用 wx-config --libs 的输出。

  2. C++11 编译问题是由于在没有 C++11 支持的情况下编译 wxWidgets。使用 g++ 时,如果不在库中使用 C++11,则不能在应用程序中使用它,反之亦然,因为 C++98 和 C++11 ABI 兼容。使用 CXXFLAGS=-std=c++11 重建库以修复此问题。

关于C++ wxWidgets Code::Blocks 自定义项目 "normal"编译和 C++11 启用期间的交叉编译链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25272822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com