![](/img/trans.png)
[英]Mingw32 Boost Log Link Errors: InterlockedCompareExchange
[英]Qt/mingw32 undefined reference errors… unable to link a .lib
我是Qt的新手,有一個我無法解決的錯誤。
我有一堆windows(VS2005)靜態庫文件( .lib
)。 我正在測試它們是否與Qt配合良好。 所以我選擇了最簡單的庫。 (稱為MessageBuffer
)。
所以我將MessageBuffer.h
添加到main.cpp
,並在.pro
的INCLUDEPATH
中添加了這些文件的位置。
在那之前一切都很好,我可以使用類和Qt IDE顯示所有方法和一切。 所以對我來說,它看起來像是找到了.h文件。
現在我在.pro
添加了MessageBuffer.lib
(VS2005 / Debug build),如下所示:
LIBS += E:/SharedLibrary/lib/MessageBufferd.lib
我也嘗試過以下方法:
win32:LIBS += E:/SharedLibrary/lib/MessageBufferd.lib
LIBS += -LE:/SharedLibrary/lib -lMessageBufferd
win32:LIBS += -LE:/SharedLibrary/lib -lMessageBufferd
這是我的.pro
文件的內容:
QT += opengl
TARGET = SilverEye
TEMPLATE = app
INCLUDEPATH += E:/SharedLibrary/MessageBuffer
SOURCES += main.cpp \
silvereye.cpp
HEADERS += silvereye.h
FORMS += silvereye.ui
OTHER_FILES +=
win32:LIBS += E:/SharedLibrary/lib/MessageBufferd.lib
他們都給了我同樣的錯誤:(即使我不包含.lib
,我也會得到相同的錯誤)
Running build steps for project SilverEye...
Configuration unchanged, skipping QMake step.
Starting: C:/Qt/2009.03/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\SilverEye.exe debug/main.o debug/silvereye.o debug/moc_silvereye.o -L"c:\Qt\2009.03\qt\lib" -lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind E:/SharedLibrary/lib/MessageBufferd.lib -lQtOpenGLd4 -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
mingw32-make: Leaving directory `C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye'
debug/main.o: In function `Z5qMainiPPc':
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:12: undefined reference to `MessageBuffer::MessageBuffer()'
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:13: undefined reference to `MessageBuffer::Append(char*, int)'
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:17: undefined reference to `MessageBuffer::~MessageBuffer()'
C:/Documents and Settings/JP/My Documents/QTProjects/SilverEye/main.cpp:17: undefined reference to `MessageBuffer::~MessageBuffer()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\SilverEye.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project SilverEye
When executing build step 'Make'
有人可以幫忙嗎?
基於在g ++(mingw)和MSDN論壇帖子編譯的應用程序中使用可視化工作室編譯的庫, 我不能混合VC和GCC ,看起來你不能將gcc應用程序與visual c ++編譯庫鏈接。
解決方案是使用相同的編譯器重新編譯所有內容。
MinGW FAQ討論了這個問題,並提供了一個解決方案:
那沒用。 我們最終從函數名中刪除了序數,這導致它編譯。 但程序無法運行,因為它無法在DLL中找到鏈接的函數。 最后,在查閱定義文件的MSDN文檔后,我們更改了構建說明:
有效! 要編譯項目,您必須簡單地:
摘自: http : //blog.outofhanwell.com/2006/05/01/linking-msvc-libraries-with-mingw-projects/
我假設你在另一個有問題的應用程序中使用了MessageBuffer庫。 該錯誤看起來無法找到庫或未導出MessageBuffer類。
您是否嘗試在專業文件中將-l放在庫的前面?
win32:LIBS += -lE:/SharedLibrary/lib/MessageBufferd.lib
看到我的其他答案 。 我添加了另一個答案,因為我不想讓這個答案比現在更混亂。
到目前為止嘗試過:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.