在CMake上链接FBX SDK的错误

时间:2017-01-02 22:37:36

标签: linux makefile cmake fbx

当我尝试使用CMake将Fbx静态库(libfbxsdk.a)链接到Linux上的项目时,我遇到了一个错误,该CMake继续报告对fbx相关函数的未定义引用。我检查了CMakelist中的配置,一切看起来都不错,但程序无法静态或动态编译。我真的不知道为什么静态库没有正确链接,并感谢任何帮助来解决链接问题。这是我的静态链接的cmakelist文件:

cmake_minimum_required(VERSION 3.6)
SET(CMAKE_VERBOSE_MAKEFILE ON)
project(FBX_SDK)

add_definitions(-DFBXSDK_NEW_API)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lm -lrt -luuid -lstdc++ -lpthread -ldl -lX11 -std=c++11")

include_directories(${X11_LIBRARIES}
        ${FBX_SDK_SOURCE_DIR}/fbxsdk-1.2/include/)

link_directories(${X11_LIBRARIES}
        ${FBX_SDK_SOURCE_DIR}/fbxsdk-1.2/Lib/Linux/Debug_x64/)

set(SOURCE_FILES main.cpp)    
add_executable(FBX_SDK ${SOURCE_FILES})

target_link_libraries(FBX_SDK
        ${FBX_SDK_SOURCE_DIR}/fbxsdk-1.2/Lib/Linux/Debug_x64/libfbxsdk.a)

我的cpp文件如下:

#include <iostream>
#include <fbxsdk.h>

void InitializeSDKObjects(FbxManager* &pManager, FbxScene* &pScene);

int main() 
{
std::cout << "Hello, World!" << std::endl;

FbxManager* lSdkManager = NULL;
FbxScene* lScene = NULL;
bool lResult;

InitializeSDKObjects(lSdkManager, lScene);


return 0;
}

void InitializeSDKObjects(FbxManager* &pManager, FbxScene* &pScene)
{
pManager = FbxManager::Create();
if(!pManager)
{
    FBXSDK_printf("Error: Unable to create FBX Manager!\n");
    exit(1);
}

else FBXSDK_printf("Autodesk FBX SDK version %s\n", pManager->GetVersion());

FbxIOSettings* ios = FbxIOSettings::Create(pManager, IOSROOT);
pManager->SetIOSettings(ios);

FbxString lPath = FbxGetApplicationDirectory();
pManager->LoadPluginsDirectory(lPath.Buffer());

pScene = FbxScene::Create(pManager, "My Scene");
if(!pScene)
{
    FBXSDK_printf("Error: Unable to create FBX scene!\n");
    exit(1);
}

}

虽然fbx sdk的include和lib文件夹是这样的: enter image description here

enter image description here

0 个答案:

没有答案