automake 用于创建库和使用它的程序

发布于 2024-09-15 09:11:58 字数 480 浏览 9 评论 0原文

我正在尝试开发一个程序,该程序使用在同一项目中完成的另一个内部库。

我想将两者链接起来。该库已在 ./lib/mylib 下存储并成功编译,并创建了 mylib.a。问题是我需要在 INCLUDE 搜索中包含 ./lib/mylib 目录,并将程序链接到库。

是否有任何自动定义的变量,或者我必须像下面的 Makefile.am 中那样自己定义变量?

SUBDIRS = lib .

# set the include path found by configure
INCLUDES = $(all_includes) -Ilib/mylib

bin_PROGRAMS = myprogram

myprogram_SOURCES = main.c 
myprogram_CPPFLAGS =  $(libmylib_CFLAGS) $(AM_CFLAGS) $(CFLAGS)
nfc_network_config_LDADD =$(LIB_MYLIB)

I'm trying to develop a program that uses another internal library done in the same project.

I want to link both. The lib is stored and succesfully compiled under ./lib/mylib and a mylib.a is created. The issue is that I need to include ./lib/mylib directory in the INCLUDE search and also link the program against the library.

Are there any automatically defined variables or do I have to do it by my own like in the Makefile.am below?

SUBDIRS = lib .

# set the include path found by configure
INCLUDES = $(all_includes) -Ilib/mylib

bin_PROGRAMS = myprogram

myprogram_SOURCES = main.c 
myprogram_CPPFLAGS =  $(libmylib_CFLAGS) $(AM_CFLAGS) $(CFLAGS)
nfc_network_config_LDADD =$(LIB_MYLIB)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若言繁花未落 2024-09-22 09:11:58

您的 Makefile 可能如下所示。

SUBDIRS = lib .
bin_PROGRAMS = myprogram
myprogram_SOURCES = main.c
myprogram_CPPFLAGS = -Ilib/mylib $(AM_CPPFLAGS) 
myprogram_LDADD = lib/mylib/mylib.a

请注意,*_CPPFLAGS 通常不应与 *_CFLAGS 混合使用,并且 $(CFLAGS)$(CPPFLAGS)< /code> 变量总是被使用(它们是用户变量),所以你不必提及它们。另外 INCLUDES 是一个过时的变量(您应该使用 *_CPPFLAGS 代替),如果您使用 -Wall 运行它,automake 会发出警告。选项。

Your Makefile could look something like this.

SUBDIRS = lib .
bin_PROGRAMS = myprogram
myprogram_SOURCES = main.c
myprogram_CPPFLAGS = -Ilib/mylib $(AM_CPPFLAGS) 
myprogram_LDADD = lib/mylib/mylib.a

Note that *_CPPFLAGS should usually not be mixed with *_CFLAGS, and that the $(CFLAGS) and $(CPPFLAGS) variables are always used (they are user variables) so you should not have to mention them. Also INCLUDES is an obsolete variable (you should use *_CPPFLAGS instead), and automake will warn about it if you run it with the -Wall option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文