compiling c++ functions file into shared libary

I have a file of functions written in C++ that I like to compile into a
shared library for other C++ code to use. I using Metrowerks Codewarrior and
I’m able to compile to a shared lib just fine. The problem is when I try to
open the libary in another file using ‘dlopen’, I immediately get a
Segmentation error. Can someone tell me how to complile this from the
command line perhaps?

Chris Rose wrote:

I have a file of functions written in C++ that I like to compile into a
shared library for other C++ code to use. I using Metrowerks Codewarrior and
I’m able to compile to a shared lib just fine. The problem is when I try to
open the libary in another file using ‘dlopen’, I immediately get a
Segmentation error. Can someone tell me how to complile this from the
command line perhaps?

Your problem is most likely that something somewhere is not compiled
with -fPIC (everything that your shared lib brings in with it must be
-fPIC). Your second problem will come when you try to do a dlsym() on
the symbol, as the symbols in the dll will be mangled. You can resolve
this issue (perhaps you already have) by forcing the linkage to “C”.

Rennie Allen