简体   繁体   English

如何在Makefile中正确引用GNU Readline库?

[英]How do I properly reference the GNU Readline Library in a Makefile?

I have the following line which I used to compile my current C project with the GNU Readline library in the terminal: 我有以下代码行,用于在终端中使用GNU Readline库编译当前的C项目:

gcc code.c -L/usr/local/lib -I/usr/local/include -lreadline

How would I include this information in a Makefile so I could avoid typing this in every time I want to compile my project? 我如何将这些信息包含在Makefile中,以便避免在每次要编译项目时都键入此信息? Thanks in advance! 提前致谢!

You really should read the Makefile documentation and try to do this yourself. 您确实应该阅读Makefile文档并尝试自己做。 You wouldn't need to read far as that's pretty much Makefiles 101. Here is a very simple example to get you started. 您几乎不需要阅读太多内容,因为Makefiles 101非常多。这是一个非常简单的示例,可以帮助您入门。 You can do much better than this. 您可以做得比这更好。

my_program: code.c
    gcc code.c -L/usr/local/lib -I/usr/local/include -lreadline

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM