簡體   English   中英

Qt - 靜態編譯的 exe 引用共享庫

[英]Qt - statically compiled exe refers shared lib

我在 Qt 中的 static 編譯到本周都運行良好。 我重新安裝了qt,重新編譯了static版本。 之后就開始頭疼了。 現在,即使我使用 tatic 版本編譯。 生成的 exe 需要 Qt 庫。 我用“dependency Walker”檢查了exe。 它表明所需的 dll 路徑指向動態/共享庫路徑。 這是我的設置

Environment:
QTDYNDIR : D:\tempinstallationfolder\Qt\dynamic
QTSTADIR : D:\tempinstallationfolder\Qt\static
Path : %QTDYNDIR%\bin;%QTDYNDIR%\qt\bin;%QTDYNDIR%\mingw\bin;
       %QTSTADIR%\bin;%QTSTADIR%\qt\bin;%QTSTADIR%\mingw\bin;

我添加了 mingw,qt 路徑,它以某種方式設法遵循動態庫的路徑。 我不知道我在哪里犯了錯誤。 有人可以在這個問題上幫助我嗎?

注意:我使用的是 Windows 平台 - qt - 4.7.0 (qt - open source v2010.05) of static,dynamic toOptions Q=>Qt.=>Tools=r

編輯:這個來自編譯 output。 這些中沒有提到動態路徑目錄。

Running build steps for project CalendarNew...
Starting: "D:/TempInstallationFolder/Qt/static/mingw/bin/mingw32-make.exe" clean -w
mingw32-make: Entering directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

D:/TempInstallationFolder/Qt/static/mingw/bin/mingw32-make -f Makefile.Release clean

mingw32-make[1]: Entering directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

del release\moc_CalendarWidget.cpp release\moc_DateSquareEditWidget.cpp release\moc_GeneralSettingsWidget.cpp release\moc_MyColorButton.cpp release\moc_MyLabel.cpp

del release\CalendarWidget.o release\DateSquare.o release\DateSquareEditWidget.o   release\GeneralSettingsWidget.o release\main.o release\MyColorButton.o release\MyLabel.o release\moc_CalendarWidget.o release\moc_DateSquareEditWidget.o release\moc_GeneralSettingsWidget.o release\moc_MyColorButton.o release\moc_MyLabel.o

mingw32-make[1]: Leaving directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

D:/TempInstallationFolder/Qt/static/mingw/bin/mingw32-make -f Makefile.Debug clean

mingw32-make[1]: Entering directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

del debug\moc_CalendarWidget.cpp debug\moc_DateSquareEditWidget.cpp debug\moc_GeneralSettingsWidget.cpp debug\moc_MyColorButton.cpp debug\moc_MyLabel.cpp

del debug\CalendarWidget.o debug\DateSquare.o debug\DateSquareEditWidget.o debug\GeneralSettingsWidget.o debug\main.o debug\MyColorButton.o debug\MyLabel.o debug\moc_CalendarWidget.o debug\moc_DateSquareEditWidget.o debug\moc_GeneralSettingsWidget.o debug\moc_MyColorButton.o debug\moc_MyLabel.o

mingw32-make[1]: Leaving directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

mingw32-make: Leaving directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

Could Not Find C:\Documents and Settings\prabhakaran\Desktop\CalendarNew-build-desktop\debug\moc_CalendarWidget.cpp

Could Not Find C:\Documents and Settings\prabhakaran\Desktop\CalendarNew-build-desktop\debug\CalendarWidget.o

The process "D:/TempInstallationFolder/Qt/static/mingw/bin/mingw32-make.exe" exited normally.
Configuration unchanged, skipping qmake step.

Starting: "D:/TempInstallationFolder/Qt/static/mingw/bin/mingw32-make.exe" -w

mingw32-make: Entering directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

D:/TempInstallationFolder/Qt/static/mingw/bin/mingw32-make -f Makefile.Release

mingw32-make[1]: Entering directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\CalendarWidget.o ..\CalendarNew\CalendarWidget.cpp

..\CalendarNew\CalendarWidget.cpp: In constructor 'CalendarWidget::CalendarWidget()':

..\CalendarNew\CalendarWidget.cpp:93: warning: 'default_String_Fontsize' may be used uninitialized in this function

..\CalendarNew\CalendarWidget.cpp:96: warning: 'lower_String_Fontsize' may be used uninitialized in this function

..\CalendarNew\CalendarWidget.cpp: In constructor 'CalendarWidget::CalendarWidget()':

..\CalendarNew\CalendarWidget.cpp:93: warning: 'default_String_Fontsize' may be used uninitialized in this function

..\CalendarNew\CalendarWidget.cpp:96: warning: 'lower_String_Fontsize' may be used uninitialized in this function

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\DateSquare.o ..\CalendarNew\DateSquare.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\DateSquareEditWidget.o ..\CalendarNew\DateSquareEditWidget.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\GeneralSettingsWidget.o ..\CalendarNew\GeneralSettingsWidget.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\main.o ..\CalendarNew\main.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\MyColorButton.o ..\CalendarNew\MyColorButton.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\MyLabel.o ..\CalendarNew\MyLabel.cpp

D:\TempInstallationFolder\Qt\static\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\CalendarNew\CalendarWidget.h -o release\moc_CalendarWidget.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\moc_CalendarWidget.o release\moc_CalendarWidget.cpp

D:\TempInstallationFolder\Qt\static\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\CalendarNew\DateSquareEditWidget.h -o release\moc_DateSquareEditWidget.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\moc_DateSquareEditWidget.o release\moc_DateSquareEditWidget.cpp

D:\TempInstallationFolder\Qt\static\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\CalendarNew\GeneralSettingsWidget.h -o release\moc_GeneralSettingsWidget.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\moc_GeneralSettingsWidget.o release\moc_GeneralSettingsWidget.cpp

D:\TempInstallationFolder\Qt\static\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\CalendarNew\MyColorButton.h -o release\moc_MyColorButton.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\moc_MyColorButton.o release\moc_MyColorButton.cpp

D:\TempInstallationFolder\Qt\static\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\CalendarNew\MyLabel.h -o release\moc_MyLabel.cpp

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\TempInstallationFolder\Qt\static\qt\include\QtCore" -I"d:\TempInstallationFolder\Qt\static\qt\include\QtGui" -I"d:\TempInstallationFolder\Qt\static\qt\include" -I"..\CalendarNew" -I"d:\TempInstallationFolder\Qt\static\qt\include\ActiveQt" -I"release" -I"." -I"d:\TempInstallationFolder\Qt\static\qt\mkspecs\win32-g++" -o release\moc_MyLabel.o release\moc_MyLabel.cpp

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o release\CalendarNew.exe object_script.CalendarNew.Release  -L"d:\TempInstallationFolder\Qt\static\qt\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4 

mingw32-make[1]: Leaving directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

mingw32-make: Leaving directory `C:/Documents and Settings/prabhakaran/Desktop/CalendarNew-build-desktop'

The process "D:/TempInstallationFolder/Qt/static/mingw/bin/mingw32-make.exe" exited normally.

注意:現在只有我為動態和 static 進行了全新安裝。 它仍然能夠產生相同的結果。

您是否已將此行添加到您的 projectname.pro 文件中?

CONFIG += static  

並確保在 QtCreator-Projects-Build 設置中“Qt-version”指向您的 static 構建?

我不確定這是正確的答案。 我做了以下更改。 我不確定哪一個糾正了我的問題。

1)似乎必須有一個名為QTDIR的環境變量指向動態安裝目錄。

2)我使用“visual studio”而不是“mingw”為 static 編譯了 qt 庫。

在這些步驟之后,我將 static 和動態 (qt-bin,lib,minwg-bin,lib) 的絕對路徑添加到路徑中。

現在,我的東西工作正常。 我沒有將其投票為正確答案。 因此有人可以給出准確的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM