Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > С/С++: Кроссплатформенное программирование, Qt/Gtk+/wxWidgets > Проблемы со статической сборкой проекта


Автор: RobinHoodPHD 17.7.2010, 14:21
Доброго времени суток, уважаемые форумчане!

Хочу статически собрать проект, чтобы не таскать за прогой dll-ки. Использую Qt Creator 2.0 и Qt 4.6.3.

Чтобы настроить Qt ввожу в консоли команду:
configure.exe -static -release -no-qt3support -no-exceptions -platform win32-g++

Все как описано в мане, однако configure мне выдает в конце:

...много текста...
Creating qmake...
execute: File or path is not found (mingw32-make)
execute: File or path is not found (mingw32-make)
Cleaning qmake failed, return code -1


Вот наш полный диалог с утилитой configure:
Код

c:\Qt\2010.04\qt>configure.exe -static -release -no-qt3support -no-exceptions -p
latform win32-g++
Which edition of Qt do you want to use ?
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.
o

This is the Qt for Windows Open Source Edition.

You are licensed to use this software under the terms of
the GNU Lesser General Public License (LGPL) version 2.1
or the GNU General Public License (GPL) version 3.

Type '3' to view the GNU General Public License version 3 (GPLv3).
Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1).
Type 'y' to accept this license offer.
Type 'n' to decline this license offer.

Do you accept the terms of the license?
yes
All the required DirectShow/Direct3D files couldn't be found.
Make sure you have either the platform SDK AND the DirectShow SDK or the Windows
 SDK installed.
If you have the DirectShow SDK installed, please make sure that you have run the
 <path to SDK>\SetEnv.Cmd script.
vmr9.h not found
dshow.h not found
strmiids.lib not found
dmoguids.lib not found
msdmo.lib not found
d3d9.h not found
Environment:
    INCLUDE=
      Unset
    LIB=
      Unset
    PATH=
      C:\Windows\system32
      C:\Windows
      C:\Windows\System32\Wbem
      C:\Windows\System32\WindowsPowerShell\v1.0\
      C:\Program Files\Microsoft SQL Server\90\Tools\binn\
      C:\Program Files\Common Files\Autodesk Shared\
You are licensed to use this software under the terms of the GNU GPL version 3.Y
ou are licensed to use this software under the terms of the Lesser GNU LGPL vers
ion 2.1.
See C:/Qt/2010.04/qt3

 or C:/Qt/2010.04/qtL

Configuration:
    minimal-config
    small-config
    medium-config
    large-config
    full-config
    release
Qt Configuration:
    release
    zlib
    gif
    png
    accessibility
    opengl
    s60
    ipv6
    script
    scripttools
    multimedia
    audio-backend
    webkit
    native-gestures
    svg
    minimal-config
    small-config
    medium-config
    large-config
    full-config

QMAKESPEC...................win32-g++ (commandline)
Architecture................windows
Maketool....................mingw32-make
Debug symbols...............no
Link Time Code Generation...no
Accessibility support.......yes
STL support.................yes
Exception support...........no
RTTI support................yes
MMX support.................no
3DNOW support...............no
SSE support.................no
SSE2 support................no
IWMMXT support..............no
OpenGL support..............yes
OpenVG support..............no
OpenSSL support.............no
QtDBus support..............no
QtXmlPatterns support.......no
Phonon support..............no
QtMultimedia support........yes
WebKit support..............yes
Declarative support.........no
QtScript support............yes
QtScriptTools support.......yes
Graphics System.............raster
Qt3 compatibility...........no

Third Party Libraries:
    ZLIB support............qt
    GIF support.............yes
    TIFF support............plugin
    JPEG support............plugin
    PNG support.............qt
    MNG support.............plugin
    FreeType support........no

Styles:
    Windows.................yes
    Windows XP..............no
    Windows Vista...........no
    Plastique...............yes
    Cleanlooks..............yes
    Motif...................yes
    CDE.....................yes
    Windows CE..............no
    Windows Mobile..........no
    S60.....................no

Sql Drivers:
    ODBC....................no
    MySQL...................no
    OCI.....................no
    PostgreSQL..............no
    TDS.....................no
    DB2.....................no
    SQLite..................plugin (qt)
    SQLite2.................no
    InterBase...............no

Sources are in..............C:\Qt\2010.04\qt
Build is done in............C:\Qt\2010.04\qt
Install prefix..............C:\Qt\2010.04\qt
Headers installed to........C:/Qt/2010.04/qt/include
Libraries installed to......C:/Qt/2010.04/qt/lib
Plugins installed to........C:/Qt/2010.04/qt/plugins
Binaries installed to.......C:/Qt/2010.04/qt/bin
Docs installed to...........C:/Qt/2010.04/qt/doc
Data installed to...........C:/Qt/2010.04/qt
Translations installed to...C:/Qt/2010.04/qt/translations
Examples installed to.......C:/Qt/2010.04/qt/examples
Demos installed to..........C:/Qt/2010.04/qt/demos

WARNING: Using static linking will disable the use of plugins.
         Make sure you compile ALL needed modules into the library.
Creating qmake...
execute: File or path is not found (mingw32-make)
execute: File or path is not found (mingw32-make)
Cleaning qmake failed, return code -1


Как бы мне от этого избавиться? 
Может нужно добавить какие-то  переменные среды?
 В данный момент для Qt я добавил:
 QTDIR , MINGWDIR , MAKESPEC и в Path добавил ;%QTDIR%\bin;%MINGWDIR%\bin;

Автор: djamshud 19.7.2010, 11:19
>в Path добавил ;%QTDIR%\bin;%MINGWDIR%\bin;

