Making dynamic libraries

I’m migrating from windows over to linux and I’m having trouble making dynamic libraries (along with many other things…).

I am trying:

g++ -c -fPIC -Wno-long-long -I/usr/include/root ./Vehicle/LVehicle.cpp

followed by:

ld -shared -soname libVehicle.so.1 -o libVehicle.so.1.0 -lc LVehicle.o

I then move this into the proper directory and link it to libVehicle.so by:

ln -sf libVehicle.so.1.0 libVehicle.so

When I try to load the library in root I get the following:

root [0] gSystem->Load(“libVehicle”)
dlopen error: /home/clkunz/root_work/src_dev/dlls/./libVehicle.so: undefined sym
bol: _ZN8LVehicle11ShowMembersER16TMemberInspectorPc
Load Error: Failed to load Dynamic link library /home/clkunz/root_work/src_dev/d
lls/./libVehicle.so
(int)(-1)
*** Interpreter error recovered ***
root [1] .q

I think I’m missing something simple. Help!

Thanks,
Chris

Hi,

[quote]dlopen error: /home/clkunz/root_work/src_dev/dlls/./libVehicle.so: undefined sym
bol: _ZN8LVehicle11ShowMembersER16TMemberInspectorPc [/quote]
You are missing the dictionary for your class ‘Vehicle’ (i.e. you need to run rootcint, compile the result and include it in your library).

Instead of ld -shared -soname libVehicle.so.1 -o libVehicle.so.1.0 -lc LVehicle.o Use g++ -shared -soname libVehicle.so.1 -o libVehicle.so.1.0 -lc LVehicle.o This is because ld is not C++ aware will not properly setup the global object initialization.

Cheers,
Philippe.