ami-iit / yarp-openvr-trackers

This repo contains an application to stream VIVE trackers pose in yarp using OpenVR
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

Linking error when installing the repo #7

Closed HosameldinMohamed closed 2 years ago

HosameldinMohamed commented 2 years ago

In my PC (running Windows) I am trying to install the software following the main README, but when I was installing yarp-openvr-trackers I am getting a linking error.

I even managed to do (following https://github.com/ami-iit/yarp-openvr-trackers#install-openvr):

NOTE: Since we are using the conda environment for installation, a common trick to avoid having to set new environment variables is just to install the CMake project directly in the environment, i.e. passing -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX on Linux/macOS or -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library on Windows.

Linking error ``` Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Checking Build System Building Custom Rule C:/Users/hmohamed/code/vr/yarp-openvr-trackers/src/CMakeLists.txt OpenVRTrackersDriver.cpp C:\Users\hmohamed\code\vr\yarp-openvr-trackers\src\OpenVRTrackersDriver.cpp(139,1): warning C4267: 'argument': conversi on from 'size_t' to 'vr::TrackedDeviceIndex_t', possible loss of data [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\b uild\src\openvr-trackers.vcxproj] C:\Users\hmohamed\code\vr\yarp-openvr-trackers\src\OpenVRTrackersDriver.cpp(189,8): warning C4267: 'argument': conversi on from 'size_t' to 'vr::TrackedDeviceIndex_t', possible loss of data [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\b uild\src\openvr-trackers.vcxproj] C:\Users\hmohamed\code\vr\yarp-openvr-trackers\src\OpenVRTrackersDriver.cpp(197,56): warning C4267: 'argument': convers ion from 'size_t' to 'const uint32_t', possible loss of data [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\ openvr-trackers.vcxproj] C:\Users\hmohamed\code\vr\yarp-openvr-trackers\src\OpenVRTrackersDriver.cpp(201,65): warning C4267: 'argument': convers ion from 'size_t' to 'vr::TrackedDeviceIndex_t', possible loss of data [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\ build\src\openvr-trackers.vcxproj] C:\Users\hmohamed\code\vr\yarp-openvr-trackers\src\OpenVRTrackersDriver.cpp(300,1): warning C4267: 'argument': conversi on from 'size_t' to 'vr::TrackedDeviceIndex_t', possible loss of data [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\b uild\src\openvr-trackers.vcxproj] C:\Users\hmohamed\code\vr\yarp-openvr-trackers\src\OpenVRTrackersDriver.cpp(314,14): warning C4267: 'argument': convers ion from 'size_t' to 'vr::TrackedDeviceIndex_t', possible loss of data [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\ build\src\openvr-trackers.vcxproj] openvr-trackers.vcxproj -> C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\lib\Release\openvr-trackers.lib Building Custom Rule C:/Users/hmohamed/code/vr/yarp-openvr-trackers/src/CMakeLists.txt run_driver.cpp openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_GetVRInitErrorAsEngl ishDescription referenced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@Devi cesManager@openvr@@QEAA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\run_driver.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_GetGenericInterface referenced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@DevicesManager@open vr@@QEAA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\run_driver.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_IsInterfaceVersionVa lid referenced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@DevicesManager@ openvr@@QEAA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\run_driver.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_GetInitToken referen ced in function "public: void __cdecl vr::COpenVRContext::CheckClear(void)" (?CheckClear@COpenVRContext@vr@@QEAAXXZ) [C :\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\run_driver.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_InitInternal2 refere nced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@DevicesManager@openvr@@QE AA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\run_driver.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_ShutdownInternal ref erenced in function "public: __cdecl openvr::DevicesManager::~DevicesManager(void)" (??1DevicesManager@openvr@@QEAA@XZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\run_driver.vcxproj] C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\bin\Release\run_driver.exe : fatal error LNK1120: 6 unresolved ext ernals [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\run_driver.vcxproj] Generating code from thrifts/OpenVRTrackersCommands.thrift Building Custom Rule C:/Users/hmohamed/code/vr/yarp-openvr-trackers/src/CMakeLists.txt OpenVRTrackersModule.cpp C:\Users\hmohamed\AppData\Local\mambaforge\envs\openvr\Library\include\yarp/sig/Vector.h(119,20): warning C4251: 'yarp: :sig::VectorOf::bytes': class 'std::vector>' needs to have dll-interface to be used by clie nts of class 'yarp::sig::VectorOf' [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-tracke rs.vcxproj] with [ T=double ] C:\Users\hmohamed\AppData\Local\mambaforge\envs\openvr\Library\include\yarp/sig/Vector.h(119): message : see declaratio n of 'std::vector>' [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers. vcxproj] with [ T=double ] C:\Users\hmohamed\AppData\Local\mambaforge\envs\openvr\Library\include\yarp/sig/Vector.h(502): message : see reference to class template instantiation 'yarp::sig::VectorOf' being compiled [C:\Users\hmohamed\code\vr\yarp-openvr-tra ckers\build\src\yarp-openvr-trackers.vcxproj] main.cpp C:\Users\hmohamed\AppData\Local\mambaforge\envs\openvr\Library\include\yarp/sig/Vector.h(119,20): warning C4251: 'yarp: :sig::VectorOf::bytes': class 'std::vector>' needs to have dll-interface to be used by clie nts of class 'yarp::sig::VectorOf' [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-tracke rs.vcxproj] with [ T=double ] C:\Users\hmohamed\AppData\Local\mambaforge\envs\openvr\Library\include\yarp/sig/Vector.h(119): message : see declaratio n of 'std::vector>' [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers. vcxproj] with [ T=double ] C:\Users\hmohamed\AppData\Local\mambaforge\envs\openvr\Library\include\yarp/sig/Vector.h(502): message : see reference to class template instantiation 'yarp::sig::VectorOf' being compiled [C:\Users\hmohamed\code\vr\yarp-openvr-tra ckers\build\src\yarp-openvr-trackers.vcxproj] OpenVRTrackersCommands.cpp Generating Code... openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_GetVRInitErrorAsEngl ishDescription referenced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@Devi cesManager@openvr@@QEAA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_GetGenericInterface referenced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@DevicesManager@open vr@@QEAA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_IsInterfaceVersionVa lid referenced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@DevicesManager@ openvr@@QEAA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_GetInitToken referen ced in function "public: void __cdecl vr::COpenVRContext::CheckClear(void)" (?CheckClear@COpenVRContext@vr@@QEAAXXZ) [C :\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_InitInternal2 refere nced in function "public: bool __cdecl openvr::DevicesManager::initialize(void)" (?initialize@DevicesManager@openvr@@QE AA_NXZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers.vcxproj] openvr-trackers.lib(OpenVRTrackersDriver.obj) : error LNK2019: unresolved external symbol __imp_VR_ShutdownInternal ref erenced in function "public: __cdecl openvr::DevicesManager::~DevicesManager(void)" (??1DevicesManager@openvr@@QEAA@XZ) [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers.vcxproj] C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\bin\Release\yarp-openvr-trackers.exe : fatal error LNK1120: 6 unre solved externals [C:\Users\hmohamed\code\vr\yarp-openvr-trackers\build\src\yarp-openvr-trackers.vcxproj] ```
HosameldinMohamed commented 2 years ago

CMake variables in Linux (compilation successful):

Screenshot_20220503_193650

CMake variables in Windows:

image

I don't see the variable pkgcfg_lib_openvr_dl in this case.

traversaro commented 2 years ago

Just to double check, are you sure you compiled https://github.com/ami-iit/openvr with BUILD_SHARED set to OFF as specified in https://github.com/ami-iit/yarp-openvr-trackers#install-openvr ? Are you sure that you are using the fix_upstream branch?

HosameldinMohamed commented 2 years ago

Just to double check, are you sure you compiled https://github.com/ami-iit/openvr with BUILD_SHARED set to OFF as specified in https://github.com/ami-iit/yarp-openvr-trackers#install-openvr ? Are you sure that you are using the fix_upstream branch?

@traversaro I doubled-checked. The branch is correct and the BUILD_SHARED is already OFF.

traversaro commented 2 years ago

@HosameldinMohamed did you solved the problem? If not, feel free to schedule a 0.5/1 hour to debug the problem with me.

traversaro commented 2 years ago

Just to double check, are you sure you compiled https://github.com/ami-iit/openvr with BUILD_SHARED set to OFF as specified in https://github.com/ami-iit/yarp-openvr-trackers#install-openvr ? Are you sure that you are using the fix_upstream branch?

@traversaro I doubled-checked. The branch is correct and the BUILD_SHARED is already OFF.

In https://github.com/robotology/robotology-superbuild/pull/1115#issuecomment-1124917869 I fixed the problem by setting BUILD_SHARED to ON. Perhaps the documentation in https://github.com/ami-iit/yarp-openvr-trackers/blame/5c63b85e22d80c18ea82da96151f6cf70fff0610/README.md#L53 should be fixed to specify that BUILD_SHARED should be set to ON ? fyi @prashanthr05

prashanthr05 commented 2 years ago

Just to double check, are you sure you compiled https://github.com/ami-iit/openvr with BUILD_SHARED set to OFF as specified in https://github.com/ami-iit/yarp-openvr-trackers#install-openvr ? Are you sure that you are using the fix_upstream branch?

@traversaro I doubled-checked. The branch is correct and the BUILD_SHARED is already OFF.

In robotology/robotology-superbuild#1115 (comment) I fixed the problem by setting BUILD_SHARED to ON. Perhaps the documentation in https://github.com/ami-iit/yarp-openvr-trackers/blame/5c63b85e22d80c18ea82da96151f6cf70fff0610/README.md#L53 should be fixed to specify that BUILD_SHARED should be set to ON ? fyi @prashanthr05

I believe @S-Dafarra also faced something similar while trying to setup on a new laptop.

HosameldinMohamed commented 2 years ago

Just to double check, are you sure you compiled https://github.com/ami-iit/openvr with BUILD_SHARED set to OFF as specified in https://github.com/ami-iit/yarp-openvr-trackers#install-openvr ? Are you sure that you are using the fix_upstream branch?

@traversaro I doubled-checked. The branch is correct and the BUILD_SHARED is already OFF.

In robotology/robotology-superbuild#1115 (comment) I fixed the problem by setting BUILD_SHARED to ON. Perhaps the documentation in https://github.com/ami-iit/yarp-openvr-trackers/blame/5c63b85e22d80c18ea82da96151f6cf70fff0610/README.md#L53 should be fixed to specify that BUILD_SHARED should be set to ON ? fyi @prashanthr05

@traversaro the problem is solved when setting BUILD_SHARED to ON on my PC too (Windows).

It's strange that in Linux it can be compiled with BUILD_SHARED set to OFF.

traversaro commented 2 years ago

@traversaro the problem is solved when setting BUILD_SHARED to ON on my PC too (Windows).

It's strange that in Linux it can be compiled with BUILD_SHARED set to OFF.

The main problem is that by default the visibility of symbol in libraries in Linux/macOS is public, while on Windows is private and symbols need to be exposed via "complex" techniques (see https://docs.microsoft.com/en-us/cpp/build/exporting-from-a-dll-using-declspec-dllexport?view=msvc-170). We tipically avoid this by using CMake's CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS, but if the library are not correctly implemented it is quite possible that you get linking problem either in the static or in the shared case on Windows.

HosameldinMohamed commented 2 years ago

I guess we can close this issue since we know how to install the current version of software in Windows and Linux..

prashanthr05 commented 2 years ago

I guess we can close this issue since we know how to install the current version of software in Windows and Linux..

Just saw this, is an action required to update the README?

HosameldinMohamed commented 2 years ago

Just saw this, is an action required to update the README?

Sorry, I forgot that the README needs to be updated. I'll open a PR

HosameldinMohamed commented 2 years ago

PR https://github.com/ami-iit/yarp-openvr-trackers/pull/9

prashanthr05 commented 2 years ago

PR landed. Thanks @HosameldinMohamed.