# How to use my own library like default ones?

**URL:** <https://root-forum.cern.ch/t/how-to-use-my-own-library-like-default-ones/16773>\
**Category:** ROOT\
**Created:** [October 20, 2013, 3:41pm UTC](https://root-forum.cern.ch/t/how-to-use-my-own-library-like-default-ones/16773 "2013-10-20T15:41:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yjc](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/b77776/32.png) [@yjc](https://root-forum.cern.ch/u/yjc)\
**Post date:** [October 20, 2013, 3:41pm UTC](https://root-forum.cern.ch/t/how-to-use-my-own-library-like-default-ones/16773/1 "2013-10-20T15:41:13Z")

</div>

hi,

I code a class(comp3exts.h,comp3exts.C) which is needed by some different programs. So, thanks for pepe’s example [url][Trying to compile rootcint dictionary with namespaces](https://root-forum.cern.ch/t/trying-to-compile-rootcint-dictionary-with-namespaces/14562/1) I could compile libcomp3exts.so

And I could use it, without #include “comp3exts.h”, as

`.L libcomp3exts.so
.x mycode.cxx`.

But, I would like to use libcomp3exts.so like the default ones , such as TH1, or TF1.

I add #include “comp3exts.h” into mycode.cxx, without `.L libcomp3exts.so` before `.x mycode.cxx`, mycode.cxx does not work properly and shows [quote]Error: comp3exts() declared but not defined [/quote]

I copied comp3exts.h and comp3exts.C to …/root/include/ and libcomp3exts.so to …/root/lib/, unfortunately, this did not work neither.

Then I run “make -f Makefile”, thanks for kalliopi’s post [url][Makefile compile time difference between slc5 and 6](https://root-forum.cern.ch/t/makefile-compile-time-difference-between-slc5-and-6/16564/1) this time I got a bigger libcomp3exts.so. But it acts the same as the previouse one.

After that , I tried to make …/root/test/Makefile, but it seems some libraries are missing

[quote]…/root/test/…/lib/libNet.so: undefined reference to `EVP_sha1' ...//root/test/../lib/libNet.so: undefined reference to`SSL\_CTX\_new’  
…/root/test/…/lib/libNet.so: undefined reference to `SSL_set_fd' .../root/test/../lib/libNet.so: undefined reference to`SSL\_CTX\_use\_certificate\_chain\_file’  
…/root/test/…/lib/libNet.so: undefined reference to `SSL\_shutdown’[/quote]

I also found something here [http://root.cern.ch/drupal/content/interacting-shared-libraries-rootcint](http://root.cern.ch/drupal/content/interacting-shared-libraries-rootcint). There are some words [quote]Of course you will need to add the include path for ROOT, and you might have to link against ROOT’s libraries libCore libCint.[/quote] I am not sure, but it seems I need to do somethings about libCore and libCint(makefile??) in order to use my class as the default library.

I hope someone could tell me how to solve this or give me some hints.

comp3exts.h, LinkDef.h, small Makefile have been uploaded.

Thanks for your help.  
yjc

[comp3exts.h](https://root-forum.cern.ch/uploads/default/original/2X/2/2966e099d062d5da3803f7bcc9e36bfaa60711c7.h) (758 Bytes)  
[LinkDef.h](https://root-forum.cern.ch/uploads/default/original/2X/3/3196b21becce987e0657a99966964d1691029e4e.h) (151 Bytes)

[code]  
##Makefile  
SOURCES = comp3exts.C  
HEADERS = comp3exts.h  
FLAGS = -O -Wall -fPIC `root-config --cflags` `root-config --ldflags`  
GLIBS = `root-config --glibs`  
INC = -I`root-config --incdir`

# suffix rule

.cc.o:  
g++ -c (CXXFLAGS) (GDBFLAGS) $\<

# define the final target

all: libcomp3exts.so

comp3exts\_dict.C: (HEADERS) LinkDef.h rootcint -f @ -c -g $^

libcomp3exts.so: comp3exts\_dict.C (SOURCES) g++ -shared -o @ (FLAGS) (GLIBS) -g (INC) ^

clean:  
rm _\_dict._[/code]
