我正在尝试构建libnice。但是编译失败并出现以下错误:
stun/libstun.a.p/stunhmac.c.o: In function `stun_sha1':
libnice/build/../stun/stunhmac.c:125: undefined reference to `gnutls_hmac_get_len'
libnice/build/../stun/stunhmac.c:126: undefined reference to `gnutls_hmac_init'
libnice/build/../stun/stunhmac.c:128: undefined reference to `gnutls_hmac'
libnice/build/../stun/stunhmac.c:129: undefined reference to `gnutls_hmac'
libnice/build/../stun/stunhmac.c:130: undefined reference to `gnutls_hmac'
libnice/build/../stun/stunhmac.c:140: undefined reference to `gnutls_hmac_deinit'
libnice/build/../stun/stunhmac.c:137: undefined reference to `gnutls_hmac'
stun/libstun.a.p/stunhmac.c.o: In function `stun_hash_creds':
libnice/build/../stun/stunhmac.c:202: undefined reference to `gnutls_hash_init'
libnice/build/../stun/stunhmac.c:203: undefined reference to `gnutls_hash'
libnice/build/../stun/stunhmac.c:204: undefined reference to `gnutls_hash'
libnice/build/../stun/stunhmac.c:205: undefined reference to `gnutls_hash'
libnice/build/../stun/stunhmac.c:206: undefined reference to `gnutls_hash'
libnice/build/../stun/stunhmac.c:207: undefined reference to `gnutls_hash'
libnice/build/../stun/stunhmac.c:209: undefined reference to `gnutls_hash_deinit'
stun/libstun.a.p/rand.c.o: In function `nice_RAND_nonce':
libnice/build/../stun/rand.c:59: undefined reference to `gnutls_rnd'
collect2: error: ld returned 1 exit status
失败的命令如下:
arm-linux-gnueabihf-cc -o tests/nice-test-bsd tests/nice-test-bsd.p/test-bsd.c.o \
-L/sysroot/staging/lib -L/sysroot/usr/lib \
-Wl,--as-needed -Wl,--no-undefined -mthumb -march=armv7-a -mtune=cortex-a9 \
-mlittle-endian -mfloat-abi=hard -mfpu=neon -Wa,-mimplicit-it=thumb \
-Wl,-rpath-link=/sysroot/lib -Wl,-rpath-link=/sysroot/usr/lib \
-Wl,-rpath,/sysroot/lib/usr/lib -Wl,-rpath-link,/sysroot/usr/lib \
-Wl,--start-group \
agent/libagent.a stun/libstun.a socket/libsocket.a random/libnice-random.a \
/sysroot/usr/lib/libgio-2.0.so /sysroot/usr/lib/libgobject-2.0.so \
/sysroot/usr/lib/libglib-2.0.so /sysroot/usr/lib/libgthread-2.0.so \
-pthread \
/sysroot/usr/lib/libgnutls.so \
-lm \
-Wl,--end-group
所以libgnutls包含在链接命令中,但仍然找不到其中的符号。但是,如果我移到socket/libsocket.a
. 的开头-Wl,--start-group
,则编译成功。
我以为里面档案的顺序--start-group
……--end-group
没关系。但似乎确实如此。为什么会这样?