简体   繁体   中英

How do I add Allegro (or any library) to the header include path on Mac?

I had no problem with Allegro while using Linux, but I can't figure out how to include the library on OS X. I built it from source originally, but I uninstalled it to try the MacPorts version. The headers are currently in /opt/local/include/allegro5/ .

I can't use #include <allegro5/allegro.h> or

#include "/opt/local/include/allegro5/allegro.h" .

Based on the compile errors, I think the Allegro headers reference each other by

#include <allegro5/other_header.h> .

So how do I add the allegro5 directory to the include path for gcc/g++?

Thanks!

Based on the data in this post, it looks like the correct include path is /opt/local/include . When gcc/g++ attempts to #include <allegro5/allegro.h>, it will add that relative path to the base include paths in its list in order to eventually form the string /opt/local/include/allegro5/allegro.h where it will locate a proper file.

If you're compiling via command line with gcc/g++, add the option -I/opt/local/include . If you're using Xcode, well, I'm not so familiar with that, but I'm confident that you would need to dig around in the project's settings and find a UI widget that allows you to add additional include paths.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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