pdhborges/ocaml-zmq — Issue #3: Compilation issue
Author: musically-ut
Created: 2011-10-18 13:25:32+00:00
State: open

Hi,

I am relatively new to the ocaml, and had some trouble compiling the bindings. To successfully compile the program, I had to change the **ocamlbuildflags** setting in _setup.data_ file to:

ocamlbuildflags = "-lflag '-thread'"

Otherwise, the compilation failed with the following error:

...
+ ocamlfind ocamlopt -g -I src -linkpkg -package uint.uint64 -package oUnit src/ZMQB.cmxa test/zmq_test.cmx test/test.cmx -o test/test.native
/lib/librt.so.1: undefined reference to `__pthread_unwind@GLIBC_PRIVATE'
/lib/librt.so.1: undefined reference to `pthread_barrier_init@GLIBC_2.2'
/usr/local/lib/libzmq.so: undefined reference to `pthread_sigmask@GLIBC_2.0'
/lib/librt.so.1: undefined reference to `pthread_attr_setstacksize@GLIBC_2.1'
/lib/librt.so.1: undefined reference to `pthread_barrier_wait@GLIBC_2.2'
collect2: ld returned 1 exit status
File "caml_startup", line 1, characters 0-1:
Error: Error during linking
Command exited with code 2.
Compilation unsuccessful after building 27 targets (0 cached) in 00:00:01.
E: Command '/usr/local/bin/ocamlbuild src/libZMQB.a src/dllZMQB.so src/ZMQB.cma src/ZMQB.cmxa src/ZMQB.a test/test.native -tag debug' terminated with error code 10

Just wondering whether there was an easier way of doing it or whether this dependency could be checked during the configuration stage?

Thanks.

~
Ut.

The complete output is here:

$ ocaml setup.ml -all
I: Running configure step
I: Running command '/usr/local/bin/ocamlc.opt -config > '/tmp/oasis-f0e9cc.txt''

Configuration:

pkg_ounit: ..................................... /usr/local/lib/ocaml/site-lib/oUnit
pkg_uint_uint64: ............................... /usr/local/lib/ocaml/site-lib/uint
Build and run tests: ........................... true
OCamlbuild additional flags: ...................
Compile with ocaml profile flag on.: ........... false
Compile with ocaml debug flag on.: ............. true
Remove a directory.: ........................... rm -rf
Remove a file.: ................................ rm -f
suffix_program: ................................
is_native: ..................................... true
findlib_version: ............................... 1.2.7
PS documentation: .............................. $docdir
PDF documentation: ............................. $docdir
DVI documentation: ............................. $docdir
HTML documentation: ............................ $docdir
Documentation root: ............................ $datarootdir/doc/$pkg_name
Man documentation: ............................. $datarootdir/man
Locale-dependent data: ......................... $datarootdir/locale
Info documentation: ............................ $datarootdir/info
Read-only architecture-independent data: ....... $datarootdir
Read-only arch-independent data root: .......... $prefix/share
Object code libraries: ......................... $exec_prefix/lib
Modifiable single-machine data: ................ $prefix/var
Modifiable architecture-independent data: ...... $prefix/com
Read-only single-machine data: ................. $prefix/etc
Program executables: ........................... $exec_prefix/libexec
System admin executables: ...................... $exec_prefix/sbin
User executables: .............................. $exec_prefix/bin
Install architecture-dependent files in dir: ... $prefix
Install architecture-independent files dir: .... /usr/local
systhread_supported: ........................... true
default_executable_name: ....................... a.out
ext_dll: ....................................... .so
ext_lib: ....................................... .a
ext_asm: ....................................... .s
ext_obj: ....................................... .o
model: ......................................... default
native_c_compiler: ............................. gcc -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
bytecomp_c_compiler: ........................... gcc -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -fPIC
standard_runtime: .............................. /usr/local/bin/ocamlrun
standard_library: .............................. /usr/local/lib/ocaml
standard_library_default: ...................... /usr/local/lib/ocaml
ocaml_version: ................................. 3.12.1
ccomp_type: .................................... cc
architecture: .................................. i386
system: ........................................ linux_elf
os_type: ....................................... Unix
Package version: ............................... 0.0.3
Package name: .................................. ZMQ
ocamlbuild: .................................... /usr/local/bin/ocamlbuild
ocamlopt: ...................................... /usr/local/bin/ocamlopt.opt
ocamlc: ........................................ /usr/local/bin/ocamlc.opt
ocamlfind: ..................................... /usr/local/bin/ocamlfind

I: Running build step
I: Running command '/usr/local/bin/ocamlbuild src/libZMQB.a src/dllZMQB.so src/ZMQB.cma src/ZMQB.cmxa src/ZMQB.a test/test.native -tag debug'
Finished, 1 target (0 cached) in 00:00:00.
+ ocamlfind ocamlc -ccopt -Wall -ccopt -W -ccopt -Wextra -ccopt -O2 -c src/socket.c
src/socket.c:17: warning: missing initializer
src/socket.c:17: warning: (near initialization for ‘caml_zmq_socket_ops.compare_ext’)
+ ocamlfind ocamlc -ccopt -Wall -ccopt -W -ccopt -Wextra -ccopt -O2 -c src/context.c
src/context.c:17: warning: missing initializer
src/context.c:17: warning: (near initialization for ‘caml_zmq_context_ops.compare_ext’)
+ ocamlfind ocamlc -ccopt -Wall -ccopt -W -ccopt -Wextra -ccopt -O2 -c src/poll.c
src/poll.c:25: warning: missing initializer
src/poll.c:25: warning: (near initialization for ‘caml_zmq_poll_ops.compare_ext’)
+ ocamlfind ocamlc -ccopt -Wall -ccopt -W -ccopt -Wextra -ccopt -O2 -c src/uint64.c
src/uint64.c:49: warning: missing initializer
src/uint64.c:49: warning: (near initialization for ‘uint64_ops.compare_ext’)
+ ocamlfind ocamlopt -g -I src -linkpkg -package uint.uint64 -package oUnit src/ZMQB.cmxa test/zmq_test.cmx test/test.cmx -o test/test.native
/lib/librt.so.1: undefined reference to `__pthread_unwind@GLIBC_PRIVATE'
/lib/librt.so.1: undefined reference to `pthread_barrier_init@GLIBC_2.2'
/usr/local/lib/libzmq.so: undefined reference to `pthread_sigmask@GLIBC_2.0'
/lib/librt.so.1: undefined reference to `pthread_attr_setstacksize@GLIBC_2.1'
/lib/librt.so.1: undefined reference to `pthread_barrier_wait@GLIBC_2.2'
collect2: ld returned 1 exit status
File "caml_startup", line 1, characters 0-1:
Error: Error during linking
Command exited with code 2.
Compilation unsuccessful after building 27 targets (0 cached) in 00:00:01.
E: Command '/usr/local/bin/ocamlbuild src/libZMQB.a src/dllZMQB.so src/ZMQB.cma src/ZMQB.cmxa src/ZMQB.a test/test.native -tag debug' terminated with error code 10