I am running an Ubuntu 12.10 machine and I had to compile and install a jsvc binary for an older version that I didn’t have a package that I could install via dpkg or apt-get install.
Running configure came off without a hitch.
Running make resulted in the following error:
gcc -ldl -lpthread jsvc-unix.o libservice.a -o ../jsvc
libservice.a(dso-dlfcn.o): In function `dso_unlink’:
/usr/local/src/daemon-1.0.1/src/native/unix/native/dso-dlfcn.c:41: undefined reference to `dlclose’
libservice.a(dso-dlfcn.o): In function `dso_link’:
/usr/local/src/daemon-1.0.1/src/native/unix/native/dso-dlfcn.c:36: undefined reference to `dlopen’
libservice.a(dso-dlfcn.o): In function `dso_symbol’:
/usr/local/src/daemon-1.0.1/src/native/unix/native/dso-dlfcn.c:47: undefined reference to `dlsym’
libservice.a(dso-dlfcn.o): In function `dso_error’:
/usr/local/src/daemon-1.0.1/src/native/unix/native/dso-dlfcn.c:52: undefined reference to `dlerror’
collect2: error: ld returned 1 exit status
make[1]: *** [jsvc] Error 1
make[1]: Leaving directory `/usr/local/src/daemon-1.0.1/src/native/unix/native’
make: *** [native/all] Error 2
I double checked that the Ubuntu packages that provide those libs were installed (libc6 and libc6-dev).
It turns out that, for some reason, under this distro that the GCC linker requires the -ldl argument to be listed last. So that the invocation of:
gcc -ldl -lpthread jsvc-unix.o libservice.a -o ../jsvc
needs to be:
gcc jsvc-unix.o libservice.a -o ../jsvc -lpthread -ldl
To make this happen, do the following:
Edit configure:
For your $host_os update:
LDFLAGS=”$LDFLAGS -ldl -lpthread”
to
LDFLAGS=”$LDFLAGS -lpthread -ldl”
Run # ./configure
Then edit the ./native/Makefile:
jsvc: jsvc-unix.o libservice.a
$(LDCMD) $(LDFLAGS) jsvc-unix.o libservice.a -o ../jsvc
to
jsvc: jsvc-unix.o libservice.a
$(LDCMD) jsvc-unix.o libservice.a -o ../jsvc $(LDFLAGS)
# make
It should compile without any complaints