Building a C++ Plugin for distribution

98 views
Skip to first unread message

Joe Weidenbach

unread,
Feb 23, 2015, 1:50:24 PM2/23/15
to python_in...@googlegroups.com
Hey all,

I'm running into a minor snag with distributing a plugin I've written. It works perfectly on all of my machines, but all of my machines have Visual Studio installed.  Also, when I build on Linux or MacOS, there's no problem.  But, when I build on Windows, and try to load the plugin on a machine that doesn't have VS, I get the following error:

Error: Unable to dynamically load : C:\Program Files\Autodesk\Maya2014\bin\plug-ins\XXX.mll 
The specified module could not be found. 

XXX is my module name, could be anything.

The research I've done says that this is a missing library somewhere.  It should be noted that I have no control over the target systems (they're at a school where I teach), but I've noticed that a few of my commercial plugins work fine, so it shouldn't be a missing dependency.  I'm guessing that I'm missing something in the build process.  At first I thought it was that I was building in Visual Studio 2012, but I've switched to building in 2010 and I have the same issue.

One thing I did try was installing the VC10 runtime, but it made no difference.

I've tried using DependencyWalker and it looks like it's not finding the OpenMaya library.  However, it works perfectly on all of my development machines, so I'm not sure what the issue could be.  I also tested on a friend's laptop that didn't have restrictions, and it got the same error as I get at the school.

The only thing I can think is that this is some switch I've forgotten to check in Visual Studio.  Any ideas?

Thanks,

Joe

Justin Israel

unread,
Feb 23, 2015, 1:58:09 PM2/23/15
to python_in...@googlegroups.com

I don't have any experience with compiling Maya plugins with Visual Studio, but as a random guess it sounds like it isn't actually linking against Maya? I wouldn't think you would need the VS runtime on the target machine, if it is just going to link against Maya. Maybe I am totally wrong.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da7Sd42QLNAgNjuopQ%3Dkid2_q0UmpXh7w93QvMOLzsMa_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Lidia Martinez

unread,
Feb 23, 2015, 3:06:41 PM2/23/15
to python_in...@googlegroups.com
Yeah, that happened to me too while working on Qt applications , not Maya related. Visual Studio always needs to be connected to their dlls, but you have to find a way so that it doesn't need to be connected. I think you could just ask in a general c++ stack overflow forum. There are plenty of solutions there, for sure.

--
Lidia

Joe Weidenbach

unread,
Feb 23, 2015, 3:10:11 PM2/23/15
to python_in...@googlegroups.com
I did check that--I'm using Chad Vernon's CMake script from his API series over on CG Circuit, modified for these plugins of course.  The project file DOES link against them.  What's weird is that it only works on my build machines.  I'd think that if they weren't linking against Maya that it wouldn't work at all, which leads me back to visual studio specifically.  I guess I'm hopiing someone who makes plugins in a windows shop might have run into this :).  Most of the searches I've done just turn up tech support for customers (mostly with Arnold or Houdini, it seems) that run into this.  Very few developer insights appear.

Marcus Ottosson

unread,
Feb 23, 2015, 3:24:47 PM2/23/15
to python_in...@googlegroups.com

Set up a virtual machine - such as VMWare or VirtualBox - and try it out on a clean Windows install.​

In general, anything built using Visual Studio requires a re-distributable for the corresponding version; e.g. Visual Studio 2010 will link against dlls that your users can get a hold of via the Visual Studio 2010 re-distributable.

But you can also bundle them. You’re typically looking for two dll’s; msvcr100 and msvcp100 for the 2010 version, but it depends on what you use. For example, here’s all files included in the 2013 re-distributable.

mfc120.dll
mfc120u.dll
mfcm120.dll
mfcm120u.dll
msvcp120.dll
msvcr120.dll
vcamp120.dll
vcomp120.dll

That, along with any other libraries you dynamically linked with will need to be included.

You can use Dependency Walker to find out exactly which; it hooks into an executable and “spies” on which libraries it imports.

It can be a bit cryptic to use at first but it’s the go-to tool for these type of situations.

Good luck!

Best,
Marcus

Joe Weidenbach

unread,
Feb 23, 2015, 3:27:12 PM2/23/15
to python_in...@googlegroups.com
Thank you thank you thank you Marcus!!!

Oddly enough, after 8 years in a mixed programming/IT role, I hadn't even considered using a VM.  Brilliant!

Also, the technical info is great!  Much appreciated!

Thanks,

Joe

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Kurian O.S

unread,
Feb 23, 2015, 3:31:24 PM2/23/15
to python_in...@googlegroups.com
Maybe a stupid question, are you in release mode or debug mode while compiling ?


