Problems compiling Ice 3.3 from source on Debian

in Help Center
Greetings,
I recently tried upgrading my Ice installation from 3.2 to 3.3. Compiling goes fine until this:
c++ -Wl,--enable-new-dtags -Wl,-rpath,/opt/Ice-3.3/lib -ftemplate-depth-128 -Wall -D_REENTRANT -I/usr/include/nptl -fPIC -g -L../../lib -o ../../bin/slice2cpp Gen.o Main.o -lSlice -lIceUtil -L/usr/lib/nptl -lpthread -lrt
/lib/librt.so.1: undefined reference to `[email protected]_PRIVATE'
/lib/librt.so.1: undefined reference to `[email protected]_PRIVATE'
/lib/librt.so.1: undefined reference to `[email protected]_PRIVATE'
Here are some details of my setup:
[email protected]:~/src/Ice-3.3.0/cpp$ g++ --version
g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
[email protected]:~/src/Ice-3.3.0/cpp$ cat /proc/version
Linux version 2.6.23.17-oblab
Not really sure why my version of librt.so (/lib/librt-2.3.6.so) is not what Ice is looking for. On Debian, librt is part of the libc6 package... pretty much a core package for the system. What version of librt does Ice 3.3 need?
I recently tried upgrading my Ice installation from 3.2 to 3.3. Compiling goes fine until this:
c++ -Wl,--enable-new-dtags -Wl,-rpath,/opt/Ice-3.3/lib -ftemplate-depth-128 -Wall -D_REENTRANT -I/usr/include/nptl -fPIC -g -L../../lib -o ../../bin/slice2cpp Gen.o Main.o -lSlice -lIceUtil -L/usr/lib/nptl -lpthread -lrt
/lib/librt.so.1: undefined reference to `[email protected]_PRIVATE'
/lib/librt.so.1: undefined reference to `[email protected]_PRIVATE'
/lib/librt.so.1: undefined reference to `[email protected]_PRIVATE'
Here are some details of my setup:
[email protected]:~/src/Ice-3.3.0/cpp$ g++ --version
g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
[email protected]:~/src/Ice-3.3.0/cpp$ cat /proc/version
Linux version 2.6.23.17-oblab
Not really sure why my version of librt.so (/lib/librt-2.3.6.so) is not what Ice is looking for. On Debian, librt is part of the libc6 package... pretty much a core package for the system. What version of librt does Ice 3.3 need?
0
Comments
Ice 3.3 doesn't require a specific version of librt. It does however require a recent version of the Native POSIX Thread Linux (because we added monotonic clock support in Ice 3.3).
On Red Hat Enterprise Linux 4 (and CentOS 4), we need to include the pthread.h in /usr/include/nptl and link with the libpthread in /usr/lib/nptl to get the required functions.
Unfortunately our build system uses this extra include directory and library directory on all Linux distributions. Usually it's not an issue (these directories don't exist), but it's possible that on your system you have a version of the Pthread library in these directories that is incompatible with your librt.
So start by checking if /usr/include/nptl or /usr/lib/nptl exists on your system; if that's the case, edit cpp/config/Make.rules.Linux, remove all nptl settings, "make clean" and try again.
Cheers,
Bernard
Well you were right. I do have a /usr/include/nptl directory on my machine. But I'm afraid I have run into more problems now. This time the compiler is complaining:
c++ -c -I../../include -DICE_UTIL_API_EXPORTS -I.. -ftemplate-depth-128 -Wall -D_REENTRANT -fPIC -g Cond.cpp
Cond.cpp: In constructor ‘IceUtil::Cond::Cond()’:
Cond.cpp:311: error: ‘pthread_condattr_setclock’ was not declared in this scope
I changed several lines in the make file you recommended from:
CXXFLAGS = $(CXXARCHFLAGS) -ftemplate-depth-128 -Wall -D_REENTRANT -I/usr/include/nptl
...
BASELIBS = -lIceUtil -L$(NPTL_LIB) -lpthread -lrt
to:
CXXFLAGS = $(CXXARCHFLAGS) -ftemplate-depth-128 -Wall -D_REENTRANT
...
BASELIBS = -lIceUtil -lpthread -lrt
But I am guessing that I need to not just remove the include of nptl but also replace it with something else..
It looks like the default Pthread header/library on your Debian system don't include the required functions, like on RHEL4.
So I recommend to install first /usr/lib/nptl/librt.so.1, and then try again to build with /usr/include/nptl and /usr/lib/nptl.
Cheers,
Bernard
Cheers,
Bernard
I am sorry if I am being really dense about this but isn't that how I got into this linking problem in the first place? On my system, the nptl directories already exist. And for whatever reason, when Ice links against librt it fails to find those symbols it needs.. unless there are more than on version of librt floating around on my system?? A nptl version and non-nptl version???
The reason those nptl directories exist is because I already have libc6-dev installed. libc6-dev installs, among other things:
/usr/lib/libpthread.so
/usr/lib/nptl
/usr/lib/nptl/libc.a
/usr/lib/nptl/libc_nonshared.a
/usr/lib/nptl/libpthread.a
/usr/lib/nptl/libpthread_nonshared.a
/usr/lib/nptl/librt.a
/usr/lib/nptl/libc.so
/usr/lib/nptl/libpthread.so
...
/usr/include/nptl
/usr/include/nptl/bits
/usr/include/nptl/bits/libc-lock.h
/usr/include/nptl/bits/stdio-lock.h
/usr/include/nptl/bits/typesizes.h
/usr/include/nptl/bits/pthreadtypes.h
/usr/include/nptl/bits/posix_opt.h
/usr/include/nptl/bits/local_lim.h
/usr/include/nptl/bits/initspin.h
/usr/include/nptl/bits/semaphore.h
/usr/include/nptl/pthread.h
/usr/include/nptl/semaphore.h
/usr/include/nptl/thread_db.h
...
/usr/lib/librt.so
Please guide me out of the darkness!
/usr/lib/nptl/librt.a
Is this what I need to link against?
From your first message, it does not look like you're linking with /usr/lib/nptl/librt.a ... not sure why, however you're probably better off with the (proper) shared library.
You really want to link with /lib/tls/librt.so.1, not /lib/librt.so.1. However, I don't know what's the proper way to do this on your Debian system. If you have LD_ASSUME_KERNEL set, unset it; see Explaining LD_ASSUME_KERNEL
Cheers,
Bernard
I fixed it! Well at least to the point where it is now compiling. I messed around with the Make.rules.Linux file and forced everywhere there was a "-lpthread -lrt" to search either /lib/tls or /usr/lib/nptl. Here are the results:
/lib/tls: ERROR!
c++ -Wl,--enable-new-dtags -Wl,-rpath,/opt/Ice-3.3/lib -ftemplate-depth-128 -Wall -D_REENTRANT -I/usr/include/nptl -fPIC -g -L../../lib -o ../../bin/slice2cpp Gen.o Main.o -lSlice -lIceUtil -L/lib/tls -lpthread -lrt
../../lib/libIceUtil.so: undefined reference to `pthread_condattr_setclock'
So libIceUtil.so gets built properly. And in fact if I ldd libIceUtil.so I see:
[email protected]:~/src/Ice-3.3.0/cpp/lib$ ldd libIceUtil.so
linux-gate.so.1 => (0xffffe000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7e8b000)
librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7e82000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7d9d000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7d78000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7d6d000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7c3c000)
/lib/ld-linux.so.2 (0x80000000)
/usr/lib/nptl: WORKS!
I think what was going wrong before is that some linking steps used:
-lpthread -lrt
while others used:
-L$(NPTL_LIB) -lpthread -lrt
And on my system those were two different sets of libraries. I haven't yet run the new binaries.. hopefully I won't get any runtime errors...
(/usr/lib/nptl already has files libc.so and libpthread.so with approximately the same contents).
So is this the official stance on this problem? I have no problem doing something like this but just want to make sure there is not a better way.
I'm experiencing this problem as well. I'm on Debian Etch with gcc 4.1.2.
I first received the "undefined reference to `[email protected]_PRIVATE'" and related errors mentioned in the first post of this thread.
I then created the script mentioned by volk in 2 posts up. I was then able to get Ice to compile successfully.
So my current rt lib structure:
The problem is when I try to use Ice (using cmake which checks if it can include Ice/Ice.h), I get linker errors / undefined references to pthread_condattr_setclock from libIceUtil:
I'm not sure what to do. Should I just get rid of rt/nptl/tls and try to install all of these from source, as it seems to be a debian issue?
yamokosk, can you perhaps post your Make.rules.Linux file? I am currently compiling by adding -L$(NPTL_LIB) before any occurrence of -lpthread -lrt in Make.rules.Linux, we'll see how it goes.
/opt/Ice-3.3/lib/libIceUtil.so: undefined reference to `[email protected]_2.3.3'
Edit: After more trial & error, I finally got cmake to correctly test for the inclusion of Ice/Ice.h. The thing is I have to specify the nptl library path (/usr/lib/nptl), and the libs rt and pthread anytime I use IceUtil. Is this how it should be (e.g., explicitly specifying these options all the time)?
Yes, with Ice 3.3 on RHEL 4 and apparently Debian Etch, you need this /usr/lib/nptl all the time: when building Ice, and also when linking your own Ice-based applications.
Cheers,
Bernard
However, I'm having another problem when trying to run icebox:
I've removed all Ice 3.2 stuff totally and recompiled (from a fresh tgz extraction) and it still is looking for the 3.2 library. There's no occurrences of 3.2 or so.32 in any of the binary files or source files for that matter.
Is this problem something I would fix at the link or runtime stage, and how would I do so?
You just need to edit your Ice configuration file (or IceGrid deployment, if you're using IceGrid), and replace "IceStormService,32" by "IceStormService,33".
Cheers,
Bernard
I've been trying to build Ice 3.3.0 or 3.3.1 on our RHEL3 and RHEL4 machines in support of some internal developers who are testing it, and running into no end of problems.
The reason I'm posting in this thread, is because the errors I'm getting are described here. Here's what I'm seeing:
But RHEL3 and RHEL4 do not have /usr/lib/nptl or /usr/lib64/nptl at all, in any package; upstream or non.The headers are there, but no libraries exist for these distributions by Red Hat.
I suspect, from further reading in this thread and a few others, that this flat-out isn't going to build at all on these platforms, even if I was to shoehorn the NPTL libraries onto the machine, is it?
So what's next? Where do I go from here?
Welcome to our forums!
We provide Ice 3.3.1 RPMs for RHEL4, so the simplest is to download and install these RPMs. See: http://www.zeroc.com/download.html#linux_rpms
If you prefer, you can also build Ice 3.3.1 on RHEL4 (that's just a little more work). Please read the INSTALL.LINUX in the source distribution; you'll notice:
(You will also need this nptl-devel RPM for any C++ development using Ice)
We don't support RHEL3 with Ice 3.3.1, so this will definitely require more work. I would start by looking at this thread: http://www.zeroc.com/forums/help-center/3900-building-ice-3-3-0-red-hat-9-a.html
Best regards,
Bernard
RH 4AS-6.1 is where I'm currently getting the errors I posted above. If you do not support RHEL3, that's better for me... one less platform I have to support internally
Apparently that doesn't exist for RH 4AS-6.1 that anyone internally that administers these machines can find. We're still looking though...
nptl-devel is a standard RPM included in all RHEL 4 Advanced Server distributions.
For example, here is a fairly recent RedHat errata that includes an updated nptl-devel for RHEL 4: rhn.redhat.com | Red Hat Support
Best regards,
Bernard