On Tue, Sep 14, 2010 at 02:06:07PM -0700, Peter Taps wrote: > Folks, > > I am getting an unresolved external when trying to create a shared library. I > would appreciate it if someone can help me identify the problem. > > Here is my simplified main.cpp program: > > #include <libzfs.h> > > int main() { > libzfs_init(); > return 0; > } > > When I compile this program to create a standard executable, there are no > link errors: > $ g++ -lzfs -o main main.cpp > > Note: For clarity, I have removed a couple of include parameters. > > In my case, I need to create a shared library. Here is the command I am using: > > $ g++ -lzfs -o main.so main.cpp -shared > > However, now I get an unresolved error for "libzfs_init." > > If I add any std templates such as string, vector, I get a bunch more errors. > > Can someone please tell me how to fix it? It must be some simple switch on > the linker.
Generally, you must include libraries *after* the objects which reference them. Try: $ g++ -shared -o main.so main.cpp -lzfs Cheers, - jonathan _______________________________________________ opensolaris-code mailing list opensolaris-code@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/opensolaris-code