For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

Joe Weidenbach

unread,
Feb 23, 2015, 3:36:08 PM2/23/15
to python_in...@googlegroups.com
Release on the ones I'm building for distribution.

Marcus Ottosson

unread,
Feb 23, 2015, 4:06:11 PM2/23/15
to python_in...@googlegroups.com
You're very welcome, Joe. Happy to help. :)
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da72tbX6k01Lnk2HqW%3D6mkHBh%2BeDOfkEr2G4ZvoHKw_quw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


--
Marcus Ottosson
konstr...@gmail.com


Chad Vernon

unread,
Feb 24, 2015, 3:00:59 PM2/24/15
to python_in...@googlegroups.com
This typically happens while compiling in debug mode and has to do with the Runtime Library flag.  This usually happens when it is set to /MD or /MDd which makes it use the dll versions of the runtime libraries.  Using /MT or /MTd use the static runtime library.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.

  2. Expand the C/C++ folder.

  3. Select the Code Generation property page.

  4. Modify the Runtime Library property.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
Marcus Ottosson
konstr...@gmail.com


Joe Weidenbach

unread,
Feb 24, 2015, 9:00:30 PM2/24/15
to python_in...@googlegroups.com
Woo!  Ok, apparently I did build it on debug mode, and /MD was set.  So, I switched it over to /MT and that fixed it, according to my virtual machine that's now up and running :)  I'll have to check it out on Friday when I'm at the school to confirm, but that looks like it sorted it.

Thanks Chad (and Marcus for the GREAT VM reminder :))!

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/73db7740-8445-425a-a399-53f06d55b810%40googlegroups.com.

Joe Weidenbach

unread,
Feb 24, 2015, 10:12:38 PM2/24/15
to python_in...@googlegroups.com
On that note, I also adjusted my CMake Template File with the following options for windows builds (at the end of the file):

# Disable CMake's default MinSizeRel and RelWithDebugInfo Build Targets for Visual Studio.
# This WILL error out on the first run. Run it again and everything will be fine.
IF (CMAKE_CONFIGURATION_TYPES AND CMAKE_CONFIGURATION_TYPES MATCHES MinSizeRel)
set (cfgs ${CMAKE_CONFIGURATION_TYPES})
list (REMOVE_ITEM cfgs MinSizeRel)
list (REMOVE_ITEM cfgs RelWithDebInfo)
set (CMAKE_CONFIGURATION_TYPES ${cfgs} CACHE STRING "Limited Configs" FORCE)
message (FATAL_ERROR "List of configurations was reset, please re-run cmake. This message is normal.")
ENDIF (CMAKE_CONFIGURATION_TYPES AND CMAKE_CONFIGURATION_TYPES MATCHES MinSizeRel)

IF (MSVC)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
ENDIF (MSVC)

That seems to take care of setting that up properly by default.  It also gets rid of the default MinSizeRel and RelWithDebugInfo build targets.  It seems (from my research) to be a known bug that on the first pass CMake will build those regardless of what you tell it to do, so the easy way is to throw an error and ask the user to re-run so the cache is fixed.

Hope that helps anyone down the road :).

Joe

Chad Vernon

unread,
Feb 25, 2015, 12:47:46 AM2/25/15
to python_in...@googlegroups.com
This worked for me without an error on the first run.  


if (WIN32)
  set(CMAKE_CONFIGURATION_TYPES Debug Release)
endif()

# Project must be called after setting the configuration types
project(sampleplugin)

if (WIN32)
  foreach (flag_var
           CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE)
      string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
  endforeach()
endif()


I think in yours the /MD flag is still in the flag list.  But whatever works!


You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/h5jyMZSigNQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da7nySVMMkZWE9UVUQauTTss783Xxcy4YqtjtbVsTVB0hg%40mail.gmail.com.

Joe Weidenbach

unread,
Feb 25, 2015, 2:28:59 AM2/25/15
to python_in...@googlegroups.com
Hey, I'm not an expert on CMake.  I've primarily been developing in Windows until the last few months, so I'm used to building up manually from Visual Studio.  If that does it, outstanding!  I'll let you know once I've had a chance to test it out.  If the /MD is still in the list, I couldn't see it, but that certainly doesn't mean it's not still there.  So this is great!  Thanks, Chad!
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da72tbX6k01Lnk2HqW%3D6mkHBh%2BeDOfkEr2G4ZvoHKw_quw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Marcus Ottosson
konstr...@gmail.com


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/73db7740-8445-425a-a399-53f06d55b810%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/h5jyMZSigNQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.




This email is free from viruses and malware because avast! Antivirus protection is active.


Reply all
Reply to author
Forward
0 new messages