QT 未定义对第 3 方库的引用

QT has undefined reference to 3rd party library

目前我正在学习使用一个名为 'triceps' 的库。我在 linux 平台上使用 qt-creator,编译器是 clang。

错误信息是

/home/developer/Projects/trytriceps/main.cpp:11: error: undefined reference to `Triceps::Unit::Unit(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'

我的.pro文件是这样的。

QT       += core

QT       -= gui

TARGET = trytriceps
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

LIBS += -stdlib=libc++
INCLUDEPATH += /home/developer/Projects/triceps-2.0.1/cpp
# This path contains libtriceps.a and libtriceps.so.
LIBS += -L/home/developer/Projects/triceps-2.0.1/cpp/build
LIBS += -ltriceps

QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11

我的 main.cpp 文件是

#include <iostream>
#include <utest/Utest.h>
#include <sched/Unit.h>
using namespace std;

int main()
{
    cout << "hello world" << endl;

    Autoref<Unit> hwunit = new Unit("my unit");

    cout << hwunit->getName() << endl;

    return 0;
}

我试过用这种方式 link 到 boost_regex 库并且它有效。谁能帮我?谢谢

原来是构建问题(即使make test仍然失败),我不再有未定义的错误了。您的项目文件也在工作。

如果问题仍然存在,这里是我构建的共享和静态库:

libtriceps.zip(包含所有cpp目录) https://mega.co.nz/#!wENQUQoK!LIbeVH8gB94oS-zBrIlGHQ0iAICiRW6dOx620AInh0o

如果问题仍然存在,请确保您已彻底清理干净,并使用 qmake 重新生成一个新的 Makefile