gpt4 book ai didi

c++ - Qt/mingw32 undefined reference 错误...无法链接.lib

转载 作者:可可西里 更新时间:2023-11-01 15:20:48 28 4
gpt4 key购买 nike

我是 Qt 的新手,有一个错误我无法修复。

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

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

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

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

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'

有人可以帮忙吗?

最佳答案

基于问题Use libraries compiled with visual studio in an application compiled by g++ (mingw)和 MSDN 论坛帖子 I can't mix VC & GCC您似乎无法将 gcc 应用程序与 Visual C++ 编译库链接起来。

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

关于c++ - Qt/mingw32 undefined reference 错误...无法链接.lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1137323/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com