QtCreator Boost错误:未定义引用`_imp__WSACleanup @ 0'

时间:2014-12-11 09:31:29

标签: qt boost

我正在使用boost 1.57.0和QT Creator 5.3和MinGW 32Bit编译器,我使用的是WIndows8.1。我试图将Boost Libraries链接到我的项目,因为它没有工作,我开始了一些Testprogramm,但我得到了同样的错误。我已经尝试了所有可以找到的教程,但是他们没有工作。

我使用MinGW将boost编译为boost_libraries文件夹。 所以这是我的.pro文件:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Test
TEMPLATE = app

DEFINES += BOOST_SYSTEM_NO_DEPRECATED
DEFINES += BOOST_ALL_DYN_LINK  # for using dynamic libraries

#here is the part with my boost libraries
DEPENDPATH += C:/boost_libraries/include/boost-1_57
INCLUDEPATH += C:/boost_libraries/include/boost-1_57
LIBS += -L "C:/boost_libraries/lib/" -lboost_thread-mgw48-mt-1_57

SOURCES += main.cpp\
    mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

所以我的测试类来了:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <boost/asio.hpp>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

这些是我试图在发布和调试模式下构建它的错误:

C:\Qt\Tools\QtCreator\bin\Test\main.cpp:-1: Fehler: undefined reference to `_imp__WSACleanup@0'
C:\Qt\Tools\QtCreator\bin\Test\main.cpp:-1: Fehler: undefined reference to `_imp__WSAStartup@8'
:-1: Fehler: release/main.o: bad reloc address 0x3f in section `.text$_ZN5boost4asio6detail17winsock_init_base7startupERNS2_4dataEhh[__ZN5boost4asio6detail17winsock_init_base7startupERNS2_4dataEhh]'
collect2.exe:-1: Fehler: error: ld returned 1 exit status

您好。现在我改变了我的代码,我的.pro文件现在看起来像这样:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Test
TEMPLATE = app

DEFINES += BOOST_SYSTEM_NO_DEPRECATED
DEFINES += BOOST_ALL_DYN_LINK  # for using dynamic libraries

DEPENDPATH += C:/boost_libraries/include/boost-1_57
INCLUDEPATH += C:/boost_libraries/include/boost-1_57

LIBS += -LC:/boost_libraries/lib/  \
           -lboost_thread-mgw48-mt-1_57 \
           -lboost_system-mgw48-mt-1_57 \
           -lboost_filesystem-mgw48-mt-1_57

LIBS += -lws2_32

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

现在我得到了这个错误:

C:\Qt\Tools\QtCreator\bin\Test\main.cpp:-1: Fehler: undefined reference to `_imp___ZN5boost6system15system_categoryEv'
C:\Qt\Tools\QtCreator\bin\Test\mainwindow.cpp:-1: Fehler: undefined reference to `_imp___ZN5boost6system15system_categoryEv'
moc_mainwindow.cpp:-1: Fehler: undefined reference to `_imp___ZN5boost6system15system_categoryEv'
collect2.exe:-1: Fehler: error: ld returned 1 exit status

我是否犯了连接lboost_system的错误?我也尝试了一个单独的库中的每个库。

0 个答案:

没有答案