【发布时间】:2015-08-13 03:52:01
【问题描述】:
目前我正在学习使用一个名为“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;
}
我尝试以这种方式链接到 boost_regex 库,它可以工作。谁能帮我?谢谢。
【问题讨论】:
-
你可以试试快速 ldd libtriceps.so 看看是否缺少某些库链接?
-
@BertrandMartel 什么是“ldd libtriceps.so”?谢谢!
-
打开一个控制台,进入您的 libtriceps.so 目录并输入 ldd libtriceps.so(ldd 将打印此库的共享库)
-
@BertrandMartel 我试过这个命令。似乎所有的依赖都存在。
-
我下载了库并构建了它,但是由于未定义的引用使测试失败。您的 make 测试是否也失败了?