简体   繁体   English

为给定库生成 gcc 的编译器/链接器标志

[英]Generate compiler/linker flags for gcc, given library

Problem问题

Is there a way I can generate linker/compiler flags for function libraries, given one or more source files?给定一个或多个源文件,有没有一种方法可以为 function 库生成链接器/编译器标志?

Details细节

Software specifications:软件规格:

  • Operating System: Ubuntu 20.04 LTS x86_64操作系统: Ubuntu 20.04 LTS x86_64
  • Kernel: 5.11.0-27-generic Kernel: 5.11.0-27-generic

There's a handy tool you can use to generate compiler/linker flags for your code.您可以使用一个方便的工具为您的代码生成编译器/链接器标志。 It's called pkg-config , and you can use it like so:它称为pkg-config ,您可以像这样使用它:

gcc file.c $(pkg-config --cflags <library>) $(pkg-config --libs <library>)

I'd recommend defining a variable containing all of your dependencies, then using a shell script or other means to generate the pkg-config output for that library.我建议定义一个包含所有依赖项的变量,然后使用 shell 脚本或其他方式为该库生成pkg-config output。

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

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