PixarAnimationStudios / OpenUSD

Universal Scene Description

Home Page:http://www.openusd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linker error LNK110K cannot open file boost_python310-vc143-mt-gd-x64-1_78.lib

Elyg opened this issue · comments

Description of Issue

After compiling from source openUSD v24.05 I am trying to use the open usd libs on a very basic program to test if it's working before proceeding further but I keep getting boost_python310-vc143-mt-gd-x64-1_78.lib linker error

Error	LNK1104	cannot open file 'boost_python310-vc143-mt-gd-x64-1_78.lib'

I have installed the openUSD in .../usd_build folder

I have added the ..../usd_build/lib ..../usd_build/bin to my environment PATH as well as create the PYTHONPATH where i pasted the path printed at the end of the build_script.py

if i run python and try to use the pxr modules it all works
when i run usdview by giving it the usdview ./OpenUSD/extras/usd/tutorials/convertingLayerFormats/Sphere.usda - it also works

However anytime i try to run my example main.cpp program i get the the linker error


I tried various build-variants - same result
I tried providing the generator flag and without - same result
I am using visual studio 2022 and i used the x64 terminal to make sure openUSD builds x64

I have added the Include Directories to my visual studio project

D:\Projects\ExternalLibs\src\usd_build\include\boost-1_78
D:\Projects\ExternalLibs\src\usd_build\include
C:\Users\username\AppData\Local\Programs\Python\Python310\include
%(AdditionalIncludeDirectories)

I have also added libs to the Library Directories as well

D:\Projects\ExternalLibs\src\usd_build\bin
D:\Projects\ExternalLibs\src\usd_build\lib
C:\Users\username\AppData\Local\Programs\Python\Python310\libs

%(AdditionalLibraryDirectories)

I see the boost_python310-vc143-mt-x64-1_78.lib file in the /usd_build/lib directory but no boost_python310-vc143-mt-gd-x64-1_78.lib (mt-x64 vs mt-gd-x64)

Which after reading on stackoverflow the build script built runtime shared library
https://stackoverflow.com/questions/6014517/whats-the-difference-between-mt-gd-and-mt-s-library

But then if i try to build release mode i get other linker errors:

