如何在配置类型设置为动态 link 库的解决方案中使用静态库?

How to use static library in a solution with configuration type set to dynamic link library?

我用 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   

经过大量研究和测试后,我发现如果我将项目属性 > 常规 > 项目默认值 > 配置从动态 link 库更改为静态,它会编译,尽管那时我尝试在 Maya 中加载已编译的 .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 文件编译为动态 link 库,但我想知道是否有一种方法可以只使用静态库而无需执行该步骤.

谢谢!

我发现了问题,我将库编译为x86,将插件编译为x64。我现在将两者都编译为 x64 并且可以工作。