c++ - Maya plugin compile problems with cmake and VS2012 -


i trying compile example plugin found @ maya api using cmake create visual studio 2012 project. there seems number of problems when compiling libraries shipped maya. first problem library trying compensate old missing bool implementation, solved adding preprocessor definition

add_definitions(-d _bool) 

to cmake file.

the next error library problem tries acces std::ostream unable find in 'std', solved using definition in cmake:

add_definitions(-d require_iostream) 

this leads final error have been unable through, have both googled it, looked on stackoverflow , looked in sample vsproject files ship maya, unable solve it. errors(18 total) stems linker, , unresolved external symbols, example error:

error   1   error lnk2019: unresolved external symbol "__declspec(dllimport) public: __thiscall mstatus::mstatus(enum mstatus::mstatuscode)" (__imp_??0mstatus@@qae@w4mstatuscode@0@@z) referenced in function "public: virtual class mstatus __thiscall hello::doit(class marglist const &)" (?doit@hello@@uae?avmstatus@@abvmarglist@@@z) c:\path\mayacmake_sample\helloworld.obj sample_helloworld 

edit: using modified cmakelist andreas have not yielded difference: hey, reply, still lot of errors inresolved externals:

error   1   error lnk2019: unresolved external symbol "__declspec(dllimport) public: __thiscall mstatus::mstatus(enum mstatus::mstatuscode)" (__imp_??0mstatus@@qae@w4mstatuscode@0@@z) referenced in function "public: virtual class mstatus __thiscall hello::doit(class marglist const &)" (?doit@hello@@uae?avmstatus@@abvmarglist@@@z) d:\mayacmake_sample\helloworld.obj  maya_sample_plugin error   13  error lnk2001: unresolved external symbol "public: virtual bool __thiscall mpxcommand::hassyntax(void)const " (?hassyntax@mpxcommand@@ube_nxz)  d:\mayacmake_sample\helloworld.obj  maya_sample_plugin 

i cut out other errors same 2 above. made sure modify paths in cmake file fit install, looks follows:

cmake_minimum_required (version 2.6)  set(maya_plugin_name "maya_sample_plugin") set(maya_directory "c:/program files/autodesk/maya2013") set(maya_headers_dir "${maya_directory}/include") set(maya_library_dir "${maya_directory}/lib")  set(source_files   helloworld.cpp  )  source_group("" files ${source_files})  include_directories(   ${maya_headers_dir}   ${boost_include_dir} ) link_directories(   ${maya_library_dir} )  set(libraries   foundation.lib   openmaya.lib   openmayaanim.lib   openmayaui.lib )  set(maya_definitions _afxdll _mbcs nt_plugin require_iostream _bool)  add_library(${maya_plugin_name} shared ${source_files}) target_link_libraries(${maya_plugin_name} ${libraries})  set_target_properties(${maya_plugin_name} properties compile_definitions "${maya_definitions}") set_target_properties(${maya_plugin_name} properties output_name "${maya_plugin_name}") set_target_properties(${maya_plugin_name} properties suffix ".mll") set_target_properties(${maya_plugin_name} properties clean_direct_output 1) 

any in matter appriciated.

you need tell linker libs link against, done target_link_libraries. here's use in cmakelists.txt.

set(maya_plugin_name "mycoolplugin") set(maya_directory "d:/program files (x86)/autodesk maya2011") set(maya_headers_dir "${maya_directory}/include") set(maya_library_dir "${maya_directory}/lib")  set(source_files   mycoolplugin.cpp  )  source_group("" files ${source_files})  include_directories(${maya_headers_dir}) link_directories(${maya_library_dir})  set(libraries foundation.lib openmaya.lib openmayaanim.lib openmayaui.lib)  set(maya_definitions _afxdll _mbcs nt_plugin require_iostream _bool)  add_library(${maya_plugin_name} shared ${source_files}) target_link_libraries(${maya_plugin_name} ${libraries})  set_target_properties(${maya_plugin_name} properties compile_definitions "${maya_definitions}") set_target_properties(${maya_plugin_name} properties output_name "${maya_plugin_name}") set_target_properties(${maya_plugin_name} properties suffix ".mll") set_target_properties(${maya_plugin_name} properties clean_direct_output 1)  set_target_properties(${maya_plugin_name} properties link_flags "/export:initializeplugin /export:uninitializeplugin") 

Comments