Hello, CIL world:
I recently intend to store the parsing results by CIL into a database for the convenience that another c program can use these parsing results by visiting this database.
So i compiled a open-source ocaml-sqlite library and installed the corresponding library file into the default ocaml library directory : /usr/lib/ocaml (ubuntu)
 
I configured the Makefile.in (add sqlite3 library)
    CILLY_LIBS = unix str nums sqlite3
 
I wrote a module referencing this Sqlite3 module and add its feature into Makefile.in and src/main.ml.
 
I compiled CIL (the following is log )
         ...
--Compiling     src/main.ml to bytecode 
--Linking bytecode obj/x86_LINUX/cilly.byte.exe 
+ gcc -o 'obj/x86_LINUX/cilly.byte.exe'   '-L/usr/lib/ocaml' -g '/tmp/camlobj59f6be.c' '-lsqlite3' '-lnums' '-lcamlstr' '-lunix' '-lcamlrun' -I'/usr/lib/ocaml' -lm  -ldl -lcurses -lpthread
--make cilly NATIVECAML= 
    ...
The byte code of CIL is OK, and i get the cilly.byte.exe.
 
But, when compiling its native code, it ran into the following error:
 
Compiling           src/main.ml to native code 
Linking native code obj/x86_LINUX/cilly.asm.exe 
+ as -o '/tmp/camlstartupcf4ec7.o' '/tmp/camlstartupf60dcc.s'
+ gcc -o 'obj/x86_LINUX/cilly.asm.exe'   '-L/usr/lib/ocaml'  
.....
'/usr/lib/ocaml/sqlite3.a' '/usr/lib/ocaml/nums.a' '/usr/lib/ocaml/str.a' '/usr/lib/ocaml/unix.a' '/usr/lib/ocaml/stdlib.a' '-lsqlite3' '-lnums' '-lcamlstr' '-lunix' '/usr/lib/ocaml/libasmrun.a' -lm  -ldl
/usr/lib/ocaml/libsqlite3.a(sqlite3.o): In function `pthreadMutexAlloc':
sqlite3.c:(.text+0x3df4): undefined reference to `pthread_mutexattr_init'
sqlite3.c:(.text+0x3e07): undefined reference to `pthread_mutexattr_settype'
sqlite3.c:(.text+0x3e24): undefined reference to `pthread_mutexattr_destroy'
/usr/lib/ocaml/libsqlite3.a(sqlite3.o): In function `pthreadMutexTry':
sqlite3.c:(.text+0x3ef8): undefined reference to `pthread_mutex_trylock'
collect2: ld returned 1 exit status
File "caml_startup", line 1, characters 0-1:
Error: Error during linking
make[1]: *** [obj/x86_LINUX/cilly.asm.exe] Error 2
 
From the log, it seems that when compiling its asm code, it failed to link "pthread" library.
Q: 
So how to configure CIL by adding this link (by modifying "Makefile.in" ? I am not familiar with this Makefile :(  )
Or, how can i prevent CIL from compiling its native code ?
 
Any help is appreciated.
 
Best Regards!

Ting SU,software institute,East China Normal University
Ph.D student
tsuletgo@gmail.com (Email,MSN)