Skip to content

cmake : build static linked executable failed #118

Description

@leleliu008

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?

Activity

  1. leleliu008 commented on Mar 5, 2023

    @leleliu008
    Author

    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}
    
  2. leleliu008 commented on Mar 25, 2023

    @leleliu008
    Author

    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
  3. added a commit that references this issue on Apr 5, 2023
  4. added a commit that references this issue on Aug 3, 2023
  5. 137 remaining items

  6. added a commit that references this issue on Jun 29, 2026
  7. added a commit that references this issue on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions