views:

85

answers:

3

I'm maintaining a library that contains compiled objects that need to be linked into a 3rd party executable. sometimes the executable has been compiled for Solaris, sometimes as a 32bit Linux Application, sometimes its a 64bit linux application. What I'd love to do is pass one "path" to the library, and have the application then automatically pick up the right flavor of the library. It'd be OK if it only worked on linux, so that I could just define the path in terms of the OS.

this particular case is for a library of PLI/VPI functions I want to link into a verilog simulator.

What I have now is

root/path/${MYPLILIB_VER}/rootname/${MYPLIFLAVOR}/plilib.so

where flavor is one of

solaris linux linux64

The flavor depends on the os, and if Linux, if running on a 64bit platform, it also depends on which version 32/64bit of the program I am running. I'm looking for a better way..

+1  A: 

Use the system info given from "uname" to set the paths automatically?
'uname -s' gives you the kernel name (eg Linux / SunOS)
'uname -i' will give you the architecture (eg x86 / x86_64)

Marty
the architecture is NOT enough... if the app is a 32bit app running on a 64bit arch, this would link to the 64 bit .so, when I need the 32bit one!!-- I'm pretty much using the first thing now, and I'd love to get away from THAT if I can..
jbdavid
+1  A: 

Hm.. its looking like ELF might do what I want.. now for some good application notes..

and on the LAST page of this paper on making DSO's is some info on the $PLATFORM and $LIB expectations.. seems like on linux I should be able to use the lib lib64 directory structure to hold the two objects..

off to learn more.

shared objects for the disoriented

jbdavid
A: 

I don't know which simulator you are using but you might try putting the path in the LD_LIBRARY_PATH environment variable. I believe both Cadence and Mentor simulators will look in there. I'm not sure abut VCS. Your simulator's user manual will have details.

Steve K
This is EXACTLY the (as I understand it) bad advice taught by clueless Cadence AE's (I was one of those in a former life) for how to solve this issue. LD_LIBRARY_PATH was always a HACK to be used for a specific program, should not be set generally on the users shell. Cadence finally wised up and now their "executable" is a wrapper that sets the the LD_LIBRARY_PATH for their tool only. In general I should be able to point the tool at the shared library directory and each program should be able to pick the version of the library it needs.
jbdavid