# Cling repl syntax to add libraries & compilation flags?

**URL:** <https://root-forum.cern.ch/t/cling-repl-syntax-to-add-libraries-compilation-flags/31826>\
**Category:** Newbie\
**Created:** [November 29, 2018, 6:17pm UTC](https://root-forum.cern.ch/t/cling-repl-syntax-to-add-libraries-compilation-flags/31826 "2018-11-29T18:17:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![forrest](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/forrest/32/17552_2.png) [@forrest](https://root-forum.cern.ch/u/forrest)\
**Post date:** [November 29, 2018, 6:17pm UTC](https://root-forum.cern.ch/t/cling-repl-syntax-to-add-libraries-compilation-flags/31826/1 "2018-11-29T18:17:20Z")

</div>

I’m merely using cling as a c++ coding tool (on Ubuntu 18)… but I’m not finding a way to feed it .a or .so libraries.  
[Yes, I’ve looked – but so far have not found this sufficiently clearly laid out. Example?]

?

---

<div class="post-metadata">

**Author:** ![forrest](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/forrest/32/17552_2.png) [@forrest](https://root-forum.cern.ch/u/forrest)\
**Post date:** [November 29, 2018, 7:08pm UTC](https://root-forum.cern.ch/t/cling-repl-syntax-to-add-libraries-compilation-flags/31826/2 "2018-11-29T19:08:42Z")

</div>

whereis libfltk  
gives me:  
libfltk: /usr/lib/x86\_64-linux-gnu/libfltk.a /usr/lib/x86\_64-linux-gnu/libfltk.so  
and whereis libX11  
libX11: /usr/lib/x86\_64-linux-gnu/libX11.so /usr/lib/x86\_64-linux-gnu/libX11.a  
.L works on the .so versions but not the .a libraries.  
If I try to run a perfectly good example program:  
#include \<FL/Fl.H\>  
#include \<FL/Fl\_Window.H\>  
#include \<FL/Fl\_Box.H\>  
int main(int argc, char \*\*argv) {  
Fl\_Window \*window = new Fl\_Window(300,180);  
Fl\_Box \*box = new Fl\_Box(20,40,260,100,“Hello, World!”);  
box-\>box(FL\_UP\_BOX);  
box-\>labelsize(36);  
box-\>labelfont(FL\_BOLD+FL\_ITALIC);  
box-\>labeltype(FL\_SHADOW\_LABEL);  
window-\>end();  
window-\>show(argc, argv);  
return Fl::run();  
}  
Okay – If I only .L the .so libraries, cling remains happy.  
If I then enter the program line by line  
there’s no response.

Ah? I’ll need to define the program as a function  
& then run the function?  
[These no-brainer things can be bewildering without clear examples!]

---

<div class="post-metadata">

**Author:** ![forrest](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/forrest/32/17552_2.png) [@forrest](https://root-forum.cern.ch/u/forrest)\
**Post date:** [November 29, 2018, 10:37pm UTC](https://root-forum.cern.ch/t/cling-repl-syntax-to-add-libraries-compilation-flags/31826/3 "2018-11-29T22:37:01Z")

</div>

Okay okay:  
[cling]$ int y;  
[cling]$ .L /usr/lib/x86\_64-linux-gnu/libfltk.so  
[cling]$ .L /usr/lib/x86\_64-linux-gnu/libX11.so  
[cling]$ #include \<FL/Fl.H\>  
[cling]$ #include \<FL/Fl\_Window.H\>  
[cling]$ #include \<FL/Fl\_Box.H\>  
[cling]$ int furr() {  
[cling]$ ? Fl\_Window \*window = new Fl\_Window(300,180);  
[cling]$ ? Fl\_Box \*box = new Fl\_Box(20,40,260,100,“Hello, World!”);  
[cling]$ ? box-\>box(FL\_UP\_BOX);  
[cling]$ ? box-\>labelsize(36);  
[cling]$ ? box-\>labelfont(FL\_BOLD+FL\_ITALIC);  
[cling]$ ? box-\>labeltype(FL\_SHADOW\_LABEL);  
[cling]$ ? window-\>end();  
[cling]$ ? window-\>show();  
[cling]$ ? return Fl::run();  
[cling]$ ? }  
[cling]$ y = furr();

Works!  
[There are different forms of fltk “window-\>show()” depending on whether or not we want it to take arguments from the command line.]
