在FreeBSD上链接libuv

时间:2019-04-16 15:37:18

标签: c linker clang freebsd libuv

我已经在FreeBSD-12.0上安装了libuv,

$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install

所有测试均通过,并且sudo make install的输出表明该库已成功安装到/usr/local/bin

$ sudo make install
 /usr/local/bin/gmkdir -p '/usr/local/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libuv.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libuv.so.1.0.0 /usr/local/lib/libuv.so.1.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libuv.so.1.0.0 libuv.so.1 || { rm -f libuv.so.1 && ln -s libuv.so.1.0.0 libuv.so.1; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libuv.so.1.0.0 libuv.so || { rm -f libuv.so && ln -s libuv.so.1.0.0 libuv.so; }; })
libtool: install: /usr/bin/install -c .libs/libuv.lai /usr/local/lib/libuv.la
libtool: install: /usr/bin/install -c .libs/libuv.a /usr/local/lib/libuv.a
libtool: install: chmod 644 /usr/local/lib/libuv.a
libtool: install: ranlib /usr/local/lib/libuv.a
 /usr/local/bin/gmkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 include/uv.h '/usr/local/include'
 /usr/local/bin/gmkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libuv.pc '/usr/local/lib/pkgconfig'
 /usr/local/bin/gmkdir -p '/usr/local/include/uv'
 /usr/bin/install -c -m 644 include/uv/errno.h include/uv/threadpool.h include/uv/version.h include/uv/unix.h include/uv/bsd.h '/usr/local/include/uv'

现在,我正在尝试编译并运行一个简单的libuv程序

#include <stdio.h>
#include <stdlib.h>
#include <uv.h>

int main() {
    uv_loop_t *loop = malloc(sizeof(uv_loop_t));
    uv_loop_init(loop);

    printf("Now quitting.\n");
    uv_run(loop, UV_RUN_DEFAULT);

    uv_loop_close(loop);
    free(loop);
    return 0;
}

仅会出现以下错误

$ clang -I/usr/local/include -L/usr/local/lib main.c -v
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang" -cc1 -triple x86_64-unknown-freebsd12.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/6.0.1 -I /usr/local/include -fdebug-compilation-dir /tmp/tmp.VwilsAoR -ferror-limit 19 -fmessage-length 80 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-0d270e.o -x c main.c
clang -cc1 version 6.0.1 based upon LLVM 6.0.1 default target x86_64-unknown-freebsd12.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/clang/6.0.1/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/local/lib -L/usr/lib /tmp/main-0d270e.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
/usr/bin/ld: error: undefined symbol: uv_loop_init
>>> referenced by main.c
>>>               /tmp/main-0d270e.o:(main)

/usr/bin/ld: error: undefined symbol: uv_run
>>> referenced by main.c
>>>               /tmp/main-0d270e.o:(main)

/usr/bin/ld: error: undefined symbol: uv_loop_close
>>> referenced by main.c
>>>               /tmp/main-0d270e.o:(main)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

0 个答案:

没有答案