PDA

View Full Version : maya 6.0.1 plugin compiling on Mac...


sparaig
12-06-2006, 10:21 PM
Yes, I know I'm 2 generations out of date. I'm an unemployed student with too much free time and no means to upgrade right now...

Anyway, I'm trying to compile the helloWorld plug-in on the Mac using the latest version of xcode and thought I had followed the steps in the API manual, but got this series of errors. Any suggestions on how to proceed?:

Building target “helloCmd” of project “helloCmd” with configuration “Development” — (2 errors, 1 warning)
[...]
@executable_path/libplds4.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libplds4.dylib
ld: warning prebinding disabled because of undefined symbols
ld: Undefined symbols:
__ZTI10MPxCommand
/Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.build/Development/helloCmd.build/Objects-normal/ppc/helloCmd.o reference to undefined __ZTI10MPxCommand
/usr/bin/libtool: internal link edit command failed
ld: warning prebinding disabled because of undefined symbols
ld: Undefined symbols:
__ZTI10MPxCommand
/Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.build/Development/helloCmd.build/Objects-normal/ppc/helloCmd.o reference to undefined __ZTI10MPxCommand
/usr/bin/libtool: internal link edit command failed
Build failed (2 errors, 1 warning)

wdavidlewis
12-07-2006, 01:48 AM
So, first off, I'm not a Mac programmer, so all I can give is pretty general advice. If you're an experienced C/C++ programmer, anything I say below will probably be obvious to you already. Now that we have the caveats out of the way...

What you're getting is linker errors that indicate that the linker couldn't find definitions for functions/classes you're using in your code. "__ZTI10MPxCommand" is the mangled name of MPxCommand. MPxCommand is the class your command is inheriting from.

On Windows, the MPxCommand class is in the OpenMaya.lib library. So, I think you need to link with the library that has the MPxCommand class in it, and I would try OpenMaya first.

Find the OpenMaya library in your installation; if you're linking, you must be finding the header files during compilation, so they're probably located close to those. Check in your build environment where you can specify extra libraries to link against. Add the OpenMaya library (and the base build in Windows adds in the Foundation library as well). You may have to add a link path or something similar.

Hope this was of some use.

--- David

sparaig
12-07-2006, 05:40 AM
So, first off, I'm not a Mac programmer, so all I can give is pretty general advice. If you're an experienced C/C++ programmer, anything I say below will probably be obvious to you already. Now that we have the caveats out of the way...

What you're getting is linker errors that indicate that the linker couldn't find definitions for functions/classes you're using in your code. "__ZTI10MPxCommand" is the mangled name of MPxCommand. MPxCommand is the class your command is inheriting from.

On Windows, the MPxCommand class is in the OpenMaya.lib library. So, I think you need to link with the library that has the MPxCommand class in it, and I would try OpenMaya first.

Find the OpenMaya library in your installation; if you're linking, you must be finding the header files during compilation, so they're probably located close to those. Check in your build environment where you can specify extra libraries to link against. Add the OpenMaya library (and the base build in Windows adds in the Foundation library as well). You may have to add a link path or something similar.

Hope this was of some use.

--- David

Not sure. The compiler I'm using is theXCODE thing, whichi s the offshoot of theoriginal NeXT development system. I looked through the complete link message, and it appears to know where to find all the object files. It just doesn't find the only one evoked by my helloWorld:


yBuilding target “helloCmd” of project “helloCmd” with configuration “Development”


