C ++ wxWidgets Code :: Blocks在自定义项目“正常”期间交叉编译链接错误编译和C ++ 11启用 [英] C++ wxWidgets Code::Blocks cross-compiling linking errors during custom project "normal" compilation and C++11 enabled

查看:792
本文介绍了C ++ wxWidgets Code :: Blocks在自定义项目“正常”期间交叉编译链接错误编译和C ++ 11启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Lubuntu 14.04 LTS AMD64。

这样,我在该教程(我更改了全局编译器设置,而不是目标 - 我的目标Win名称是Windows):

I use Lubuntu 14.04 LTS AMD64.
In this way I compiled wxWidgets 3.0.1 with the help of that tutorial (I changed global compiler settings, not the target ones - my target to Win name is 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


$ b b

然后我使用make -j3并安装make。一切还好。
然而,有链接的问题:

Then i used make -j3 and install make. Everything - OK. However, there is the problem with linking:

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,因为当我禁用它,没有像那些错误。

I think that the problem is connected with wx/app.h because when I disabled it, there weren't errors like the ones.

整个日志:

-------------- 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的原因):

And when I try to use C++11 (the reason why I compiled MinGW manually because of the old compiler in repository):

/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 的输出。

编译问题是由于编译wxWidgets没有C ++ 11支持。使用g ++,您不能在应用程序中使用C ++ 11而不在库中使用,反之亦然,因为C ++ 98和C ++ 11不是 ABI兼容的。使用 CXXFLAGS = -std = c ++ 11 重新构建库以修复此问题。

The C++11 compilation problems are due to compiling wxWidgets without C++11 support. With g++ you can't use C++11 in your application without using it in the library or vice versa as C++98 and C++11 are not ABI-compatible. Rebuild the library with CXXFLAGS=-std=c++11 to fix this.

这篇关于C ++ wxWidgets Code :: Blocks在自定义项目“正常”期间交叉编译链接错误编译和C ++ 11启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