Thank you both (Actually I thought named scripts and un-named scripts behave the same
).
For my compilation issue, you were both right: headers really helps 
(I got confused by my first C tests).
So below’s how to proceed in:
[ul][li]C[/]
[]C++[/]
[]ROOT with ACLiC[/*][/ul]
1. In C
Files (.c files, header useless)
[code]### myextlib.c ###
#include <stdio.h>
int hello()
{
printf (“Hello World!\n”);
return (0) ;
}
importlib.c
int main()
{
hello() ;
return (0) ;
}[/code]
Compilation/Execution (gcc)
gcc -c myextlib.c -o myextlib.o && gcc -shared myextlib.o -o myextlib.dll
gcc -c importlib.c -o importlib.o && gcc -L./ -lmyextlib importlib.o -o importlib.exe
./importlib.exe
2. In C++
Files (.cpp and .hpp files, header compulsory)
[code]### myextlib.hpp ###
#include <stdio.h>
int hello() ;
myextlib.cpp ### // header included
#include "myextlib.hpp"
int hello()
{
printf (“Hello World!\n”);
return (0) ;
}
importlib.cpp ### // header included
#include "myextlib.hpp"
int main()
{
hello() ;
return (0) ;
}[/code]
Compilation/Execution (g++)
g++ -c myextlib.cpp -o myextlib.o && g++ -shared myextlib.o -o myextlib.dll
g++ -c importlib.cpp -o importlib.o && g++ -L./ -lmyextlib importlib.o -o importlib.exe
./importlib.exe
3. In ROOT with ACLiC
Files (.cpp and .hpp files, header compulsory)
[code]### myextlib.hpp ### // same as standard C++
#include <stdio.h>
int hello() ;
myextlib.cpp ### // same as standard C++
#include "myextlib.hpp"
int hello()
{
printf (“Hello World!\n”);
return (0) ;
}
importlib.cpp ### // the function cannot be called main
#include "myextlib.hpp"
int importlib_root()
{
hello() ;
return (0) ;
}[/code]
Compilation/Execution (within ROOT)
[root_01]> .L myextlib.cpp+ /// creates the file myextlib_cpp.dll
[root_02]> gSystem->Load("myextlib_cpp.dll")
[root_03]> .L importlib_root.cpp+
[root_04]> importlib_root()
NB:[ul]
[*]Once the library myextlib_cpp.dll is created you can link it anywhere along with myextlib.hpp
"ln -s $MYLIBDIR/myextlib_cpp.dll ; ln -s $MYLIBDIR/myextlib.hpp"
OR just “ln -s $MYLIBDIR/myextlib.hpp” if you add myextlib_cpp.dll to LD_LIBRARY_PATH.
You will then just need to type commands root_02, root_03 and root_04. [/li]
[li]To avoid loading the library each time you open Root, add it to your rootlogon.C file (that you can also link in the current directory).
You will then just need to type commands root_03 and root_04 (or just “.x importlib_root.cpp+”).[/li]
[li]Of course, no probs in interpreted mode, root_03 and root_04 can be replaced by
".x importlib_root.cpp"[/li]
[li]All the above libraries can be skimmed: strip myextlib[_cpp].dll[/li][/ul]
Voilà,
Feel free to correct me if I’m wrong or if it sounds awkward.
Cheers,
Z