Error: Bad source file(binary)

Hi,

I wrote a small class to get data from a mysql database. I generated a dictionary with rootcint:

rootcint -f SqlRootDict.cxx -c SqlRoot.h LinkDef.h

The g++ compiles my class SqlRoot without any error so I guess it is not a syntax error.
I made something wrong during the dictionary generating.

  1. I put the

class TSQLServer;
class TSQLResult;
class TSQLRow;
class TH1F;

into the header file and the

ClassDef (SqlRoot, 1)

before the “};” i.e. the end of my class header.

  1. I put the

ClassImp(SqlRoot)

line into the source SqlRoot.cxx after the #include statements

  1. Then I compiled the SqlRoot.cxx and SqlRootDict.cxx with g++ and tried to load my
    class in the Cint:

root [0] .L SqlRoot.o
Error: Bad source file(binary) /home/radbal/Chandra/src/chandra/./SqlRoot.o FILE:SqlRoot.o LINE:1
*** Interpreter error recovered ***

So I don’t know what my error was. Please help!:slight_smile:

Cheers,

Balint
SqlRoot.h (750 Bytes)
SqlRoot.cxx (4.04 KB)

You must create a SqlRoot.so file with your SqlRoot.o and SqlRootDict.o
then do
root > .L SqlRoot.so

Rene

I did it. Now it says:

[radbal@eagle chandra]$ g++ -shared SqlRoot.o SqlRootDict.o -o SqlRoot.so
[radbal@eagle chandra]$ root -l
root [0] .L SqlRoot.so
dlopen error: /home/radbal/Chandra/src/chandra/./SqlRoot.so: undefined symbol: _ZN10TSQLServer5QueryEPKc
Load Error: Failed to load Dynamic link library /home/radbal/Chandra/src/chandra/./SqlRoot.so
*** Interpreter error recovered ***

There is something wrong with the TSQLServer ? Or I don’t know…

Balint

What is your implementation of the QLSserver? Did you load the
corresponding library?

Rene

I have

mysql Ver 12.22 Distrib 4.0.24, for pc-linux-gnu (i686)

I use ROOT 4.00/06 on RedHat 9.

I did:

g++ -shared SqlRoot.o SqlRootDict.o $(root-config --libs) -lMySQL -o SqlRoot.so

root [0] .L SqlRoot.so
dlopen error: /home/radbal/Chandra/src/chandra/./SqlRoot.so: undefined symbol: _ZN10TSQLServer5QueryEPKc
Load Error: Failed to load Dynamic link library /home/radbal/Chandra/src/chandra/./SqlRoot.so
*** Interpreter error recovered ***

Balint

You must load the mySQL.so library before your library
root > .L mySQL.so
root > .L SqlRoot.so

Rene

No, it doesn’t work:

root [1] .L /usr/local/src/root/lib/libMySQL.so
root [2] .L /home/radbal/Chandra/src/chandra/SqlRoot.so
dlopen error: /home/radbal/Chandra/src/chandra/SqlRoot.so: undefined symbol: _ZN10TSQLServer5QueryEPKc
Load Error: Failed to load Dynamic link library /home/radbal/Chandra/src/chandra/SqlRoot.so
*** Interpreter error recovered ***

Or

root [0] gSystem->Load(“libMySQL.so”);
root [1] gSystem->Load(“SqlRoot.so”);
dlopen error: /home/radbal/Chandra/src/chandra/./SqlRoot.so: undefined symbol: _ZN10TSQLServer5QueryEPKc
Load Error: Failed to load Dynamic link library /home/radbal/Chandra/src/chandra/./SqlRoot.so
*** Interpreter error recovered ***

Balint

But everyting works if I use only script:

root [1] .L SqlRoot.C
root [2] SqlRoot * sql = new SqlRoot(“mysql://eagle.phys.klte.hu:3306/astro”,"$
root [3] sql->Getdxdy_subhisto(“4000”,“4002”,“4000”,“4002”,1000,6000);
select * from casa_4634 where x=4000 and y=4000
select * from casa_4634 where x=4000 and y=4001
select * from casa_4634 where x=4000 and y=4002
select * from casa_4634 where x=4001 and y=4000
select * from casa_4634 where x=4001 and y=4001
select * from casa_4634 where x=4001 and y=4002
select * from casa_4634 where x=4002 and y=4000
select * from casa_4634 where x=4002 and y=4001
select * from casa_4634 where x=4002 and y=4002
root [4] .ls
TROOT* Rint The ROOT of EVERYTHING
OBJ: TH1F h1 histogram : 0 at: 0x8d88210
root [5]

Balint

OK, it works. I found the bug. In the source of the SqlRoot.cxx I called the TSQLServer, TSQLResult and TSQLRow member functions as e.g.:

Let’s say that we have a TSQLRow * row, then

field = row->TSQLRow::GetField(3);

So I used the “::” to show that it is the member function of the corresponding class.
It is a bit strange though that it generates any error message. The version that doesn’t generates error:

field = row->GetField(3);

Strange to me.

Balint