Checking Dependencies
Ld /Applications/Alias/maya6.0/devkit/plug-ins/build/Development/helloCmd.dylib normal ppc
cd /Applications/Alias/maya6.0/devkit/plug-ins
/usr/bin/g++-4.0 -o /Applications/Alias/maya6.0/devkit/plug-ins/build/Development/helloCmd.dylib
-L/Applications/Alias/maya6.0/devkit/plug-ins/build/Development
-L/Applications/Alias/maya6.0/Maya.app/Contents/MacOS
-F/Applications/Alias/maya6.0/devkit/plug-ins/build/Development
-filelist /Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.build/Development/helloCmd.build/Objects-normal/ppc/helloCmd.LinkFileList
-arch ppc -prebind -Wl,-single_module -compatibility_version 1 -current_version 1
-install_name /usr/local/lib/helloCmd.dylib -Wl,-Y,1455
-dynamiclib -lOpenMaya -lFoundation
-dylib_file @executable_path/libBase.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libBase.dylib
-dylib_file @executable_path/libFoundation.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libFoundation.dylib
-dylib_file @executable_path/libSubdivEngine.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libSubdivEngine.dylib
-dylib_file @executable_path/libGeometryEngine.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libGeometryEngine.dylib
-dylib_file @executable_path/libAG.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libAG.dylib
-dylib_file @executable_path/libExplorerSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libExplorerSlice.dylib
-dylib_file @executable_path/libShared.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libShared.dylib
-dylib_file @executable_path/libNurbsEngine.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libNurbsEngine.dylib
-dylib_file @executable_path/libSubdiv.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libSubdiv.dylib
-dylib_file @executable_path/libDataModel.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libDataModel.dylib
-dylib_file @executable_path/libNurbs.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libNurbs.dylib
-dylib_file @executable_path/libExtensionLayer.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libExtensionLayer.dylib
-dylib_file @executable_path/libPolyEngine.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libPolyEngine.dylib
-dylib_file @executable_path/libCommandEngine.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libCommandEngine.dylib
-dylib_file @executable_path/libDependEngine.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libDependEngine.dylib
-dylib_file @executable_path/libPoly.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libPoly.dylib
-dylib_file @executable_path/libSubdivGeom.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libSubdivGeom.dylib
-dylib_file @executable_path/libModelSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libModelSlice.dylib
-dylib_file @executable_path/libRenderModel.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libRenderModel.dylib
-dylib_file @executable_path/lib3dGraphics.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/lib3dGraphics.dylib
-dylib_file @executable_path/libImage.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libImage.dylib
-dylib_file @executable_path/libAnimEngine.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libAnimEngine.dylib
-dylib_file @executable_path/libHWRender.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libHWRender.dylib
-dylib_file @executable_path/libHWFoundation.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libHWFoundation.dylib
-dylib_file @executable_path/libHWGL.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libHWGL.dylib
-dylib_file @executable_path/libNurbsSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libNurbsSlice.dylib
-dylib_file @executable_path/libDependCommand.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libDependCommand.dylib
-dylib_file @executable_path/libPolySlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libPolySlice.dylib
-dylib_file @executable_path/libKinSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libKinSlice.dylib
-dylib_file @executable_path/libDynSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libDynSlice.dylib
-dylib_file @executable_path/libDeformSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libDeformSlice.dylib
-dylib_file @executable_path/libAnimSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libAnimSlice.dylib
-dylib_file @executable_path/libManips.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libManips.dylib
-dylib_file @executable_path/libModelUISlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libModelUISlice.dylib
-dylib_file @executable_path/libSharedUI.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libSharedUI.dylib
-dylib_file @executable_path/libImageUI.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libImageUI.dylib
-dylib_file @executable_path/libRenderSlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libRenderSlice.dylib
-dylib_file @executable_path/libPopLib.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libPopLib.dylib
-dylib_file @executable_path/libIMF.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libIMF.dylib
-dylib_file @executable_path/libDynUISlice.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libDynUISlice.dylib
-dylib_file @executable_path/libOpenMaya.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libOpenMaya.dylib
-dylib_file @executable_path/libxpcom.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libxpcom.dylib
-dylib_file @executable_path/libnspr4.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libnspr4.dylib
-dylib_file @executable_path/libplc4.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libplc4.dylib
-dylib_file @executable_path/libplds4.dylib:/Applications/Alias/maya6.0/Maya.app/Contents/MacOS/libplds4.dylib
ld: warning prebinding disabled because of undefined symbols
ld: Undefined symbols:
__ZTI10MPxCommand
/Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.build/Development/helloCmd.build/Objects-normal/ppc/helloCmd.o reference to undefined __ZTI10MPxCommand
/usr/bin/libtool: internal link edit command failed

wdavidlewis
12-07-2006, 09:59 AM
Okay, we've just about surpassed my ability to figure out what's going on (having never programmed on a Mac before...)

If you're getting an undefined symbol at link time, it's got to be one of two things:1) not linking the proper library

2) the symbol reference in your code doesn't match the exported symbol in the library (e.g. your code is looking for __ZTI10MPxCommand and the library exports __blahblah10MpxCommand ) I couldn't find any docs on the mangling logic, so other than the fact the 10 refers to the length of the symbol name (MPxCommand), the rest of it is a mystery to me.
As far as I can tell from the output, you're linking the libraries you should be. So, if it's #1, MPxCommand must be in another library. Seems unlikely.

