Qt/mingw32 undefined reference errors...无法链接.lib [英] Qt/mingw32 undefined reference errors... unable to link a .lib

查看:25
本文介绍了Qt/mingw32 undefined reference errors...无法链接.lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Qt 新手,遇到一个无法修复的错误.

I am new to Qt and have one error I am unable to fix.

我有一堆 windows (VS2005) 静态库文件 (.lib).我正在测试它们是否可以很好地与 Qt 配合使用.所以我选择了我拥有的最简单的库.(称为MessageBuffer).

I have a bunch of windows (VS2005) static library file (.lib). And I am testing if they work well with Qt. So I took the most simple library that I have. (Called MessageBuffer).

所以我将MessageBuffer.h添加到main.cpp中,并将这些文件的位置添加到INCLUDEPATH中>.pro.

So I added MessageBuffer.h to the main.cpp, and added the location of those file in the INCLUDEPATH of the .pro.

在那之前一切看起来都很好,我可以使用类和 Qt IDE 显示所有方法和所有内容.所以对我来说,它看起来像是找到了 .h 文件.

Until then everything seem fine, I can use the class and Qt IDE show all method and everything. So to me it look like it found the .h file.

现在我在 .pro 中添加了 MessageBuffer.lib(VS2005/Debug 构建),如下所示:

Now I added the MessageBuffer.lib (VS2005/Debug build) in the .pro like this:

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 文件的内容:

Here is the content of my .pro file:

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,我也会得到同样的错误)

They all give me the same errors: (and I get the same even if I don't include the .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 debugSilverEye.exe debug/main.o debug/silvereye.o debug/moc_silvereye.o -L"c:Qt2009.03qtlib" -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]: *** [debugSilverEye.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project SilverEye
When executing build step 'Make'

有人可以帮忙吗?

推荐答案

基于问题在由 g++ (mingw) 编译的应用程序中使用 Visual Studio 编译的库 和 MSDN 论坛帖子 我不能混合 VC &GCC 看来您不能将 gcc 应用程序与可视 c++ 编译库链接.

Based on the question Use libraries compiled with visual studio in an application compiled by g++ (mingw) and the MSDN forum post I can't mix VC & GCC it does not appear you can link a gcc application with visual c++ compiled libraries.

解决方案是使用相同的编译器重新编译所有内容.

The solution would be to recompile everything with the same compiler.

这篇关于Qt/mingw32 undefined reference errors...无法链接.lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