ublk-org / ublksrv

ublk: userspace block device driver
MIT License
147 stars 50 forks source link

cannot link to pthread #12

Closed old-memories closed 2 years ago

old-memories commented 2 years ago

[root@iZuf609uyxtf9dw6jr2adgZ ubdsrv]# autoreconf -i [root@iZuf609uyxtf9dw6jr2adgZ ubdsrv]# export LIBURING_DIR=~/work/liburing-liburing-2.2; PKG_CONFIG_PATH=${LIBURING_DIR} ./configure CFLAGS="-I${LIBURING_DIR}/src/include" CXXFLAGS="-I${LIBURING_DIR}/src/include" LDFLAGS="-L${LIBURING_DIR}/src" checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether gcc understands -c and -o together... yes checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define EXTENSIONS... yes checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... no checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports the include directive... yes (GNU style) checking whether make supports nested variables... yes checking dependency style of gcc... gcc3 checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking how to print strings... printf checking for a sed that does not truncate output... /usr/bin/sed checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for ar... ar checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for a working dd... /usr/bin/dd checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1 checking for mt... no checking if : is a manifest tool... no checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for a sed that does not truncate output... (cached) /usr/bin/sed checking for gcc... (cached) gcc checking whether we are using the GNU C compiler... (cached) yes checking whether gcc accepts -g... (cached) yes checking for gcc option to accept ISO C89... (cached) none needed checking whether gcc understands -c and -o together... (cached) yes checking how to run the C preprocessor... gcc -E checking for function prototypes... yes checking whether gcc is Clang... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking whether more special flags are required for pthreads... no checking for PTHREAD_PRIO_INHERIT... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking dependency style of g++... gcc3 checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC -DPIC checking if g++ PIC flag -fPIC -DPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking dynamic linker characteristics... (cached) GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for LIBURING... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating include/Makefile config.status: creating lib/Makefile config.status: creating tests/Makefile config.status: creating ublksrv.pc config.status: creating config.h config.status: config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands [root@iZuf609uyxtf9dw6jr2adgZ ubdsrv]# make clean && make Making clean in include make[1]: Entering directory '/root/work/ubdsrv/include' rm -rf .libs _libs rm -f .lo make[1]: Leaving directory '/root/work/ubdsrv/include' Making clean in lib make[1]: Entering directory '/root/work/ubdsrv/lib' test -z "~ .d" || rm -f ~ .d test -z "libublksrv.la" || rm -f libublksrv.la rm -f ./so_locations rm -rf .libs _libs rm -f .o rm -f .lo make[1]: Leaving directory '/root/work/ubdsrv/lib' Making clean in tests make[1]: Entering directory '/root/work/ubdsrv/tests' test -z "~ /~" || rm -f ~ /~ rm -rf .libs _libs rm -f .lo make[1]: Leaving directory '/root/work/ubdsrv/tests' make[1]: Entering directory '/root/work/ubdsrv' rm -f ublk demo_null demo_event test -z "~ test cscope. include/~ .d" || rm -f ~ test cscope. include/~ .d rm -rf .libs _libs rm -f .o rm -f .lo make[1]: Leaving directory '/root/work/ubdsrv' make all-recursive make[1]: Entering directory '/root/work/ubdsrv' Making all in include make[2]: Entering directory '/root/work/ubdsrv/include' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/root/work/ubdsrv/include' Making all in lib make[2]: Entering directory '/root/work/ubdsrv/lib' /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv_cmd.lo -MD -MP -MF .deps/libublksrv_la-ublksrv_cmd.Tpo -c -o libublksrv_la-ublksrv_cmd.lo test -f 'ublksrv_cmd.c' || echo './'ublksrv_cmd.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv_cmd.lo -MD -MP -MF .deps/libublksrv_la-ublksrv_cmd.Tpo -c ublksrv_cmd.c -fPIC -DPIC -o .libs/libublksrv_la-ublksrv_cmd.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv_cmd.lo -MD -MP -MF .deps/libublksrv_la-ublksrv_cmd.Tpo -c ublksrv_cmd.c -o libublksrv_la-ublksrv_cmd.o >/dev/null 2>&1 mv -f .deps/libublksrv_la-ublksrv_cmd.Tpo .deps/libublksrv_la-ublksrv_cmd.Plo /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv_json.lo -MD -MP -MF .deps/libublksrv_la-ublksrv_json.Tpo -c -o libublksrv_la-ublksrv_json.lo test -f 'ublksrv_json.cpp' || echo './'ublksrv_json.cpp libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv_json.lo -MD -MP -MF .deps/libublksrv_la-ublksrv_json.Tpo -c ublksrv_json.cpp -fPIC -DPIC -o .libs/libublksrv_la-ublksrv_json.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv_json.lo -MD -MP -MF .deps/libublksrv_la-ublksrv_json.Tpo -c ublksrv_json.cpp -o libublksrv_la-ublksrv_json.o >/dev/null 2>&1 mv -f .deps/libublksrv_la-ublksrv_json.Tpo .deps/libublksrv_la-ublksrv_json.Plo /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv.lo -MD -MP -MF .deps/libublksrv_la-ublksrv.Tpo -c -o libublksrv_la-ublksrv.lo test -f 'ublksrv.c' || echo './'ublksrv.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv.lo -MD -MP -MF .deps/libublksrv_la-ublksrv.Tpo -c ublksrv.c -fPIC -DPIC -o .libs/libublksrv_la-ublksrv.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-ublksrv.lo -MD -MP -MF .deps/libublksrv_la-ublksrv.Tpo -c ublksrv.c -o libublksrv_la-ublksrv.o >/dev/null 2>&1 mv -f .deps/libublksrv_la-ublksrv.Tpo .deps/libublksrv_la-ublksrv.Plo /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-utils.lo -MD -MP -MF .deps/libublksrv_la-utils.Tpo -c -o libublksrv_la-utils.lo test -f 'utils.c' || echo './'utils.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-utils.lo -MD -MP -MF .deps/libublksrv_la-utils.Tpo -c utils.c -fPIC -DPIC -o .libs/libublksrv_la-utils.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -I/root/work/liburing-liburing-2.2/src/include -MT libublksrv_la-utils.lo -MD -MP -MF .deps/libublksrv_la-utils.Tpo -c utils.c -o libublksrv_la-utils.o >/dev/null 2>&1 mv -f .deps/libublksrv_la-utils.Tpo .deps/libublksrv_la-utils.Plo /bin/sh ../libtool --tag=CXX --mode=link g++ -I/root/work/liburing-liburing-2.2/src/include -version-info 0:0:0 -L/root/work/liburing-liburing-2.2/src -o libublksrv.la -rpath /usr/local/lib libublksrv_la-ublksrv_cmd.lo libublksrv_la-ublksrv_json.lo libublksrv_la-ublksrv.lo libublksrv_la-utils.lo -L/usr/lib -luring
libtool: link: g++ -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/10/crtbeginS.o .libs/libublksrv_la-ublksrv_cmd.o .libs/libublksrv_la-ublksrv_json.o .libs/libublksrv_la-ublksrv.o .libs/libublksrv_la-utils.o -L/root/work/liburing-liburing-2.2/src -L/usr/lib -luring -L/usr/lib/gcc/x86_64-redhat-linux/10 -L/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/10/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-redhat-linux/10/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crtn.o -Wl,-soname -Wl,libublksrv.so.0 -o .libs/libublksrv.so.0.0.0 libtool: link: (cd ".libs" && rm -f "libublksrv.so.0" && ln -s "libublksrv.so.0.0.0" "libublksrv.so.0") libtool: link: (cd ".libs" && rm -f "libublksrv.so" && ln -s "libublksrv.so.0.0.0" "libublksrv.so") libtool: link: ar cru .libs/libublksrv.a libublksrv_la-ublksrv_cmd.o libublksrv_la-ublksrv_json.o libublksrv_la-ublksrv.o libublksrv_la-utils.o libtool: link: ranlib .libs/libublksrv.a libtool: link: ( cd ".libs" && rm -f "libublksrv.la" && ln -s "../libublksrv.la" "libublksrv.la" ) make[2]: Leaving directory '/root/work/ubdsrv/lib' Making all in tests make[2]: Entering directory '/root/work/ubdsrv/tests' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/root/work/ubdsrv/tests' make[2]: Entering directory '/root/work/ubdsrv' g++ -DHAVE_CONFIG_H -I. -I./include -fcoroutines -std=c++20 -I/root/work/liburing-liburing-2.2/src/include -MT ublk-ublksrv_tgt.o -MD -MP -MF .deps/ublk-ublksrv_tgt.Tpo -c -o ublk-ublksrv_tgt.o test -f 'ublksrv_tgt.cpp' || echo './'ublksrv_tgt.cpp mv -f .deps/ublk-ublksrv_tgt.Tpo .deps/ublk-ublksrv_tgt.Po g++ -DHAVE_CONFIG_H -I. -I./include -fcoroutines -std=c++20 -I/root/work/liburing-liburing-2.2/src/include -MT ublk-tgt_null.o -MD -MP -MF .deps/ublk-tgt_null.Tpo -c -o ublk-tgt_null.o test -f 'tgt_null.cpp' || echo './'tgt_null.cpp mv -f .deps/ublk-tgt_null.Tpo .deps/ublk-tgt_null.Po g++ -DHAVE_CONFIG_H -I. -I./include -fcoroutines -std=c++20 -I/root/work/liburing-liburing-2.2/src/include -MT ublk-tgt_loop.o -MD -MP -MF .deps/ublk-tgt_loop.Tpo -c -o ublk-tgt_loop.o test -f 'tgt_loop.cpp' || echo './'tgt_loop.cpp mv -f .deps/ublk-tgt_loop.Tpo .deps/ublk-tgt_loop.Po /bin/sh ./libtool --tag=CXX --mode=link g++ -fcoroutines -std=c++20 -I/root/work/liburing-liburing-2.2/src/include -L/root/work/liburing-liburing-2.2/src -o ublk ublk-ublksrv_tgt.o ublk-tgt_null.o ublk-tgt_loop.o lib/libublksrv.la -L/usr/lib -luring
libtool: link: g++ -fcoroutines -std=c++20 -I/root/work/liburing-liburing-2.2/src/include -o .libs/ublk ublk-ublksrv_tgt.o ublk-tgt_null.o ublk-tgt_loop.o -L/root/work/liburing-liburing-2.2/src lib/.libs/libublksrv.so -L/usr/lib -luring -Wl,-rpath -Wl,/usr/local/lib /usr/bin/ld: ublk-ublksrv_tgt.o: in function ublksrv_drain_fetch_commands(ublksrv_dev*, ublksrv_queue_info*)': ublksrv_tgt.cpp:(.text+0x85e): undefined reference topthread_join' /usr/bin/ld: ublk-ublksrv_tgt.o: in function ublksrv_io_handler(void*)': ublksrv_tgt.cpp:(.text+0x9f8): undefined reference topthread_create' /usr/bin/ld: lib/.libs/libublksrv.so: undefined reference to `pthread_setaffinity_np' collect2: error: ld returned 1 exit status make[2]: [Makefile:545: ublk] Error 1 make[2]: Leaving directory '/root/work/ubdsrv' make[1]: [Makefile:693: all-recursive] Error 1 make[1]: Leaving directory '/root/work/ubdsrv' make: *** [Makefile:431: all] Error 2

old-memories commented 2 years ago

I find m4/ax_pthread.m4 is missing, so I add one here copied from http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_pthread.m4

This works.

ming1 commented 2 years ago

You need to install the package of autoconf-archive

ming1 commented 2 years ago

I have documented the build dependency in README, so close it now.