【发布时间】:2014-04-07 14:28:39
【问题描述】:
我一直在尝试在 QT 5.2 中运行 assimp 以导入一些 3D 对象,但我(我相信)链接器有问题。
我是通过cmake安装的,先从http://sourceforge.net/projects/assimp/files/assimp-3.0/这里下载源文件,然后用cmake编译安装。
然后,我尝试运行他们在文档中提供的示例
#include <assimp/cimport.h> // Plain-C interface
#include <assimp/scene.h> // Output data structure
#include <assimp/postprocess.h> // Post processing flags
bool DoTheImportThing( const char* pFile)
{
// Start the import on the given file with some example postprocessing
// Usually - if speed is not the most important aspect for you - you'll t
// probably to request more postprocessing than we do in this example.
const aiScene* scene = aiImportFile( pFile,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
// If the import failed, report it
if( !scene)
{
// DoTheErrorLogging( aiGetErrorString());
return false;
}
return true;
}
但是当试图编译这段代码时,我得到了错误
error: undefined reference to `aiImportFile'
error: collect2: error: ld returned 1 exit status
我使用的是 32 位 linux mint。有谁知道为什么它没有链接?我应该使用特定标志使用 cmake 编译吗?我无法在周围的任何帖子中找到任何特殊标志。
谢谢!
【问题讨论】:
-
您似乎没有与图书馆链接。
-
约阿希姆,我也是这么想的。 gumlym,您能否发布您项目的 CMakeLists.txt,或者如果您正在使用 qmake 编译,请发布 qmake 文件?
-
嗨!是的,我也认为我没有与图书馆链接,我只是不知道如何解决这个问题。我刚刚编辑了我的问题并添加了 CMakeLists.txt
-
库的
CMakeLists.txt没有帮助。我们需要知道的是你如何构建你的项目。