ライブラリ リンクの問題のデバッグに取り組んでいますが、予期しない問題に遭遇しました。これが問題です。ビルド ツールを使用して Makefile を生成しているので、Makefile.am を記述するだけで済みます。最終的な目標は、共有ライブラリ ( srv.so ) を構築することです。静的にリンクしたいライブラリがいくつかあるので、「静的」フラグを LD に使用したいと考えています。私の Makefile.am には、このような LD_FLAGS があります
srv_la_LDFLAGS= -module -avoid-version
「静的」フラグを追加すると、2 つの別々の解釈が存在するようになります。
1位
srv_la_LDFLAGS= -module -avoid-version -static /path/to/lib.a
2位
srv_elastica_la_LDFLAGS= -module -avoid-version --static /path/to/lib.a
--staticと-staticの違いに注意してください。
最初のものは、 arを実行し、 srv.soの代わりにsrv.aを生成しようとするリンカー行を生成します。
/bin/bash ../../libtool --tag=CC --mode=link gcc -I../../include/
-Wno-unused-label -DMONGO_HAVE_STDINT -g -O2 -Wall -D_REENTRANT -g -O2 -Wall
-DCI_BUILD_MODULE -I/usr/local /c_icap/include/c_icap -module -avoid-version -z defs
-static /usr/local/lib/libmongoc.a -o srv.la -rpath /usr/local/lib/c_icap_modules
srv_la-srv.lo -lrt -lcre2 -lre2 -lcurl -lpthread -lbson
*** Warning: Linking the shared library srv_elastica.la against the
*** static library /usr/local/lib/libmongoc.a is not portable!
libtool: link: ar cru .libs/srv.a /usr/loc/lib/libmongoc.a
.libs/srv_la-srv.o
2番目のものは正しいリンカー行(-shared )を生成してsrv.soを出力します
/bin/bash ../../libtool --tag=CC --mode=link gcc -I../../include/ -Wno-unused-label
-DMONGO_HAVE_STDINT -g -O2 -Wall -D_REENTRANT -g -O2 -Wall -DCI_BUILD_MODULE -I/usr
/local/c_icap/include/c_icap -module -avoid-version -z defs --static /usr/local
/lib/libmongoc.a -o srv.la -rpath /usr/local/lib/c_icap_modules srv_la-srv.lo
-lrt -lcre2 -lre2 -lcurl -lpthread -lbson
*** Warning: Linking the shared library srv_elastica.la against the
*** static library /usr/local/lib/libmongoc.a is not portable!
libtool: link: gcc -shared -fPIC -DPIC .libs/srv_la-srv.o
/usr/local/lib/libmongoc.a -lrt -lcre2 -lre2 /usr/lib/x86_64-linux-gnu/libcurl.so
-lpthread -lbson -O2 -O2 -Wl,-soname -Wl,srv.so -o .libs/srv.so
これは奇妙なことです。この種のldのマンページには何も言及されていません。何か助けはありますか?