Hi,
I am having a problem loading my own shared library into root. The library is built containing one simple class called DSQLWrap. I have provided the header and cpp file - it’s just a class which inherits from TMySQLServer - all very simple. I use rootcint to generate a root dictionary which is compiled into a shared library. But this shared library fails to load in root.
===FILE DSQLWrap.cpp===
#include “DSQLWrap.h”
using namespace std;
DSQLWrap::DSQLWrap(string dbname, string username, string passwd):TMySQLServer(dbname.c_str(), username.c_str(), passwd.c_str()){
}
DSQLWrap::~DSQLWrap(){}
===FILE DSQLWrap.h===
#ifndef DSQLWRAP
#include <TMySQLServer.h>
class DSQLWrap : public TMySQLServer{
public:
DSQLWrap(std::string dbname, std::string username, std::string passwd);
~DSQLWrap();
private:
ClassDef(DSQLWrap,1);
};
#endif
I also have a linkdef file which looks like this:
#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclass;
#pragma link C++ nestedtypedef;
#pragma link C++ class DSQLWrap+;
#endif
The library (both a static and shared one) compile successfully:
g++ -E -M -Wall -g -fPIC -O3 -I…/common/include -Iinclude -I. -pthread -m64 -I/usr/local/include/root -I/usr/include/mysql -g -pipe -m64 src/DSQLWrap.cpp | perl -pe ‘s/(^[^\s])/‘out’/$1/’ > out/.depend
g++ -o out/DSQLWrap.o -c -Wall -g -fPIC -O3 -I…/common/include -Iinclude -I. -pthread -m64 -I/usr/local/include/root -I/usr/include/mysql -g -pipe -m64 src/DSQLWrap.cpp
/home/coganp/software/root/bin/rootcint -v -f out/root_dict.cpp -c -p -I…/common/include -Iinclude -I. -D__extension__="" -D__attribute__\(X\)="" -D__const=const -D__restrict="" -D__signed=signed -D__volatile=volatile -D__BEGIN_DECLS= -D__END_DECLS= -D__THROW= include/DSQLWrap.h include/LinkDef.h
:11:14: warning: ISO C requires whitespace after the macro name
g++ -Wall -g -fPIC -O3 -I…/common/include -Iinclude -I. -pthread -m64 -I/usr/local/include/root -I/usr/include/mysql -g -pipe -m64 -c -o out/root_dict.o out/root_dict.cpp
ar r lib/libDSLcommon.a out/DSQLWrap.o out/root_dict.o
ar: creating lib/libDSLcommon.a
ranlib lib/libDSLcommon.a
g++ -shared -Wl,-s -o lib/libDSLshared.so out/DSQLWrap.o out/root_dict.o
When I launch root, I do the following:
[coganp@pcp177897pcs common]$ root
root [0] gSystem->Load(“lib/libDSLshared.so”)
dlopen error: /home/coganp/software/dsl/common/./lib/libDSLshared.so: undefined symbol: _ZN12TMySQLServer5CloseEPKc
Load Error: Failed to load Dynamic link library /home/coganp/software/dsl/common/./lib/libDSLshared.so
(int)(-1)
*** Interpreter error recovered ***
root [1]
ROOT and system details as follows:
root: 5.22/00
system: Red Hat Enterprise Version 4
gcc -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.3/specs
Configured with: …/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,java,f77 --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
many thanks!!