Feedback

What's your question?

By: [ Admin ] Asked from India

how to compile maya plugins for windows using cygwin

anyone know whats involved in compiling maya plugins for win using cygwin? if someone has a makefile that will really help.

Add comment viewed 721 times Latest activity 11 months ago

NN comments
michalf
-

out of curiosity, why would you wan’t to do that ?

julian
-

I’ve been using Rake (Ruby Make) to build for mac and linux, and it means I don’t have to maintain project files from different IDEs. XCode, KDevelop etc. In the Rakefile I have an switch statement for platforms so I just want to add windows as a case and keep things DRY.

michalf
-

does Rake forces you somehow to use cygwin? I use cmake and build with gcc under linux, and msvc under win…

julian
-

The reason I set up cygwin was to use bash. I’d rather not be using windows at all. I’m sure you can run Rake on Win without cygwin, but I was using some env vars that were set in bashrc – the same bashrc (symlinked) for mac and linux.

or Cancel

2 answers

  • 1

mr grumpy [ Editor ]

I don't think it's possible to use g++ to build a Maya plug-in for Windows, the ABI will be different, name mangling, vtables, etc.

I've been calling Microsoft's cl.exe/link.exe instead of g++; rip all the flags out of the VS project. You could have all the platform-specific variable definitions in another file and include it into the main Makefile. e.g. for Maya 2011-x64...

cxx := "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/amd64/cl.exe"
cc := $(cxx)
ld := "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/amd64/link.exe"
ar := "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/amd64/lib.exe"
vc_incl := "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include"
vc_libpath := "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\amd64"
vc_sdk_incl := "C:\Program Files\Microsoft SDKs\Windows\v7.0\include"
vc_sdk_libpath := "C:\Program Files\Microsoft SDKs\Windows\v7.0\lib\x64"

cflags := /c /O2 /nologo /W3 /Ob1 /Gy /DNOMINMAX
cflags += /MD
cxxflags := /GR /EHs /TP /EHsc $(cflags)
cxxflags += /DNDEBUG \
        /DNT_PLUGIN /DREQUIRE_IOSTREAM /DAW_NEW_IOSTREAMS /DGLEW_STATIC \
        /FD /D_CRT_SECURE_NO_WARNINGS /fp:precise /Gd
cxxflags += /DWIN_NT /DWIN32 /D_WIN32 /D_WINDOWS /D_WINDLL
cxxflags += /DBits64_ /D_WIN64

maya_version := 2011
maya_include := "C:\Program Files\Autodesk\Maya$(maya_version)\include"
maya_libpath := "C:\Program Files\Autodesk\Maya$(maya_version)\lib"
maya_version := $(maya_version)-x64

includes := /I. /I$(vc_incl) /I$(vc_sdk_incl) /I$(maya_include) 
lib_path := /LIBPATH:$(vc_libpath) /LIBPATH:$(vc_sdk_libpath)
ldflags := /nologo /OPT:NOREF /INCREMENTAL:NO 
gl_libs := opengl32.lib glu32.lib
maya_libs := /LIBPATH:$(maya_libpath) odbc32.lib odbccp32.lib \
    OpenMaya.lib Foundation.lib OpenMayaUI.lib \
    OpenMayaAnim.lib OpenMayaFX.lib OpenMayaRender.lib \
    $(gl_libs) wsock32.lib tbb.lib

dso_flags = /DLL /export:initializePlugin /export:uninitializePlugin
pluglibext = mll
staticlibext = lib
objext = obj
ld_out = /OUT:$@
cc_out = /Fo$@
inst = /cygdrive/c/cygwin/bin/install

The rest is the same as on Linux/Mac.

NN comments
or Cancel
  • 1

hradec [ Editor ]

Hi Julian...

I have being trying to compile maya plugins with mingw and cygwin for a long time and I never got it to work. The way MSVC exports symbols in a .dll is kinda different from the way mingw does and, although they are compatible, maya is kinda "sensible" about MSVC way and doesn't like the other ones.

There is some info on the web on how to "convert" the symbols from mingw/cygwin to MSVC, but I never got the time to try...

Another method would be compile the plugin as a normal dll, and have a simple "maya dll loader" plugin compiled in MSVC that would then READ the mingw dlls. But again, I never got that far.

I hope someone else had more luck than I and hopefully would share the cookbook here with us!

If in the future I get this finally to work, I'll definitely drop you a line here!

-H

PS: here are some links that explain the problem a bit better:

-this explains about the problem of compiling maya plugin with gcc in windows abit. At the end theres an reply from Rob Bateman to me explaining how to get all your code into a mingw dll and load it in a plugin built in MSVC: http://www.creativecrash.com/forums/api/topics/maya-libs-compatible-with-mingw-

-this shows you the errors you get when you try to link your code with maya libraries: http://forums.cgsociety.org/archive/index.php/t-195959.html

-this talks about the diferences from mingw/cygwin dlls and msvc dlls, and it also talks about use MSVC LIB tool to genreate a .def file from a MSVC DLL to use with Mingw. I never tried, but this was the best bet of getting Mingw/Cygwin to link against maya libraries correclty. It also talks about how to proper genrate a DLL from mingw, also using .def files to properly convert symbol mangling from mingw to msvc, which in my understand, would allow maya to load it properly. http://wyw.dcweb.cn/stdcall.htm

If there's a way to build maya plugins ONLY using mingw/cygwin, that is our best bet!

-this last one explains how to get mingw to generate a proper dll that a maya MSVC plugin can read (the same idea Rob gave me on the first link). This was the only successful attempt of using mingw/cygwin with maya so far. If you scroll all the way down you find a link to a testdll.zip file. It's a demo on how to do it! it comes with the code and a shell script to build a mingw/cygwin dll and the MSVC code and project to build the maya plugin that will load the myngw/cygwin dll. http://cygwin.com/ml/cygwin/2002-02/msg00689.html

Unfortunatelly I never found info about loading mingw dll DIRECTLY in maya. =(

"That makes me a saaaaaaaaad Panda!"

NN comments
julian
-

Cheers Roberto, that sounds like a nightmare and you probably just saved me lot of effort. I wanted to keep just one Makefile for all platforms and I thought it would be easy with Cygwin, but it looks like I’ll have to just use Visual Studio. yuk.

or Cancel