1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl pxrInternal_v0_24__pxrReserved__::Tf_RefPtr_UniqueChangedCounter::_RemoveRefMaybeLocked(class pxrInternal_v0_24__pxrReserved__::TfRefBase const *,int)" (__imp_?_RemoveRefMaybeLocked@Tf_RefPtr_UniqueChangedCounter@pxrInternal_v0_24__pxrReserved__@@SA_NPEBVTfRefBase@2@H@Z) referenced in function "public: __cdecl pxrInternal_v0_24__pxrReserved__::TfRefPtr<class pxrInternal_v0_24__pxrReserved__::UsdStage>::~TfRefPtr<class pxrInternal_v0_24__pxrReserved__::UsdStage>(void)" (??1?$TfRefPtr@VUsdStage@pxrInternal_v0_24__pxrReserved__@@@pxrInternal_v0_24__pxrReserved__@@QEAA@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_PathNode::_RemovePathTokenFromTable(void)const " (__imp_?_RemovePathTokenFromTable@Sdf_PathNode@pxrInternal_v0_24__pxrReserved__@@IEBAXXZ) referenced in function "protected: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_PathNode::~Sdf_PathNode(void)" (??1Sdf_PathNode@pxrInternal_v0_24__pxrReserved__@@IEAA@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_PrimPartPathNode::operator delete(void *)" (__imp_??3Sdf_PrimPartPathNode@pxrInternal_v0_24__pxrReserved__@@SAXPEAX@Z) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_PropPartPathNode::operator delete(void *)" (__imp_??3Sdf_PropPartPathNode@pxrInternal_v0_24__pxrReserved__@@SAXPEAX@Z) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_PrimPathNode::~Sdf_PrimPathNode(void)" (__imp_??1Sdf_PrimPathNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_PrimPropertyPathNode::~Sdf_PrimPropertyPathNode(void)" (__imp_??1Sdf_PrimPropertyPathNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_PrimVariantSelectionNode::~Sdf_PrimVariantSelectionNode(void)" (__imp_??1Sdf_PrimVariantSelectionNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_TargetPathNode::~Sdf_TargetPathNode(void)" (__imp_??1Sdf_TargetPathNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_RelationalAttributePathNode::~Sdf_RelationalAttributePathNode(void)" (__imp_??1Sdf_RelationalAttributePathNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_MapperPathNode::~Sdf_MapperPathNode(void)" (__imp_??1Sdf_MapperPathNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_MapperArgPathNode::~Sdf_MapperArgPathNode(void)" (__imp_??1Sdf_MapperArgPathNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_24__pxrReserved__::Sdf_ExpressionPathNode::~Sdf_ExpressionPathNode(void)" (__imp_??1Sdf_ExpressionPathNode@pxrInternal_v0_24__pxrReserved__@@AEAA@XZ) referenced in function "void __cdecl pxrInternal_v0_24__pxrReserved__::TfDelegatedCountDecrement(class pxrInternal_v0_24__pxrReserved__::Sdf_PathNode const *)" (?TfDelegatedCountDecrement@pxrInternal_v0_24__pxrReserved__@@YAXPEBVSdf_PathNode@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class pxrInternal_v0_24__pxrReserved__::TfRefPtr<class pxrInternal_v0_24__pxrReserved__::UsdStage> __cdecl pxrInternal_v0_24__pxrReserved__::UsdStage::CreateInMemory(enum pxrInternal_v0_24__pxrReserved__::UsdStage::InitialLoadSet)" (__imp_?CreateInMemory@UsdStage@pxrInternal_v0_24__pxrReserved__@@SA?AV?$TfRefPtr@VUsdStage@pxrInternal_v0_24__pxrReserved__@@@2@W4InitialLoadSet@12@@Z) referenced in function main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static char * * pxrInternal_v0_24__pxrReserved__::Sdf_Pool<struct pxrInternal_v0_24__pxrReserved__::Sdf_PathPrimTag,24,8,16384>::_regionStarts" (__imp_?_regionStarts@?$Sdf_Pool@USdf_PathPrimTag@pxrInternal_v0_24__pxrReserved__@@$0BI@$07$0EAAA@@pxrInternal_v0_24__pxrReserved__@@0PAPEADA) referenced in function "public: __cdecl std::pair<class pxrInternal_v0_24__pxrReserved__::SdfPath,class pxrInternal_v0_24__pxrReserved__::SdfPath>::~pair<class pxrInternal_v0_24__pxrReserved__::SdfPath,class pxrInternal_v0_24__pxrReserved__::SdfPath>(void)" (??1?$pair@VSdfPath@pxrInternal_v0_24__pxrReserved__@@V12@@std@@QEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static char * * pxrInternal_v0_24__pxrReserved__::Sdf_Pool<struct pxrInternal_v0_24__pxrReserved__::Sdf_PathPropTag,24,8,16384>::_regionStarts" (__imp_?_regionStarts@?$Sdf_Pool@USdf_PathPropTag@pxrInternal_v0_24__pxrReserved__@@$0BI@$07$0EAAA@@pxrInternal_v0_24__pxrReserved__@@0PAPEADA)

I am probably doing something really stupid, i have been stuck on this for a couple of days now
Any help is greatly appreciated!

Steps to Reproduce

  1. build using the build_script.py with below flags
  2. create a cpp visual studio project
  3. try to run debug mode of example main.cpp
// IMPORT STANDARD LIBRARIES
#include <iostream>

#define NOMINMAX 0
#define TBB_USE_ASSERT 0 //Defines I needed for TBB to work found them in other issues on github here
#define TBB_USE_THREADING_TOOLS 0
#define TBB_USE_PERFORMANCE_WARNINGS 0
#define __TBB_STATISTICS 0

// IMPORT THIRD-PARTY LIBRARIES
#include <pxr/usd/usd/stage.h>

PXR_NAMESPACE_USING_DIRECTIVE

int main()
{
   auto stage = UsdStage::CreateInMemory();
   std::cout << "Hello World!" << std::endl;
}

System Information (OS, Hardware)

Windows 11 Pro 10.0.22631 Build 22631

Build Flags

set "USD_REPO_DIR=D:\Projects\ExternalLibs\src\OpenUSD"
set "USD_BUILD_ROOT=D:\Projects\ExternalLibs\src\usd_build"

python %USD_REPO_DIR%\build_scripts\build_usd.py ^
    --build-variant="relwithdebuginfo" ^
    --generator "Visual Studio 17 2022" ^
    "%USD_BUILD_ROOT%"

gd indicates a debug build. I think if you switch your project to RelWithDebInfo to match your USD build, it should solve your problem.

Note that boost python specifies the library inclusion via a pragma, which is where the unexpected filename is coming from.

Filed as internal issue #USD-9697

So i switched from using visual studio solutions to cmake
With that I was able to get the release config build without issues

But I still had issues with RelWithDebInfo, where i was getting another different error about libs not being found

1> [CMake] CMake Error at D:/Projects/ExternalLibs/src/usd_build/lib/cmake/MaterialX/MaterialXTargets.cmake:164 (message):
1> [CMake]   The imported target "arch" references the file
1> [CMake] 
1> [CMake]      "/lib/usd_arch.lib"
1> [CMake] 
1> [CMake]   but this file does not exist.  Possible reasons include:
1> [CMake] 
1> [CMake]   * The file was deleted, renamed, or moved to another location.
1> [CMake] 
1> [CMake]   * An install or uninstall procedure did not complete successfully.
1> [CMake] 
1> [CMake]   * The installation package was faulty and contained
1> [CMake] 
1> [CMake]      "D:/Projects/ExternalLibs/src/usd_build/lib/cmake/MaterialX/MaterialXTargets.cmake"
1> [CMake] 
1> [CMake]   but not all the files it references.

So I ended up editing pxrTargets-relwithdebinfo.cmake and included this from the other pxrTargets.cmake

pxrTargets-relwithdebinfo.cmake

set(CMAKE_IMPORT_FILE_VERSION 1)
#...
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
  set(_IMPORT_PREFIX "")
endif()
#...

This fixed the final issue i had, and now I am able to build with RelWithDebInfo


Here's my final cmake in my project

# CMakeList.txt : CMake project for TestUsd, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)


# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

set(CMAKE_BUILD_TYPE RelWithDebInfo)

# Specify the path where USD is installed
set(USD_INSTALL_DIR "D:/Projects/ExternalLibs/src/usd_build")

project ("TestUsd")

# Add source to this project's executable.
add_executable (TestUsd "main.cpp" )

# Add the directory containing pxrTargets.cmake to CMake module path
list(APPEND CMAKE_MODULE_PATH "${USD_INSTALL_DIR}/cmake")

# Include the pxrTargets.cmake file
include(pxrTargets)
include(pxrTargets-relwithdebinfo)

# Find the USD package
find_package(pxr REQUIRED)

target_link_libraries(TestUsd usd)

if (CMAKE_VERSION VERSION_GREATER 3.12)
  set_property(TARGET TestUsd PROPERTY CXX_STANDARD 20)
endif()

main.cpp

// IMPORT STANDARD LIBRARIES
#include <iostream>
#include <string>

#define NOMINMAX 0
#define TBB_USE_ASSERT 0 //Defines I needed for TBB to work found them in other issues on github here
#define TBB_USE_THREADING_TOOLS 0
#define TBB_USE_PERFORMANCE_WARNINGS 0
#define __TBB_STATISTICS 0

// IMPORT THIRD-PARTY LIBRARIES
#include <pxr/usd/usd/stage.h>

PXR_NAMESPACE_USING_DIRECTIVE

int main()
{   
    std::cout << "Reading File" << std::endl;
    UsdStageRefPtr stage = UsdStage::Open("D:\\Projects\\CppProjects\\TestUsd\\sphere.usda"); 

    std::cout << "Export To String" << std::endl;
    std::string t;
    stage->ExportToString(&t);
    std::cout << t << std::endl;

    std::cout << "End" << std::endl;
}