English 中文(简体)
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..

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.

问题回答

暂无回答




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签