You have tried to outwit the buid-system, and it has outwitted you.
It's generally a bad idea to hard-code paths.
Debian (and ubuntu is just a derivative), has started to ship binaries (like libraries) in architecture-dependent directories, to allow installations for multiple architectures on a single system.
These libraries are installed into /usr/lib/<host-triplet>
, where <host-triplet>
depends on the architecture; e.g. x86_64-linux-gnu
is the amd64 architecture for systems with a linux and the gnu tools.
a 32bit system would typically have a host-triplet of i386-linux-gnu
.
Since you are hard-coding the library path to a 64bit location( /usr/lib/x86_64-linux-gnu/libm.so
) this fails on all systems but 64bit/linux/gnu.
Instead you should just tell the linker to link against the m library (libm
), resp the X11 library (libX11
).
Let the linker care for the correct architecture to pick:
relay_LDADD = -lm -lX11 $(RELAY_LIBS)
In general, if you want to link against a library foo, that provides a library-file libfoo.so
you would use -lfoo
(stripping away the leading lib
and the trailing .so
).
However, sometimes this is not enough; in those cases your library might use pkg-config
to provide the full CFLAGS
and LDFLAGS
needed to compile/link against this library.
e.g. if I want to use libquicktime
:
$ pkg-config --cflags libquicktime
-I/usr/include/lqt
$ pkg-config --libs libquicktime
-lquicktime -lpthread -lm -lz -ldl
So I would use something like:
myprog_CFLAGS += $(shell pkg-config --cflags libquicktime)
myprog_LDADD += $(shell pkg-config --libs libquicktime)
That would work in any GNU(?) Makefile (not related to autotools).
In an autotools project, you would probably move the pkg-config check into configure
, using the m4-macro PKG_CHECK_MODULES