So, we're left with #2. This could be caused by compiling your code with a different version of the compiler (or a different compiler all together) than the libs were compiled with. If the version of XCode you're using is supported by Alias, it's probably something simple, like a command line switch that's doing name mangling differently. I assume you're including the proper header file for MPxCommand (MPxCommand.h) rather than getting a declaration of the MPxCommand class from somewhere else?

Anyway, this probably doesn't help you much. Hopefully someone else has actually seen this and can tell you what's going on. However, this doesn't seem like a "Maya" issue, but a (probably somewhat common) toolset issue. If there's someone who knows about the XCode toolset that's local and can sit down with you, they may be able to get you going even though they don't know anything about Maya or the API.

Good luck and sorry I couldn't be more helpful.

--- David

sparaig
12-07-2006, 04:44 PM
Okay, we've just about surpassed my ability to figure out what's going on (having never programmed on a Mac before...)

That's OK. I've never programmed on MacOS X before, either. Unix plus objective-c-based GUI. Sheesh.


If you're getting an undefined symbol at link time, it's got to be one of two things:1) not linking the proper library

2) the symbol reference in your code doesn't match the exported symbol in the library (e.g. your code is looking for __ZTI10MPxCommand and the library exports __blahblah10MpxCommand ) I couldn't find any docs on the mangling logic, so other than the fact the 10 refers to the length of the symbol name (MPxCommand), the rest of it is a mystery to me.
As far as I can tell from the output, you're linking the libraries you should be. So, if it's #1, MPxCommand must be in another library. Seems unlikely.

So, we're left with #2. This could be caused by compiling your code with a different version of the compiler (or a different compiler all together) than the libs were compiled with. If the version of XCode you're using is supported by Alias, it's probably something simple, like a command line switch that's doing name mangling differently. I assume you're including the proper header file for MPxCommand (MPxCommand.h) rather than getting a declaration of the MPxCommand class from somewhere else?

Anyway, this probably doesn't help you much. Hopefully someone else has actually seen this and can tell you what's going on. However, this doesn't seem like a "Maya" issue, but a (probably somewhat common) toolset issue. If there's someone who knows about the XCode toolset that's local and can sit down with you, they may be able to get you going even though they don't know anything about Maya or the API.

Good luck and sorry I couldn't be more helpful.

--- David

The devkit docs say something about Mac OS X 10.3. I'm using XCode for X 10.4. Maybe if I drop back...

Will let you know. Thanks for your advice.

JackSMillenium
12-09-2006, 08:40 PM
Ah, I think that's it. Maya 6 is compiled with gcc 3.3 (the default on 10.3 I believe), whereas 10.4 uses gcc4 (as your log shows).

To switch compiler versions, you need to double-click your build target (under the "Targets" in the left column - it probably is the same name as the final plugin); this will open a setting window for that target. Go to the "Rules" tab, and in the "System C rule", say that it should process "C source files" using "GCC 3.3".

I think that should do it...

Of note, if you're on an intel Mac, then you're screwed... only builds for Maya8 are supported.

Good Luck,
Jack.

sparaig
12-10-2006, 06:53 PM
Ah, I think that's it. Maya 6 is compiled with gcc 3.3 (the default on 10.3 I believe), whereas 10.4 uses gcc4 (as your log shows).

To switch compiler versions, you need to double-click your build target (under the "Targets" in the left column - it probably is the same name as the final plugin); this will open a setting window for that target. Go to the "Rules" tab, and in the "System C rule", say that it should process "C source files" using "GCC 3.3".

I think that should do it...

Of note, if you're on an intel Mac, then you're screwed... only builds for Maya8 are supported.

Good Luck,
Jack.

Hmmm... Did that, it compiled OK, then produced a new error. The helloCmd.dylib exists in the products group/folder, but xcode apparently doesn't recognize it as the right dylib.

There are two places where "System C rule" appears, for the C source and for the asmbler files. I get the same error whether I change the first or both to use gcc 3.3:




Building target “helloCmd” of project “helloCmd” with configuration “Development” — (1 error, 1 warning)
[...]
/bin/sh -c /Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.build/Development/helloCmd.build/Script-8A8F789E05E54A880032FA51.sh
cp: /Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.dylib: No such file or directory
cp: /Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.dylib: No such file or directory
Build failed (1 error, 1 warning)

sparaig
12-11-2006, 08:09 AM
Hmmm... Did that, it compiled OK, then produced a new error. The helloCmd.dylib exists in the products group/folder, but xcode apparently doesn't recognize it as the right dylib.

