我正在尝试使用C
来编译clang
文件。我的C
文件与Zlib库具有依赖性,因此我包含了zlib.h
。当我使用clang编译时,出现以下链接器错误
undefined symbols for architecture x86_64:
"_inflate", referenced from:
__inflate in zlib_inflate_jni-169a59.o
(maybe you meant: __inflate)
"_inflateEnd", referenced from:
__createInflateContext in zlib_inflate_jni-169a59.o
__freeInflateContext in zlib_inflate_jni-169a59.o
"_inflateInit2_", referenced from:
__createInflateContext in zlib_inflate_jni-169a59.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我使用的命令
clang -Oz -v -dynamiclib -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include/ -I/usr/local/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include/darwin/ -I/System/Library/Frameworks/JavaVM.framework/Headers -Izlib/ -o libjniexample.jnilib -shared zlib_inflate_jni.c
我在gcc上尝试过也仍然遇到相同的错误。