我能够很容易地为macos编译librdkafa的静态版本:
./configure --prefix=$TEMP_DIR \
--disable-sasl \
--enable-static
make
make install
我假设上面的配置可以工作,因为我是在目标平台上编译的。
对于ios,我指定的架构类型如下:
./configure --prefix=$TEMP_DIR \
--arch=arm64 \
--disable-sasl \
--enable-static
make
make install
但我得到一个编译错误:
gcc -shared -dynamiclib -Wl,-install_name,/Users/przemeklach/dev/artifact_staging/temp/lib/librdkafka.1.dylib rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_conf.o rdkafka_timer.o rdkafka_offset.o rdkafka_transport.o rdkafka_buf.o rdkafka_queue.o rdkafka_op.o rdkafka_request.o rdkafka_cgrp.o rdkafka_pattern.o rdkafka_partition.o rdkafka_subscription.o rdkafka_assignor.o rdkafka_range_assignor.o rdkafka_roundrobin_assignor.o rdkafka_feature.o rdcrc32.o crc32c.o rdaddr.o rdrand.o rdlist.o tinycthread.o rdlog.o rdstring.o rdkafka_event.o rdkafka_metadata.o rdregex.o rdports.o rdkafka_metadata_cache.o rdavl.o rdkafka_sasl.o rdkafka_sasl_plain.o rdkafka_interceptor.o rdkafka_msgset_writer.o rdkafka_msgset_reader.o rdvarint.o rdbuf.o rdunittest.o rdkafka_sasl_scram.o snappy.o rdgz.o rdkafka_lz4.o xxhash.o rddl.o rdkafka_plugin.o -o librdkafka.1.dylib -L/usr/local/Cellar/lz4/1.8.1.2/lib -llz4 -lpthread -lz -L/usr/local/Cellar/openssl/1.0.2o_1/lib -lssl -ldl
Undefined symbols for architecture x86_64:
"_BIO_ctrl", referenced from:
_rd_base64_encode in rdkafka_sasl_scram.o
"_BIO_f_base64", referenced from:
_rd_kafka_sasl_scram_fsm in rdkafka_sasl_scram.o
_rd_base64_encode in rdkafka_sasl_scram.o
实际的错误要长得多,所以我只张贴的部分,我认为是相关的。
以下是编译开始时打印的配置摘要:
prefix /Users/przemeklach/dev/artifact_staging/temp
ARCH arm64
CPU generic
GEN_PKG_CONFIG y
ENABLE_DEVEL n
ENABLE_VALGRIND n
ENABLE_REFCNT_DEBUG n
ENABLE_SHAREDPTR_DEBUG n
ENABLE_LZ4_EXT y
ENABLE_SSL y
ENABLE_SASL n
MKL_APP_NAME librdkafka
MKL_APP_DESC_ONELINE The Apache Kafka C/C++ library
MKL_DISTRO osx
SOLIB_EXT .dylib
CC gcc
CXX g++
LD ld
NM nm
OBJDUMP objdump
STRIP strip
CPPFLAGS -gstrict-dwarf -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align
PKG_CONFIG pkg-config
INSTALL install
HAS_LDFLAGS_STATIC n
LIB_LDFLAGS -shared -dynamiclib -Wl,-install_name,$(DESTDIR)$(libdir)/$(LIBFILENAME)
RDKAFKA_VERSION_STR 0.11.3
MKL_APP_VERSION 0.11.3
LIBS -L/usr/local/Cellar/lz4/1.8.1.2/lib -llz4 -lpthread -lz -L/usr/local/Cellar/openssl/1.0.2o_1/lib -lssl -ldl
CFLAGS -I/usr/local/Cellar/lz4/1.8.1.2/include -I/usr/local/Cellar/openssl/1.0.2o_1/include
CXXFLAGS -Wno-non-virtual-dtor
SYMDUMPER $(NM) -g
exec_prefix /Users/przemeklach/dev/artifact_staging/temp
bindir /Users/przemeklach/dev/artifact_staging/temp/bin
sbindir /Users/przemeklach/dev/artifact_staging/temp/sbin
libexecdir /Users/przemeklach/dev/artifact_staging/temp/libexec
datadir /Users/przemeklach/dev/artifact_staging/temp/share
sysconfdir /Users/przemeklach/dev/artifact_staging/temp/etc
sharedstatedir /Users/przemeklach/dev/artifact_staging/temp/com
localstatedir /Users/przemeklach/dev/artifact_staging/temp/var
libdir /Users/przemeklach/dev/artifact_staging/temp/lib
includedir /Users/przemeklach/dev/artifact_staging/temp/include
infodir /Users/przemeklach/dev/artifact_staging/temp/info
mandir /Users/przemeklach/dev/artifact_staging/temp/man
这个错误给我提出了两个问题:1)我在configure中是否正确地指定了体系结构;2)为什么它会抱怨我不打算构建的体系结构的未定义符号?
暂无答案!
目前还没有任何答案,快来回答吧!