[PATCH blktests] src/Makefile: fix static linking of miniublk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When using static linking, the libraries need to be placed after the
.o or .c files so they are searched.  Otherwise, the build will fail:

cc -O2 -Wall -Wshadow  -DHAVE_LINUX_BLKZONED_H  -D_GNU_SOURCE -lpthread -luring -o miniublk miniublk.c
/bin/ld: /tmp/ccfjiUvb.o: in function `ublk_ctrl_init':
miniublk.c:(.text+0xaeb): undefined reference to `io_uring_queue_init_params'
/bin/ld: /tmp/ccfjiUvb.o: in function `ublk_queue_deinit':
miniublk.c:(.text+0xb73): undefined reference to `io_uring_unregister_ring_fd'
/bin/ld: miniublk.c:(.text+0xb85): undefined reference to `io_uring_unregister_files'
/bin/ld: /tmp/ccfjiUvb.o: in function `ublk_io_handler_fn':
miniublk.c:(.text+0xd62): undefined reference to `io_uring_queue_init_params'
/bin/ld: miniublk.c:(.text+0xd77): undefined reference to `io_uring_register_ring_fd'
/bin/ld: miniublk.c:(.text+0xd8c): undefined reference to `io_uring_register_files'
/bin/ld: miniublk.c:(.text+0xe94): undefined reference to `io_uring_submit_and_wait_timeout'
/bin/ld: /tmp/ccfjiUvb.o: in function `__ublk_ctrl_cmd':
miniublk.c:(.text+0x14a6): undefined reference to `io_uring_submit'
/bin/ld: miniublk.c:(.text+0x1533): undefined reference to `__io_uring_get_cqe'
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: miniublk] Error 1

Fixes: d42fe976 ("src: add mini ublk source code")
Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
---
 src/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 1365480..c902649 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -39,7 +39,8 @@ CONFIG_DEFS := $(call HAVE_C_HEADER,linux/blkzoned.h,-DHAVE_LINUX_BLKZONED_H)
 override CFLAGS   := -O2 -Wall -Wshadow $(CFLAGS) $(CONFIG_DEFS)
 override CXXFLAGS := -O2 -std=c++11 -Wall -Wextra -Wshadow -Wno-sign-compare \
 		     -Werror $(CXXFLAGS) $(CONFIG_DEFS)
-MINIUBLK_FLAGS :=  -D_GNU_SOURCE -lpthread -luring
+MINIUBLK_FLAGS :=  -D_GNU_SOURCE
+MINIUBLK_LIBS := -lpthread -luring
 LDFLAGS ?=
 
 all: $(TARGETS)
@@ -58,6 +59,7 @@ $(CXX_TARGETS): %: %.cpp
 	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
 
 $(C_MINIUBLK): %: miniublk.c
-	$(CC) $(CFLAGS) $(LDFLAGS) $(MINIUBLK_FLAGS) -o $@ miniublk.c
+	$(CC) $(CFLAGS) $(LDFLAGS) $(MINIUBLK_FLAGS) -o $@ miniublk.c \
+		$(MINIUBLK_LIBS)
 
 .PHONY: all clean install
-- 
2.31.0




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux