我正在研究一个C ++程序,该程序使用Nvidia(https://developer.nvidia.com/usd)的Python 3预构建库创建.usda文件。有很多外部库,我无法确定哪个库引起了很多编译器问题。有一些头文件(具体来说是stage.h,mesh.h)会阻止我的程序编译。我从软件包中使用的其他头文件不会导致这些错误。
我从研究中发现,我可能会丢失一个include / lib目录,或者某些内容是在其他版本上编译的,但是如何找到丢失或编译不正确的文件呢?
我正在使用Windows 10,Visual Studio 2017,Python 3.6和Boost 1.68。 Nvidia库位于C:\ USDP3
包括:C:\ USDP3 \ include C:\ Program Files \ boost_1_68_0
库:C:\ USDP3 \ lib C:\ Program Files \ boost_1_68_0 C:\ USDP3 \ libs
示例代码:
#include "pch.h"
#define NOMINMAX
#define TBB_USE_ASSERT 0
#define TBB_USE_THREADING_TOOLS 0
#include "pxr/pxr.h"
#include "pxr/usd/usd/stage.h"
#include <iostream>
PXR_NAMESPACE_USING_DIRECTIVE
int main(int argc, char* argv[])
{
//Create Stage
UsdStage::CreateNew("Test.usda");
std::cout << "Hello World!\n";
}
导致这些错误:
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static char * * pxrInternal_v0_19__pxrReserved__::Sdf_Pool<struct pxrInternal_v0_19__pxrReserved__::Sdf_PathPropTag,24,8,16384>::_regionStarts" (__imp_?_regionStarts@?$Sdf_Pool@USdf_PathPropTag@pxrInternal_v0_19__pxrReserved__@@$0BI@$07$0EAAA@@pxrInternal_v0_19__pxrReserved__@@0PAPEADA)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_PrimPathNode::~Sdf_PrimPathNode(void)" (__imp_??1Sdf_PrimPathNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_MapperArgPathNode::~Sdf_MapperArgPathNode(void)" (__imp_??1Sdf_MapperArgPathNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_ExpressionPathNode::~Sdf_ExpressionPathNode(void)" (__imp_??1Sdf_ExpressionPathNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_PrimPartPathNode::operator delete(void *)" (__imp_??3Sdf_PrimPartPathNode@pxrInternal_v0_19__pxrReserved__@@SAXPEAX@Z)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_PrimPropertyPathNode::~Sdf_PrimPropertyPathNode(void)" (__imp_??1Sdf_PrimPropertyPathNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_TargetPathNode::~Sdf_TargetPathNode(void)" (__imp_??1Sdf_TargetPathNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_PropPartPathNode::operator delete(void *)" (__imp_??3Sdf_PropPartPathNode@pxrInternal_v0_19__pxrReserved__@@SAXPEAX@Z)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl pxrInternal_v0_19__pxrReserved__::Tf_RefPtr_UniqueChangedCounter::_RemoveRef(class pxrInternal_v0_19__pxrReserved__::TfRefBase const *)" (__imp_?_RemoveRef@Tf_RefPtr_UniqueChangedCounter@pxrInternal_v0_19__pxrReserved__@@SA_NPEBVTfRefBase@2@@Z)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_RelationalAttributePathNode::~Sdf_RelationalAttributePathNode(void)" (__imp_??1Sdf_RelationalAttributePathNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_MapperPathNode::~Sdf_MapperPathNode(void)" (__imp_??1Sdf_MapperPathNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) protected: void __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_PathNode::_RemovePathTokenFromTable(void)const " (__imp_?_RemovePathTokenFromTable@Sdf_PathNode@pxrInternal_v0_19__pxrReserved__@@IEBAXXZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class pxrInternal_v0_19__pxrReserved__::TfRefPtr<class pxrInternal_v0_19__pxrReserved__::UsdStage> __cdecl pxrInternal_v0_19__pxrReserved__::UsdStage::CreateNew(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum pxrInternal_v0_19__pxrReserved__::UsdStage::InitialLoadSet)" (__imp_?CreateNew@UsdStage@pxrInternal_v0_19__pxrReserved__@@SA?AV?$TfRefPtr@VUsdStage@pxrInternal_v0_19__pxrReserved__@@@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4InitialLoadSet@12@@Z)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: __cdecl pxrInternal_v0_19__pxrReserved__::Sdf_PrimVariantSelectionNode::~Sdf_PrimVariantSelectionNode(void)" (__imp_??1Sdf_PrimVariantSelectionNode@pxrInternal_v0_19__pxrReserved__@@AEAA@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static char * * pxrInternal_v0_19__pxrReserved__::Sdf_Pool<struct pxrInternal_v0_19__pxrReserved__::Sdf_PathPrimTag,24,8,16384>::_regionStarts" (__imp_?_regionStarts@?$Sdf_Pool@USdf_PathPrimTag@pxrInternal_v0_19__pxrReserved__@@$0BI@$07$0EAAA@@pxrInternal_v0_19__pxrReserved__@@0PAPEADA)'
答案 0 :(得分:0)
您应该在编译步骤设置中正确设置以下内容: 预处理器标志:
TBB_USE_DEBUG=0
YY_NO_UNISTD_H
BOOST_ALL_DYN_LINK
BOOST_PYTHON_NO_PY_SIGNATURES
BUILD_OPTLEVEL_DEV
NDEBUG
NOMINMAX
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
_CRT_SECURE_NO_DEPRECATE
_CRT_NONSTDC_NO_DEPRECATE
NO_WARN_MBCS_MFC_DEPRECATION
包括目录:<usd_install>\include;<usd_install>\include\boost-1_70;<Python374>\include
要链接的库:usd_ms.lib
(当 USD 被编译为整体共享库时)
其他,基本的:arch.lib;pxOsd.lib;sdf.lib;usd.lib;vt.lib;tf.lib;
渲染:hd.lib;hdx.lib;
更多:gf.lib;cameraUtil.lib;trace.lib;hf.lib;
(取决于您使用的是哪些。)
它们对应的 dll 应该是可发现的,或者最好应该在同一个目录中。作为您的可执行文件。
查看 USD 的 cmake 文件以更好地了解要包含的内容。