"undefined reference" error in SuSE

I am trying to compile an app I got from another party. I get the error:

: undefined reference to ‘XmuLookupStandardColormap’

and then make quits. I am using the compiler options

-ltk8.4 -ltcl8.4 -lGLU -lGL -lX11 -lXmu -Xmu -lXext -lm -lXi -lglut

(Before you ask, this program is only guaranteed compatible with tcl/tk 8.4 and lower.)

The library directory in the Makefile is given by
LIBDIRS = -L/usr/X11R6/lib64 -L/usr/lib

(there’s a similar line for my tcl/tk directory)

I checked to make sure those directories actually exist and are full of stuff, and they are. Has anyone run into this kind of error and can give me some help?

The function prefix is a dead giveaway, but here on SuSE 11.2 sure enough, this is defined in libXmu.so:

> nm -Do /usr/lib64/lib*.so* | grep  XmuLookupStandardColormap
/usr/lib64/libXmu.so:00000000000101c0 T XmuLookupStandardColormap
/usr/lib64/libXmu.so.6:00000000000101c0 T XmuLookupStandardColormap
/usr/lib64/libXmu.so.6.2.0:00000000000101c0 T XmuLookupStandardColormap

Things to check:

[ol][li]What OS/CPU architecture are you on? 32-bit or 64-bit?[/li]
uname -a will tell you, or more specifically (and redundantly): uname -m -p -i. Here these are all x86_64, signifying that I installed 64-bit SuSE on a 64-bit CPU.

If you are on 64-bit, you need to look in lib64 dirs (e.g. /usr/lib64). For 32-bit, use lib (e.g. /usr/lib). Typically your compiler/linker just looks in the right system dir(s) automatically based on the architecture you select (or default to). [li]Make sure that you have the libXmu.so files installed:[/li]
ls -l /usr/lib64/libXmu.*

If not, you need to install the relevant packages that contains them.

Note that you need both the library (e.g. libXmu.so.6.2.0 and the .so symlink that points to it (e.g. libXmu.so). The former is what’s actually referenced by linked programs. The latter is only needed for development when the linker goes to find the latest (or preferred) version of a library. The latter is also typically stored in a -devel package.

For instance, here:

> cd /usr/lib64
> ls -l libXmu.so*
lrwxrwxrwx 1 root root     15 Nov 27 14:51 libXmu.so -> libXmu.so.6.2.0
lrwxrwxrwx 1 root root     15 Nov 27 09:50 libXmu.so.6 -> libXmu.so.6.2.0
-rwxr-xr-x 1 root root 107256 Oct 19 13:36 libXmu.so.6.2.0

> rpm -qf /usr/lib64/libXmu.so.6.2.0
> rpm -qf /usr/lib64/libXmu.so

So note that here on SuSE 11.2 to get both the libXmu.so.6.2.0 binary library file AND the .so symlink used by the compile-time linker to find it, I’d need to make sure I have the xorg-x11-libXmu and the xorg-x11-libXmu-devel packages installed. Again note that the latter contains the libXmu.so symlink used for "devel"opment, along with header files used for compilation.[/ol]

The library directory in the Makefile is given by
LIBDIRS = -L/usr/X11R6/lib64 -L/usr/lib

This is bogus. The first directory is a directory for 64-bit libs, the second is a directory for 32-bit libs. Typically you don’t specify any of this and the compiler/linker just adds the appropriate search paths for you based on the architecture you select (or default to).

If you’re compiling on 64-bit Linux, the default compile target is 64-bit. On 32-bit Linux, 32-bit. If you want to cross-compile 32-bit on 64-bit Linux that’s the only time you need to start specifying explicit target architectures to the compiler or linker.

Ah, yes, everything ix x86_64. These processors are Xeon X5160s.

The libXmu.so* files are not in /usr/lib64, but they are in /usr/X11R6/lib64. Is that a problem?

Must be an old SuSE as they haven’t done that for several releases.

But no, not a problem. Just make sure -lXmu is on the link line. And if the compiler/linker doesn’t auto-search /usr/X11R6/lib64, then add -L/usr/X11R6/lib64 before it.

Yup. I have done both of those things, hence why I am so stuck. Here’s what I have in my Makefile (there is some unnecessary stuff there, but it was already in the Makefile when I got it, so I left it alone, and yes, I realize that I probably should not have put tk/tcl in bin):

Where to find libtcl.a, libtk.a, OpenGL/Mesa libraries:

LIBDIRS = -L/usr/local/lib64 -L/usr/X11R6/lib64 -L/usr/lib64
LIBDIRS = -L/home/#####/bin/tcl/lib -L/home/#####/bin/tk/lib

Libraries to link with:

LIBS = -ltk8.4 -ltcl8.4 -lGLU -lGL -lX11R6 -lXmu -lXext -lm -lXi -lglut

And as you can see, the libraries are there:

#####@####:/scratch/#####/chimera2.0/gui> ls /usr/X11R6/lib64/libXmu*
/usr/X11R6/lib64/libXmu.a /usr/X11R6/lib64/libXmuu.a
/usr/X11R6/lib64/libXmu.so /usr/X11R6/lib64/libXmuu.so
/usr/X11R6/lib64/libXmu.so.6 /usr/X11R6/lib64/libXmuu.so.1
/usr/X11R6/lib64/libXmu.so.6.2 /usr/X11R6/lib64/libXmuu.so.1.0

OK, I fixed it. I didn’t realize that having two LIBDIRS lines meant the second wiped out the first. I had just uncommented things from the original Makefile that had what I needed. Now I just have to get it to recognize libimf.so, but I guess that’s a different forum.

Ah!, yes.

Now I just have to get it to recognize libimf.so, but I guess that’s a different forum.

OpenEXR possibly, though here it’s libIlmImf.so. If so, just install OpenEXR and OpenEXR-devel.