Судя по логу в PATH-е нет пути до mingw, и, как я понимаю, именно его конфигуратору и не удается найти. Добавьте его явным образом C:\bin\mingw\ или где там он у вас установлен.

ЗЫ. Если за последнее время ничего не изменилось, бесплатную версию Qt запрещается линковать статически со своим софтом.

Автор: bsa 19.7.2010, 20:21
Цитата(djamshud @  19.7.2010,  12:19 Найти цитируемый пост)
ЗЫ. Если за последнее время ничего не изменилось, бесплатную версию Qt запрещается линковать статически со своим софтом. 

Нет, не запрещается. Только если софт тоже будет распространяться под LGPL или GPL.

RobinHoodPHD, возможно, ты mingw32-make не установил, так как по умолчанию галка в инсталляторе с него снята.

Автор: RobinHoodPHD 19.7.2010, 21:01
djamshudbsa, спасибо, вроде собралось.
Теперь проблема со сборкой проекта в самом Qt Creator'е:
Выдает две загадочные ошибки: (скриншот окна прикреплен) 

:: error: cannot find -lQtGuid
:: error: collect2: ld returned 1 exit status


Сначала думал что это из за того, что я плагины не подключил (т.к. в приложении использовал jpeg и ico изображения). Но не собирается даже простейшее графическое приложение с пустой формой... 

Подскажите пожалуйста, чем вызвано сие непотребство?
 

Автор: RobinHoodPHD 19.7.2010, 21:21
Покурив интернет пришел к выводу, что может быть еще полезно дополнительно сообщить, что Qt я пересобирал с параметром -release и в файл .pro проекта добавил строку CONFIG += static (хотя эта строка никакого эффекта и не дала...)

Обе ошибки 
:: error: cannot find -lQtGuid
:: error: collect2: ld returned 1 exit status
выводятся в режиме сборки "Отладка"

При сборке "Релиз" только 
:: error: collect2: ld returned 1 exit status

В папке %QTDIR%/lib есть библиотеки: libQtGui.a, libQtGui4.a , libQtGuid4.a

Добавлено через 9 минут и 3 секунды
Кажется нашел ответ:

Если вдруг после перекомпиляции Qt вы при сборке проекта получаете примерно такую ошибку:
D:\Qt\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lQtGuid
collect2: ld returned 1 exit status
значит что-то не докомпилировалось. Ещё такое бывает, если при перекомпиляции Qt в configure установить ключ "-release", а компилировать проект в debug, или наоборот.


Бегу перекомпилировать....;)

Автор: RobinHoodPHD 20.7.2010, 19:01
Нашел проблему - утилита mingw32-make завершается с ошибкой:
Код

g++ -static -static-libgcc -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-en
able-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,windows -o ..\..\..\..\bin\assis
tant.exe object_script.assistant.Release  -L"c:\Qt\2010.04\qt\lib" -L"c:\Qt\2010
.04\qt\lib" -lmingw32 -lqtmain tmp\obj\release_static\assistant_res.o -LC:/Qt/20
10.04/qt/plugins/sqldrivers -lQtHelp -lqsqlite -lQtSql -lQtXml -lQtGui -lQtNetwo
rk -lQtCLucene -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg3
2 -lQtCore -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
c:\Qt\2010.04\qt\lib\libQtGui.a(qapplication.o):qapplication.cpp:(.text+0x34de):
 undefined reference to `_imp___Z21qt_call_post_routinesv'
c:\Qt\2010.04\qt\lib\libQtGui.a(qapplication.o):qapplication.cpp:(.text+0x3a83):
 undefined reference to `_imp___Z21qt_call_post_routinesv'
c:\Qt\2010.04\qt\lib\libQtGui.a(qapplication.o):qapplication.cpp:(.text+0x401e):
 undefined reference to `_imp___Z21qt_call_post_routinesv'
c:\Qt\2010.04\qt\lib\libQtGui.a(qwhatsthis.o):qwhatsthis.cpp:(.text+0xfc): undef
ined reference to `_imp___Z21qDeleteInEventHandlerP7QObject'
collect2: ld returned 1 exit status
mingw32-make[5]: *** [..\..\..\..\bin\assistant.exe] Error 1
mingw32-make[5]: Leaving directory `C:/Qt/2010.04/qt/tools/assistant/tools/assis
tant'
mingw32-make[4]: *** [release] Error 2
mingw32-make[4]: Leaving directory `C:/Qt/2010.04/qt/tools/assistant/tools/assis
tant'
mingw32-make[3]: *** [sub-assistant-make_default-ordered] Error 2
mingw32-make[3]: Leaving directory `C:/Qt/2010.04/qt/tools/assistant/tools'
mingw32-make[2]: *** [sub-tools-make_default-ordered] Error 2
mingw32-make[2]: Leaving directory `C:/Qt/2010.04/qt/tools/assistant'
mingw32-make[1]: *** [sub-assistant-make_default-ordered] Error 2
mingw32-make[1]: Leaving directory `C:/Qt/2010.04/qt/tools'
mingw32-make: *** [sub-tools-make_default-ordered] Error 2

Может быть есть идеи насчет того, как это исправить?

Автор: bsa 20.7.2010, 21:36
RobinHoodPHD, если ты Qt собрал с опцией -release, то и в настройках компилируемого проекта должен ставить release. По умолчанию стоит debug, вот и ругается. Думаю, нет никакого смысла делать статичную дебаговую версию - линкуется долго очень, да и объемы невпупительные. Поэтому, дебаговый профиль настрой на динамическую Qt, а релизный на статическую.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)