NetBSD / pkgsrc

Automatic conversion of the NetBSD pkgsrc CVS module, use with care
https://www.pkgsrc.org
310 stars 164 forks source link

cmake : build static linked executable failed #118

Closed leleliu008 closed 1 year ago

leleliu008 commented 1 year ago

I add /etc/mk.conf to LDFLAGS+= -static -pthread to build static linked executable,but it failed and report following:

...
ols.o EncodingC.o ProcessUNIX.o String.o System.o Terminal.o  -lkvm -luv -lrhash -lcrypto -o cmake
ld: /home/vagrant/pkgsrc/devel/cmake/work/.buildlink/lib/libuv.a(libuv_la-netbsd.o): in function `uv_resident_set_memory':
/home/vagrant/pkgsrc/devel/libuv/work/libuv-1.44.2/src/unix/netbsd.c:162: undefined reference to `kvm_open'
ld: /home/vagrant/pkgsrc/devel/libuv/work/libuv-1.44.2/src/unix/netbsd.c:166: undefined reference to `kvm_getproc2'
ld: /home/vagrant/pkgsrc/devel/libuv/work/libuv-1.44.2/src/unix/netbsd.c:176: undefined reference to `kvm_close'
ld: /home/vagrant/pkgsrc/devel/libuv/work/libuv-1.44.2/src/unix/netbsd.c:171: undefined reference to `kvm_close'
make: *** [Makefile:2: cmake] Error 1
---------------------------------------------
Error when bootstrapping CMake:
Problem while running make
---------------------------------------------
Log of errors: /home/vagrant/pkgsrc/devel/cmake/work/cmake-3.25.1/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
*** Error code 9

Stop.
bmake[1]: stopped in /home/vagrant/pkgsrc/devel/cmake
*** Error code 1

Stop.
bmake: stopped in /home/vagrant/pkgsrc/devel/cmake

The reason is -lkvm -luv should be changed to -luv -lkvm. how should I do?

leleliu008 commented 1 year ago

content of /lib/pkgconfig/libuv.pc is correct:

prefix=/home/vagrant/pkgsrc-packages
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libuv
Version: 1.44.2
Description: multi-platform support library with a focus on asynchronous I/O.
URL: http://libuv.org/

Libs: -L${libdir} -luv -lkvm  
Cflags: -I${includedir}
leleliu008 commented 1 year ago

work around

ar x /usr/lib/libkvm.a
ar x /home/vagrant/pkgsrc/devel/cmake/work/.buildlink/lib/libuv.a
ar crs libuv.a *.o
cp libuv.a /home/vagrant/pkgsrc/devel/cmake/work/.buildlink/lib/libuv.a
bmake install