Linking with external library

Dear all,

I’m trying to link cint (and ideally also root) with an external library and/or
object file, so that I can access its functions and/or classes. To make
thinks simple, I have created a very small class “simple” - see the code at
the end of this mail.

My cint installation stems from root (5.08, freshly compiled) and is installed
below /opt/root . I can call both root and cint on the command line and e.g.
execute a printf statement, so presumably the compilation and installation
worked as expected.

I am following the procedure from the makecint man page. However,
already my first attempt fails. I have created an object file from the
source quoted below (which I know works, as I have tried it out with
a corresponding main() function.

I have then called:

makecint -mk Makefile -o mycint -H simple.h simple.o

which responds with

Makefile is created. Makecint success

However, calling “make” just results in the message:
make: *** Keine Regel vorhanden, um das Target »/opt/root//lib/root/cint/main/G__setup.c«,
benötigt von »G__setup.o«, zu erstellen. Schluss.

Which just means that /opt/root//lib/root/cint/main/G__setup.c
does not exist. There is indeed no such file below /opt/root .

I have then tried to only install cint 5.16 (excluding root), both using
platform/gcc_max and platform/linux_RH7.3_so, which failed
with differing error messages.

This is on a SuSE 10.0 Linux system, gcc 4.02, kernel 2.6.13 .

It would be sufficient for my purpose if I could just load a
shared library - no static linkage would be necessary. To be
concrete, I want to have access to the “ncurses” library from
inside cint/root . Ideally I would not want to modify the ncurses
source code in any way.

Thanks for any help,
Ruediger Berlich

/************ simple.C ***************/

#include “simple.h”

simple::simple()
{
writeHello();
}

simple::~simple(){}

void simple::writeHello()
{
cout << “Hello World” << endl;
}

/************ simple.h ***************/

#include

#ifndef _SIMPLE_H
#define _SIMPLE_H

using namespace std;

class simple
{
public:
simple(void);
~simple();

private:
void writeHello(void);
};

#endif /* _SIMPLE_H */

/****** MAKEFINFO from root installation **************/

CC = gcc
CPP = g++
CPREP = gcc -E -C
CPPPREP = g++ -E -C

CSRCPOST = .c
CHDRPOST = .h
CPPSRCPOST = .C
CPPHDRPOST = .h
OBJPOST = .o
DLLPOST = .so

Hi there,
here is an update to my problem. I have now succeeded in accessing
the “simple” class from within root (however, see below). This was done
pretty much as described in
hep.phy.uct.ac.za/root_tree/CintGenerator.html :

ruediger@euridike> ./myroot
[…]
root [0] simple Simple;
Hello World

Fine. Now I’m trying to link the ncurses library with root, pretty much
in the same way. I fail when running rootcint on the header file:

“rootcint mydict.C -c /usr/include/ncurses.h” gives me lots of errors:

Error: Symbol __BEGIN_DECLS#include is not defined in current scope /usr/include/sys/types.h:35:
Error: Symbol bits is not defined in current scope /usr/include/sys/types.h:35:
Error: Symbol types is not defined in current scope /usr/include/sys/types.h:35:
Error: Failed to evaluate types.hError: operator ‘/’ divided by zero /usr/include/sys/types.h:35:
Error: Symbol #ifdef__USE_BSD#ifndef__u_char_definedtypedef__u_charu_char is not defined in current scope /usr/include/sys/types.h:35:
Error: class,struct,union or type __u_short not defined /usr/include/sys/types.h:36:

and so on.
I have then tried to add the switch “-p”, which gives me:

rootcint mydict.C -c -p /usr/include/ncurses.h
Error: link requested for unknown class ncurses G__auto17498LinkDef.h:7:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing mydict.C mydict.h !!!
Error: rootcint: error loading headers…

Any clue ?

By the way, in the “simple” example above, I am not linking to all
root libraries. I am just using the following:

-L/usr/X11R6/lib/ -L$(ROOTSYS)/lib/root -lXpm -lX11 -lm -lGpad -lGraf -lGraf3d -lHist -lMatrix -lRint -lCore -lCint -ldl -lc -lm -lz

This creates the executable without errors. However I am not sure whether, by leaving out some of the libraries in the ROOT lib directory,
I’m missing any functionality.

In any case thanks for your help!

Best Regards,
Ruediger Berlich

Hi,

In general when creting library for ROOT always using rootcint instead of makeinct:

[quote]rootcint mydict.C -c -p /usr/include/ncurses.h
Error: link requested for unknown class ncurses G__auto17498LinkDef.h:7:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing mydict.C mydict.h !!!
Error: rootcint: error loading headers…
[/quote]This is the expected behavior. If you do not provide a linkdef file, rootcint will attempt to generate the dictionary for a class with the same name as the header file. So you need to provide a linkdef file (see User’s Guide) listing of the function that you want to provide a dictionary for.

Cheers,
Philippe.

Hi there,

JFYI: as this discussion has moved from cint to rootcint, and I found
a solution, I have shifted my further posts to the ROOT support
list.

Thanks for all the help!

Best Regards,
Ruediger