Undefined reference to: __imp_nuitrack_GetErrorType

Hello there,

Newly set up a development env: VS Code + NuiTrack SDK + OpenCV 4.5.5 + Mingw64, and got many undefined reference errors, could anyone please shed some light on how to resolve it?

Thanks

Yuan

[main] Building folder: Hand 
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/realsense/NuiTrackSDKSample-master/sample/Hand/build --config Debug --target all -j 10 --
[build] [ 33%] Building CXX object CMakeFiles/Hand.dir/nuitrack.cpp.obj
[build] [ 66%] Building CXX object CMakeFiles/Hand.dir/main.cpp.obj
[build] [100%] Linking CXX executable Hand.exe
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::ExceptionTranslator::handle(tdv::nuitrack::nuitrack_error*)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/utils/ExceptionTranslator.h:76: undefined reference to `__imp_nuitrack_GetErrorType'
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/utils/ExceptionTranslator.h:78: undefined reference to `__imp_nuitrack_GetErrorMessage'
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/utils/ExceptionTranslator.h:81: undefined reference to `__imp_nuitrack_DestroyError'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::RGBFrame::RGBFrame(ColorSensorData*)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/RGBFrame.h:23: undefined reference to `__imp_nuitrack_AddColorSensorDataRef'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::RGBFrame::~RGBFrame()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/RGBFrame.h:28: undefined reference to `__imp_nuitrack_DestroyColorSensorData'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::RGBFrame::getRows() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/RGBFrame.h:36: undefined reference to `__imp_nuitrack_GetColorFrameRows'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::RGBFrame::getCols() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/RGBFrame.h:44: undefined reference to `__imp_nuitrack_GetColorFrameCols'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::RGBFrame::getID() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/RGBFrame.h:52: undefined reference to `__imp_nuitrack_GetColorFrameID'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::RGBFrame::getData() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/RGBFrame.h:60: undefined reference to `__imp_nuitrack_GetColorFrameData'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::RGBFrame::getTimestamp() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/RGBFrame.h:69: undefined reference to `__imp_nuitrack_GetColorFrameTimestamp'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::ColorSensor::create()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/ColorSensor.h:61: undefined reference to `__imp_nuitrack_CreateColorSensor'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::ColorSensor::ColorSensor(NuitrackModule*)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/ColorSensor.h:74: undefined reference to `__imp_nuitrack_registerColorSensorCallback'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::ColorSensor::~ColorSensor()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/ColorSensor.h:79: undefined reference to `__imp_nuitrack_DestroyColorSensor'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::ColorSensor::getColorFrame()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/ColorSensor.h:122: undefined reference to `__imp_nuitrack_GetColorSensorData'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::ColorSensor::canUpdate() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/ColorSensor.h:129: undefined reference to `__imp_nuitrack_GetNuitrackModuleCanUpdate'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::ColorSensor::getTimestamp()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/ColorSensor.h:140: undefined reference to `__imp_nuitrack_GetNuitrackModuleTimestamp'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTrackerData::HandTrackerData(HandTrackerDataInner*)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/HandTrackerData.h:24: undefined reference to `__imp_nuitrack_AddHandTrackerDataRef'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTrackerData::~HandTrackerData()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/HandTrackerData.h:29: undefined reference to `__imp_nuitrack_DestroyHandTrackerData'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTrackerData::getTimestamp() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/HandTrackerData.h:41: undefined reference to `__imp_nuitrack_GetHandTrackerDataTimestamp'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTrackerData::getUsersHands() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/HandTrackerData.h:61: undefined reference to `__imp_nuitrack_HandTrackerGetNumUsers'
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/types/HandTrackerData.h:70: undefined reference to `__imp_nuitrack_HandTrackerGetUserHands'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTracker::create()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/HandTracker.h:60: undefined reference to `__imp_nuitrack_CreateHandTracker'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTracker::~HandTracker()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/HandTracker.h:68: undefined reference to `__imp_nuitrack_DestroyHandTracker'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTracker::HandTracker(NuitrackModule*)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/HandTracker.h:79: undefined reference to `__imp_nuitrack_registerHandTrackerCallback'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTracker::getData()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/HandTracker.h:111: undefined reference to `__imp_nuitrack_ReceiveInnerHandTrackerData'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTracker::canUpdate() const':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/HandTracker.h:126: undefined reference to `__imp_nuitrack_GetNuitrackModuleCanUpdate'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::HandTracker::getTimestamp()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/modules/HandTracker.h:137: undefined reference to `__imp_nuitrack_GetNuitrackModuleTimestamp'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::Nuitrack::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:63: undefined reference to `__imp_nuitrack_InitializeFromConfig_E'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::Nuitrack::run()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:77: undefined reference to `__imp_nuitrack_Run'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::Nuitrack::update()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:91: undefined reference to `__imp_nuitrack_Update'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::Nuitrack::waitUpdate(std::shared_ptr<tdv::nuitrack::HeaderOnlyAPI_Module>)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:124: undefined reference to `__imp_nuitrack_WaitSyncUpdatePublic'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::Nuitrack::release()':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:136: undefined reference to `__imp_nuitrack_getIssuesCallbackStruct'
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:139: undefined reference to `__imp_nuitrack_setIssuesCallbackStruct'
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:142: undefined reference to `__imp_nuitrack_Release'
[build] CMakeFiles\Hand.dir/objects.a(nuitrack.cpp.obj): In function `tdv::nuitrack::Nuitrack::setConfigValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
[build] C:/realsense/github/nuitracksdk/Nuitrack/include/nuitrack/Nuitrack.h:154: undefined reference to `__imp_nuitrack_SetConfigValue'
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make.exe[2]: *** [CMakeFiles\Hand.dir\build.make:133: Hand.exe] Error 1
[build] mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/Hand.dir/all] Error 2
[build] mingw32-make.exe: *** [Makefile:90: all] Error 2
[build] Build finished with exit code 2

CMakeList.txt

cmake_minimum_required( VERSION 3.6 )

# Require C++11 (or later)
set( CMAKE_CXX_STANDARD 11 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )

# Create Project
project( NuiTrack )
add_executable( Hand nuitrack.h nuitrack.cpp main.cpp )

# Set StartUp Project
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "Hand" )

# Find Package
# NuiTrack
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_MODULE_PATH} )
set( NuiTrack_DIR "C:/realsense/github/nuitracksdk/Nuitrack" CACHE PATH "Path to NuiTrack directory." )
find_package( NuiTrack REQUIRED )

# OpenCV
set( OpenCV_DIR "${OpenCV_DIR}" CACHE PATH "Path to OpenCV config directory." )
find_package(OpenCV REQUIRED )

# OpenMP
find_package( OpenMP )

if( NuiTrack_FOUND AND OpenCV_FOUND )
  # Additional Include Directories
  include_directories( ${NuiTrack_INCLUDE_DIR} )
  include_directories( ${Nuitrack_MIDDLEWARE} )
  include_directories( ${OpenCV_INCLUDE_DIRS} )

  # Additional Dependencies
  target_link_libraries( Hand ${NuiTrack_LIBRARIES} )
  target_link_libraries( Hand ${OpenCV_LIBS} )
endif()

if( OpenMP_FOUND )
  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
endif()

Envarialbes
env

Hi @ou.yuan

In your CMakeLists change

set( NuiTrack_DIR "C:/realsense/github/nuitracksdk/Nuitrack" CACHE PATH "Path to NuiTrack directory.")
find_package( NuiTrack REQUIRED )

to

set(NUITRACK_INCLUDE_PATH C:/realsense/github/nuitracksdk/Nuitrack/include C:/realsense/github/nuitracksdk/Nuitrack/include/middleware)
set(NUITRACK_LIBRARY_PATH C:/realsense/github/nuitracksdk/Nuitrack/lib/win64)

and

include_directories( ${NuiTrack_INCLUDE_DIR} )
include_directories( ${Nuitrack_MIDDLEWARE} )
target_link_libraries( Hand ${NuiTrack_LIBRARIES} )

to

include_directories(${NUITRACK_INCLUDE_PATH})
link_directories(${NUITRACK_LIBRARY_PATH})
target_link_libraries(Hand nuitrack)

Basically you should copy this CMakeLists with no changes regarding Nuitrack linkage

Hi @ou.yuan

Did you manage to link your code with Nuitrack? Do you have any other questions I can help you with?