简体   繁体   中英

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

I have created two solutions with visual studio. I compile the first as a static lib. I want to use that lib in the second solution which is a plugin for maya.

For the second solution I started from the hello world template file Autodesk provides and didn't change much or anything at all except adding the path to my lib and including it. I kept getting this errors:

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   

After a lot of researches and tests I found out that if I would change project properties > general > project defaults > configuration from dynamic link libraries to static it would compile, although at that point when i try to load the compiled .mll file in maya I get this error:

// 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) //  

So I guess the solution is to compile the first .sln file as a dynamic link library instead, but I was wondering if there was a way to just use the static library without having to do that step.

Thanks!

I found the problem, I compiled the library as x86 and the plugin as x64. I compiled both as x64 now and works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM