OSX fun with pkg-config and Xcode

In the configure script for the release of oacapture that I’m currently working on I’ve made fairly heavy use of pkg-config to determine compiler and linker flags for installed packages and to check installed versions to see if they provide the necessary functionality. Other than the slight niggle that when adding, say, include directory locations for multiple packages can cause duplication of the flags it works very nicely.

When doing development work I prefer to pass the flags -Wall -Werror to the compiler when building my own code and if any warnings cause the build to fail I tidy up the code to fix the problem.

I’ve run into an awkward situation with recent versions of Xcode however. The libusb-1.0 package makes fairly heavy use of static inline functions in its header files and for reasons I’m currently unable to justify to myself Xcode flags a warning if these functions are not used. Of course with the above flags set this halts the build, and I do make fairly heavy use of libusb 🙁

I have discovered that there is a “workaround” whereby replacing the -I compiler flag with -isystem prevents the compiler throwing warnings for files in the specified directory. Seems fairly ugly to me, but there you go. Replacing the flag manually does indeed appear to fix compilation. Of course there’s a problem once you start using flags generated by pkg-config because it still uses -I. There is the temptation to fudge something up to convert -I to -isystem, but it’s really not pretty. I can’t see as I have much choice though, unless Apple care to fix their compiler implementation to work the way a sane person might expect it to.

This entry was posted in Computing, Projects and tagged , , . Bookmark the permalink.

1 Response to OSX fun with pkg-config and Xcode

  1. Pingback: Well that’s not going to work then | www.tanstaafl.co.uk

Leave a Reply

Your email address will not be published. Required fields are marked *