There are two places where "System C rule" appears, for the C source and for the asmbler files. I get the same error whether I change the first or both to use gcc 3.3:




Building target “helloCmd” of project “helloCmd” with configuration “Development” — (1 error, 1 warning)
[...]
/bin/sh -c /Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.build/Development/helloCmd.build/Script-8A8F789E05E54A880032FA51.sh
cp: /Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.dylib: No such file or directory
cp: /Applications/Alias/maya6.0/devkit/plug-ins/build/helloCmd.dylib: No such file or directory
Build failed (1 error, 1 warning)

OK, I sorta figured out how to make it link. I dragged the dynlib file into the main build group window, and lo, it compiles and links, no errors. FOr some reason, it won't copy into the specified plug-in directory, but I can rename it and drag it in manually.

And lo, Maya loads the plugin with no errors, and lo...

nada.

this is the canned code that the plug-in allegedly implements. I type "hello Maya" into the command line, but it doesn't print "Hello Maya" like it is supposed to. It just echos "hello Maya."



[code]
#include <maya/MSimple.h>

// Use a Maya macro to setup a simple hello class
// with methods for initialization, etc.
//
DeclareSimpleCommand( hello, "Alias", "6.0");

// All we need to do is supply the doIt method
// which in this case only prints "Hello" followed
// by the first argument given in the command line.
//
MStatus hello::doIt( const MArgList& args )
{

printf("Hello %s\n", args.asString( 0 ).asChar() );
return MS::kSuccess;
}
[\code]

JackSMillenium
12-12-2006, 05:47 AM
Ah, what "printf" does is print to a shell. I've never quite figured out where that ends up on a Mac (I'm guessing a console log somewhere). On Linux, it's just printed out in the shell you used to launch Maya.

If you want to see the message display in the script editor, you need to do:
#include <maya/MGlobal.h>
MStatus hello::doIt( const MArgList& args )
{
MString msg = MString("Hello ")+args.asString( 0 ).asChar();
MGlobal::displayInfo(msg);
return MS::kSuccess;
}

If displayInfo doesn't work, try displayWarning or displayError (there may be some typos, I haven't actually tested the code).

That's the clean way. For fun, you can always also build a mel command and then execute it:

MString melCmd = MString(" print \"")+args.asString( 0 ).asChar()+MString("\";");
MGlobal::executeCommand(melCmd);

sparaig
12-17-2006, 03:07 PM
Ah, what "printf" does is print to a shell. I've never quite figured out where that ends up on a Mac (I'm guessing a console log somewhere). On Linux, it's just printed out in the shell you used to launch Maya.

If you want to see the message display in the script editor, you need to do:
#include <maya/MGlobal.h>
MStatus hello::doIt( const MArgList& args )
{
MString msg = MString("Hello ")+args.asString( 0 ).asChar();
MGlobal::displayInfo(msg);
return MS::kSuccess;
}

If displayInfo doesn't work, try displayWarning or displayError (there may be some typos, I haven't actually tested the code).

That's the clean way. For fun, you can always also build a mel command and then execute it:

MString melCmd = MString(" print \"")+args.asString( 0 ).asChar()+MString("\";");
MGlobal::executeCommand(melCmd);


Doh. Thanks much. Maybe I CAN start learning the API afterall.

sparaig
12-17-2006, 09:32 PM
Doh. Thanks much. Maybe I CAN start learning the API afterall.

Nope, displayWarning, displayError and creating a mel command didn't work either...

Sigh. Think I'll table the API until I can get a version that everyone is certain will work out-of-the-box with MacOS X. 6.0 apparently isn't it.

I AM learning more about xcode features though...

sparaig
12-17-2006, 11:30 PM
Nope, displayWarning, displayError and creating a mel command didn't work either...

Sigh. Think I'll table the API until I can get a version that everyone is certain will work out-of-the-box with MacOS X. 6.0 apparently isn't it.

I AM learning more about xcode features though...


OMG... I finally figured out the problem. The "hello" command is apparently already used by some other Maya plug-in. I found my arguments to "hello" being echoed to the MacOS X console window, and couldn't change what was echoed until I changed the command from "hello" to "mello."

Now everything works as all the documentation says it should and it all goes to the Maya script edit window, instead of Console.

Sheesh.

Thanks for everyone's help.

CGTalk Moderation
12-17-2006, 11:30 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.