1

Ubuntu has libiconv built-in to it’s standard c library and does not require it in LDFLAGS. OS X does not have it built-in and requires the flag to be set.

My current approach is using ifeq in my Makefile to conditionally set LDFLAG += -liconv when on OS X.

I am wondering if there is a better approach? I am heavily influenced by the feature-detection mindset of web development and hope I can use a similar approach to detect whether the flag is required on the current system or not.

4

1 回答 1

0

对于手动编写的makefile,单独设置LDFLAGS和朋友的内容是一种可接受的方式。如果只需要几个功能,这可能会更简单。

如果您想普遍检测该功能,那么一条路线是使用诸如CMakeAutomake之类的 makefile 生成器。

最后一个选项是手动执行 Automake 所做的运行时检查。那就是有一个您编译的示例文件,与其中一个选项链接并查看它是否有效。如果它不尝试下一个等等。这样您就可以测试每个功能需要哪些标志。Automake 仅在项目为./configured 时执行此操作,但您可以在每次make运行或任何时候对您的构建设置有利时执行此操作。

于 2012-11-30T12:27:08.040 回答