Qt / mingw32未定义的引用错误...无法链接.lib [英] Qt/mingw32 undefined reference errors... unable to link a .lib

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

问题描述

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



我有一堆窗口(VS2005)静态库文件c> .lib )。我测试如果他们与Qt很好。所以我采取了我最简单的图书馆。 (调用 MessageBuffer )。



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



直到那时,一切看起来都很好,我可以使用类和Qt IDE显示所有方法和一切。



现在我添加了 MessageBuffer.lib (VS2005 / Debug build)在 .pro 中如下:

  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

 为项目运行构建步骤SilverEye ... 
配置不变,跳过QMake步骤。
开始:C:/Qt/2009.03/mingw/bin/mingw32-make.exe -w
mingw32-make:输入目录`C:/ Documents and Settings / JP / My Documents / QTProjects / SilverEye '
C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make [1]:输入目录`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 -Lc:\Qt\2009.03\qt\lib-lopengl32 -lglu32 -lgdi32 -luser32 -lmingw32 -lqtmaind E :/SharedLibrary/lib/MessageBufferd.lib -lQtOpenGLd4 -lQtGuid4 -lQtCored4
mingw32-make [1]:离开目录`C:/ Documents and Settings / JP / My Documents / QTProjects / SilverEye'
mingw32 -make:离开目录`C:/ Documents and Settings / JP / My Documents / QTProjects / SilverEye'
debug / main.o:在函数`Z5qMainiPPc':
C:/ Documents and Settings / JP / My Documents / QTProjects / SilverEye / main.cpp:12:未定义引用`MessageBuffer :: MessageBuffer()'
C:/ Documents and Settings / JP / My Documents / QTProjects / SilverEye / main.cpp:13 :未定义引用`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返回1退出状态
mingw32-make [1]:*** [debug\SilverEye.exe]错误1
mingw32-make:*** [debug]错误2
退出与代码2.
构建项目时出错SilverEye
执行生成步骤'Make'

解决方案

根据问题使用由visual studio编译的库在由g ++(mingw)编译的应用程序中和MSDN论坛帖子我不能混合VC& GCC 它没有出现你可以链接一个gcc应用程序与可视化c ++编译库。



解决方案将重新编译一切与同一编译器。 p>

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

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).

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

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.

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

LIBS += E:/SharedLibrary/lib/MessageBufferd.lib

I have also tried the following:

win32:LIBS += E:/SharedLibrary/lib/MessageBufferd.lib
LIBS += -LE:/SharedLibrary/lib -lMessageBufferd
win32:LIBS += -LE:/SharedLibrary/lib -lMessageBufferd

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

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 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'

Can anyone help please?

解决方案

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未定义的引用错误...无法链接.lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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