![](/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.