简体   繁体   English

静态构建Qt之后,我无法在Windows 7上编译/链接应用程序(GNU分配器错误)

[英]After building Qt statically, I can't get to compile / link an application on Windows 7 (GNU allocator error)

I'm trying to statically link my app against Qt. 我正在尝试将我的应用程序与Qt静态链接。 This is what I did: 这是我所做的:

  1. downlaoded the Qt libs 4.8.1 贬低了Qt库4.8.1
  2. donwloaded MinGW 已下载MinGW
  3. configured Qt with: 使用以下命令配置Qt:

    configure -release -platform win32-g++ -nomake examples -nomake demos -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite configure -release -platform win32-g ++ -nomake示例-nomake演示-no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no -style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite

  4. run win32-make 运行win32-make

  5. setup my project in Qt Creator (from the SDK 4.8 also) to release and to use the static lib. 在Qt Creator中设置我的项目(也从SDK 4.8开始)以发布和使用静态库。

add CONFIGURE += static to the .pro file 将CONFIGURE + = static添加到.pro文件

And I get this error (apparently something is not liking something about my code using std::vector<> ?): 而且我得到了这个错误(显然,使用std :: vector <>吗?我的代码不喜欢某些东西):

C:/MinGW/bin/mingw32-make.exe -f Makefile.Release
mingw32-make.exe[1]: Entering directory `C:/PhotoChop-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Release'
g++ -c -Os -momit-leaf-frame-pointer -fno-exceptions -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_DYNAMIC_CAST -I"..\..\..\Qt\4.8.1\include\QtCore" -I"..\..\..\Qt\4.8.1\include\QtGui" -I"..\..\..\Qt\4.8.1\include" -I"..\..\..\Qt\4.8.1\include\ActiveQt" -I"release" -I"." -I"..\PhotoChop" -I"." -I"..\..\..\Qt\4.8.1\mkspecs\win32-g++" -o release\mainwindow.o ..\PhotoChop\mainwindow.cpp
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/mingw32/bits/c++allocator.h:34:0,
                 from c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/allocator.h:48,
                 from c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/string:43,
                 from ..\..\..\Qt\4.8.1\include/QtCore/../../src/corelib/tools/qstring.h:54,
                 from ..\..\..\Qt\4.8.1\include/QtCore/qstring.h:1,
                 from ..\..\..\Qt\4.8.1\include/QtCore/../../src/corelib/kernel/qobject.h:48,
                 from ..\..\..\Qt\4.8.1\include/QtCore/qobject.h:1,
                 from ..\..\..\Qt\4.8.1\include/QtGui/../../src/gui/kernel/qwidget.h:46,
                 from ..\..\..\Qt\4.8.1\include/QtGui/qwidget.h:1,
                 from ..\..\..\Qt\4.8.1\include\QtGui/../../src/gui/widgets/qmainwindow.h:45,
                 from ..\..\..\Qt\4.8.1\include\QtGui/qmainwindow.h:1,
                 from ..\..\..\Qt\4.8.1\include\QtGui/QMainWindow:1,
                 from ..\PhotoChop\/mainwindow.h:4,
                 from ..\PhotoChop\mainwindow.cpp:1:
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/ext/new_allocator.h: In instantiation of '__gnu_cxx::new_allocator<const PCOperator::OperatorInfo* const>':
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/allocator.h:92:11:   instantiated from 'std::allocator<const PCOperator::OperatorInfo* const>'
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/stl_vector.h:73:60:   instantiated from 'std::_Vector_base<const PCOperator::OperatorInfo* const, std::allocator<const PCOperator::OperatorInfo* const> >'
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/stl_vector.h:180:11:   instantiated from 'std::vector<const PCOperator::OperatorInfo* const>'
..\PhotoChop\mainwindow.cpp:55:35:   instantiated from here
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/ext/new_allocator.h:82:7: error: 'const _Tp* __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::const_reference) const [with _Tp = const PCOperator::OperatorInfo* const, __gnu_cxx::new_allocator<_Tp>::const_pointer = const PCOperator::OperatorInfo* const*, __gnu_cxx::new_allocator<_Tp>::const_reference = const PCOperator::OperatorInfo* const&]' cannot be overloaded
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/ext/new_allocator.h:79:7: error: with '_Tp* __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::reference) const [with _Tp = const PCOperator::OperatorInfo* const, __gnu_cxx::new_allocator<_Tp>::pointer = const PCOperator::OperatorInfo* const*, __gnu_cxx::new_allocator<_Tp>::reference = const PCOperator::OperatorInfo* const&]'
mingw32-make.exe[1]: Leaving directory `C:/PhotoChop-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Release'
mingw32-make.exe[1]: *** [release/mainwindow.o] Error 1
mingw32-make.exe: *** [release] Error 2
01:24:28: The process "C:\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building project PhotoChop (target: Desktop)
When executing build step 'Make'

Any ideas? 有任何想法吗?

Basically there's some issue with the mingw compiler vs the msvc one as far as 基本上,mingw编译器与msvc相比存在一些问题

std::vector<const PCOperator::OperatorInfo* const>

I re-configured qt with -platform win32-msvc2010 and nmake instead of mingw32-make and the thing compiles just fine now. 我用-platform win32-msvc2010和nmake而不是mingw32-make重新配置了qt,现在编译就可以了。

我在配置参数中看不到“ -static”选项吗?

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

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