automake 用于创建库和使用它的程序
我正在尝试开发一个程序,该程序使用在同一项目中完成的另一个内部库。
我想将两者链接起来。该库已在 ./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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
Makefile
可能如下所示。请注意,
*_CPPFLAGS
通常不应与*_CFLAGS
混合使用,并且$(CFLAGS)
和$(CPPFLAGS)< /code> 变量总是被使用(它们是用户变量),所以你不必提及它们。另外
INCLUDES
是一个过时的变量(您应该使用*_CPPFLAGS
代替),如果您使用-Wall
运行它,automake 会发出警告。选项。Your
Makefile
could look something like this.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. AlsoINCLUDES
is an obsolete variable (you should use*_CPPFLAGS
instead), and automake will warn about it if you run it with the-Wall
option.