Question

When compiling projects that make use of libraries installed via MacPorts (boost, opencv, etc) I need to pass clang the library and include file locations via the -I and -L arguments.

Is there any "official" way to direct the Apple native clang look in these locations by default.

I guess I could just make a bash script with something to the effect of

clang -I/opt/local/include -L/opt/local/lib %@

and call that instead of the compiler, but is there a cleaner way to point clang to these locations automatically?

I am not looking for an Xcode based fix, instead I would like to be able to compile from the command line without having to manually type the above arguments in each time.

Any suggestions?

Was it helpful?

Solution

I had a similar question answered on the MacPorts mailing list[0].

Export these environment variables.

export CPPFLAGS='-isystem/opt/local/include'
export LDFLAGS='-L/opt/local/lib'

P.S. Hope you've not been waiting this long for an answer :)

[0] https://lists.macports.org/pipermail/macports-users/2017-July/043562.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top