【问题标题】:Pixar USD LNK2019: unresolved external symbolPixar USD LNK2019:未解决的外部符号
【发布时间】:2019-10-06 21:32:44
【问题描述】:

我正在开发一个 C++ 程序,该程序使用来自 Nvidia (https://developer.nvidia.com/usd) 的 Python 3 预构建库创建一个 .usda 文件。有很多外部库,我无法确定哪个导致了一堆编译器问题。有一些头文件(具体来说是 stage.h、mesh.h)会阻止我的程序编译。我从包中使用的其他头文件不会导致这些错误。

我从研究中得知,我可能缺少包含/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)'

【问题讨论】:

  • 您缺少指向 dll 导入库的链接。
  • 这是有道理的,但我无法弄清楚 哪个 dll 丢失了。我可以在包中找到的每个库都在我包含的路径中。此处的错误消息中是否有任何内容实际上可以帮助我找到丢失的文件?
  • 这个项目有多少个 .dll 文件?这不是缺少dll,您没有链接到与该项目中现有 dll 文件一起使用的 .lib(导入库而不是静态库)文件。
  • Stage.h 中有很多头文件,所以我不确定到底有多少个 dll 文件。这是 stage.h 的样子:github.com/PixarAnimationStudios/USD/blob/master/pxr/usd/lib/…

标签: c++ python-3.x visual-studio compiler-errors nvidia


【解决方案1】:

您应该在编译步骤设置中正确设置以下内容: 预处理器标志:

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

包括目录:&lt;usd_install&gt;\include;&lt;usd_install&gt;\include\boost-1_70;&lt;Python374&gt;\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 文件以更好地了解要包含的内容。

【讨论】:

    猜你喜欢
    • 2021-05-06
    • 2014-05-12
    • 2014-05-14
    • 2014-11-07
    • 2013-06-01
    • 1970-01-01
    • 2015-05-18
    • 1970-01-01
    相关资源
    最近更新 更多