开发者

Linking a Maya client library to libOpenMayalib.a fails, MLibrary::initialize can't be found (even though nm shows libOpenMayalib.a contains it)

I'm trying to link my app with the Maya C++ API, but i get:

Debug/../src/main.cpp:80: undefined reference to `MLibrary::initialize(bool, char*, bool)'

but, nm shows:

nm libOpenMayalib.a | grep initialize
00000000000004b0 T _ZN8MLibrary10initializeEPcb
0000000000000380 T _ZN8MLibrary10initializeEbPcb
0000000000000000 b _ZZN8MLibrary10initializeEbPcbE13isInitialized

which seems to match MLibrary::initialize, that looks like:

class OPENMAYA_EXPORT MLibrary
{
public:
      MLibrary ();
 virtual    ~MLibrary ();
 static MStatus  initialize (char* applicationName,
         bool viewLicense = false);
 static MStatus  initialize (bool wantScriptOutput,
         char* applicationName,
         bool viewLicense = false);
 static void   cleanup( int exitStatus = 0 );

protected:
// No protected members

private:
// No private members

};

The linking process is run with:

g++ -L/usr/autodesk/maya2009-x64/lib -m64 -pthread -Wl,-rpath,/usr/autodesk/maya2009-x64/lib -lOpenMayalib  -l3dGraphics -lAG -lAnimEngine -lAnimSlice -lAnimUISlice -lAppVersion -lAshliFX -lAshli -lAutoCam -lawCacheShared -lawnSolver -lawxml2 -lBase -lCgGL -lCg -lCloth -lCommandEngine -lcxaguard -lDataModel -lDebug -lDeformSlice -lDeformUISlice -lDependCommand -lDependEngine -lDevices -lDynSlice -lDynUISlice -lExplorerSlice -lExtensionLayer -lfbxfilesdk -lFoundation -lgcc_s -lGeometryEngine -lguide -lhairlib -lHalf -lHumanIKShared -lHWFoundation -lHWGL -lHWRenderMaya -lHWRender -lIex -liff -lIlmImf -lImage -lImageUI -lImath -lIMFbase -limf -lirc -lJasperSlice -lKinSlice -lKinUISlice -lManips -lMaya -lmocap -lModelSlice -lModelUISlice -lModifiers -lMotionCapture -lNurbsEngine -lNurbsSlice -lNurbs -lNurbsUISlice -lOpenMayaAnim -lOpenMayaFX -lOpenMayaRender -lOpenMaya -lOpenMayaUI -lPolyEngine -lPolySlice -lPoly -lPolyUISlice -lProjectSlice -lPsdTexture -lpython2.5 -lRenderModel -lRenderSlice -lRenderUISlice -lShared -lSharedUI -lstdc++ -lstdc++ -lSubdivEngine -lSubdivGeom -lSubdiv -lSubdivUI -lsvml -ltbbmalloc -ltbb -lTranslators -lUIComponents -lUrchinSlice -lUrchinUISlice -lXm -lzlib -o"BinaryGL3MdlMayaExporter"  ./src/Exporter.o ./src/Format.o ./src/Generic.o ./src/Output.o ./src/main.o   -lm -lgtk-x11-2.0 -ldl -lpthread -lgdk-x11-2.0

The system is Ubuntu Maverick 10.10, 64-bit, and Maya is 64-bit as well, and compiling with -m64 gives the same result.

I found a similar post http://area.autodesk.com/forum/autodesk-maya/sdk/link-errors-when-using-the-openmaya-api-on-linux/ i took some ideas from his file, like using the -Wl,-rpath, but, that doesn't change anything.开发者_如何学JAVA.

I also tried installing g++-4.1 as it seems to be the one mentioned in the scripts, but that didn't change anything either (current version is g++-4.4)

Thanks in regards //Johan


The problem is the way you call MLibrary::initialize.

It expects a non-const char string, which is probably fed with a literal char string that is implicitly constant.

What you call is something like lib.initialize(false, "my app", false) which equals MLibrary::initialize(bool, const char*, bool) - this signature is indeed not exported by MLibrary.

What you have to do to make it work is to use a non-const application name, for example:

// char* appName = "my app"; would be deprecated as string literals are always const
char appName[] = {'m','y',' ','a','p','p'};
lib.initialize(false, appName, false);

Note: This is an interface bug as the application name should indeed be fed as a const char* - this bug is fixed in later maya versions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