3

私はautotoolsで手を試しています。次のプロジェクト階層があります。

    project/src
    project/src/utilities
    project/src/utilities/util.c
    project/src/utilities/util.h
    project/src/sharedObject
    project/src/sharedObject/sharedObject.c
    project/src/sharedObject/sharedObject.h
    project/src/sharedObject/thing.c
    project/src/executable
    project/src/executable/exec.c
    project/src/executable/exec.h
    project/src/executable/thing1.c
    project/src/executable/thing2.c

"executable"両方ともと"sharedObject.so"に依存し"util.o"ます"util.h"。便利なライブラリを作成する例を見てきました"Makefile.am"が、他の 2 つのサブプロジェクトのファイルでそれらを指定する方法がわかりません。これらの種類のプロジェクト間の依存関係はどのように定義されていますか?

"executable"との両方"sharedObject.so"がインストールされます。およびファイルは"util.o""util.h"ビルド プロセスでのみ使用されます。

ありがとうございました

4

1 に答える 1

3

utilities/Makefile.am

noinst_LTLIBRARIES = libutil.la   
libutil_la_SOURCES = util.h util.c

ではexecutable/Makefile.am、ライブラリの使用にはLDADDプライマリを使用する必要があります。

bin_PROGRAMS = exec
exec_SOURCES = exec.h exec.c thing.h thing.c
exec_LDADD = ../utilities/libutil.la

では、プライマリsharedObject/Makefile.amを使用します。LIBADD

lib_LTLIBRARIES = sharedObject.la
sharedObject_la_SOURCES = sharedObject.h sharedObject.c thing.c
sharedObject_la_LIBADD = ../utilities/libutil.la

実際にsharedObject.soを動的にロードする必要がある場合は、以下も必要です。

sharedObject_la_LDFLAGS = -module

それ以外の場合は、ターゲットを呼び出す必要がありますlibsharedObject


最上位の Makefile.am は、依存関係が最初に構築されるように順序付けする必要があります SUBDIRS

SUBDIRS = utilities executable sharedObject

于 2013-04-16T03:15:55.560 に答える