I encountered an error when I am trying to link the Fbx static library (libfbxsdk.a) to a project on Linux using CMake that keeps reporting for undefined references to fbx-related functions. I checked the configuration in the CMakelist and everything looks alright, but the program cannot be compiled statically or dynamically. I really don't have any idea why the static library is not linked properly and appreciate any helps to fix the linking issue. Here is my cmakelist file for static linking:
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)
and my cpp file is as below:
#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);
}
}