[Libct] [PATCH] test/Makefile: tests should use local libs

Kir Kolyshkin kir at openvz.org
Thu Jul 24 00:02:19 PDT 2014


This adds linker options so that test binaries compiled will use
the local copy of libct and libnl libs (instead of system ones).

This gives us two benefits:

 1 ability to run tests without installing the libraries or using
   tricks such as LD_LIBRARY_PATH;

 2 confidence that the proper libs are used, not some old ones.

Before this commit:

 [kir at kirpad test]$ ldd ct_create
	linux-vdso.so.1 =>  (0x00007fff121fe000)
 ->	libct.so => not found
 ->	libnl-route-3.so.200 => /lib64/libnl-route-3.so.200 (0x00007f20d9996000)
 ->	libnl-3.so.200 => /lib64/libnl-3.so.200 (0x00007f20d9778000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f20d93b9000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f20d919b000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f20d8e94000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f20d9c1f000)

After:

 [kir at kirpad test]$ ldd ct_create
	linux-vdso.so.1 =>  (0x00007fffb72fc000)
 ->	libct.so => /vz/kir/git/libct/test/./../src/libct.so (0x00007f1061c58000)
 ->	libnl-route-3.so.200 => /vz/kir/git/libct/test/./../.shipped/libnl/lib/.libs/libnl-route-3.so.200 (0x00007f10619f7000)
 ->	libnl-3.so.200 => /vz/kir/git/libct/test/./../.shipped/libnl/lib/.libs/libnl-3.so.200 (0x00007f10617da000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f10613ed000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f10611cf000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f1060ec8000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f1061e67000)

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 test/Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/test/Makefile b/test/Makefile
index 72568e3..c91bad1 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -8,7 +8,11 @@ PIGS  = file_piggy
 
 CC = gcc
 CFLAGS = -I../src/include/uapi/ -g
-LDFLAGS = -Wl,--no-as-needed -lct -L../src/ -L../.shipped/libnl/lib/.libs/ -lnl-route-3 -lnl-3
+LIBNLDIR = ../.shipped/libnl/lib/.libs
+LDFLAGS = -Wl,--no-as-needed \
+	-lct -L../src/ -Wl,-rpath,'$$ORIGIN/../src' \
+	-lnl-route-3 -lnl-3 -L$(LIBNLDIR) -Wl,-rpath,'$$ORIGIN/$(LIBNLDIR)'
+
 OUTS = $(TESTS:%=%.out)
 
 all: $(PIGS) $(TESTS)
-- 
1.9.3



More information about the Libct mailing list