我用 Visual Studio 创建了两个解决方案。我将第一个编译为静态库。我想在第二个解决方案中使用该库,它是 Maya 的插件。
对于第二个解决方案,我从 Autodesk 提供的 hello world 模板文件开始,除了添加到我的库的路径并包含它之外,没有进行太多更改或任何其他操作。我不断收到此错误:
Severity Code Description Project File Line Suppression State
Error LNK1120 2 unresolved externals ddRbf C:\Users\daniele\Documents\workspace\ddPlugins\ddRbf\x64\Release\ddRbf.mll 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: void __cdecl ddMatrix::print(void)const " (?print@ddMatrix@@QEBAXXZ) referenced in function "public: virtual class Autodesk::Maya::OpenMaya20180000::MStatus __cdecl ddRbf::compute(class Autodesk::Maya::OpenMaya20180000::MPlug const &,class Autodesk::Maya::OpenMaya20180000::MDataBlock &)" (?compute@ddRbf@@UEAA?AVMStatus@OpenMaya20180000@Maya@Autodesk@@AEBVMPlug@345@AEAVMDataBlock@345@@Z) ddRbf C:\Users\daniele\Documents\workspace\ddPlugins\ddRbf\ddRbf.obj 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __cdecl ddMatrix::ddMatrix(class std::vector<class std::vector<double,class std::allocator<double> >,class std::allocator<class std::vector<double,class std::allocator<double> > > >)" (??0ddMatrix@@QEAA@V?$vector@V?$vector@NV?$allocator@N@std@@@std@@V?$allocator@V?$vector@NV?$allocator@N@std@@@std@@@2@@std@@@Z) referenced in function "public: virtual class Autodesk::Maya::OpenMaya20180000::MStatus __cdecl ddRbf::compute(class Autodesk::Maya::OpenMaya20180000::MPlug const &,class Autodesk::Maya::OpenMaya20180000::MDataBlock &)" (?compute@ddRbf@@UEAA?AVMStatus@OpenMaya20180000@Maya@Autodesk@@AEBVMPlug@345@AEAVMDataBlock@345@@Z) ddRbf C:\Users\daniele\Documents\workspace\ddPlugins\ddRbf\ddRbf.obj 1
经过大量研究和测试,我发现如果我将项目属性>常规>项目默认>配置从动态链接库更改为静态,它就会编译,尽管当时我尝试加载已编译的.mll文件玛雅我收到此错误:
// Error: file: C:/Program Files/Autodesk/Maya2018/scripts/others/pluginWin.mel line 290: Unable to dynamically load : C:/Users/daniele/Documents/maya/plug-ins/ddRbf.mll
// Error: file: C:/Program Files/Autodesk/Maya2018/scripts/others/pluginWin.mel line 290: (ddRbf) //
所以我想解决方案是将第一个 .sln 文件编译为动态链接库,但我想知道是否有一种方法可以只使用静态库而不必执行该步骤。
我发现了问题,我将库编译为x86,将插件编译为x64。我现在将两者编译为 x64 并且可以工作。