Wie legt man Include Pfade global an?

T

THeVega

Grünschnabel
Hallo @ll,
Gibt es eine Möglichkeit, bestehende Include Verzeichnisse, z.b /opt/lotus/notesapi/include irgendwo Global zu deklarieren, so daß der Compiler bei einem #include <test.h> auch dort nach der Header Datei test.h sucht?
 
Aus

Code:
man gcc

-I dir
Add the directory dir to the list of directories to be searched for header files. Directories named by -I are searched before the standard system include directories.
If the directory dir is a standard system include directory, the option is ignored to ensure that the default search order for system directories and the special treat-
ment of system headers are not defeated .
 
Hallo!

So musst du aber bei jedem Aufruf des gcc die Option "-I" manuell mit angeben. Ich denke was THeVega wollte ist, dass der zusätzliche Include-Pfad automatisch bei jedem Kompilieren mit verwendet wird.

Dafür bietet sich die Umgebungsvariable CPATH an:
CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH

Each variable's value is a list of directories separated by a special character, much like PATH, in which to look for header files. The special character, PATH_SEPARATOR, is target-dependent and determined at GCC build time. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets it is a colon.

CPATH specifies a list of directories to be searched as if specified with -I, but after any paths given with -I options on the command line. This environment variable is used regardless of which language is being preprocessed.
[...]
In all these variables, an empty element instructs the compiler to search its current working directory. Empty elements can appear at the beginning or end of a path. For instance, if the value of CPATH is :/special/include, that has the same effect as `-I. -I/special/include'.
Quelle: http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html

Wenn du diese Umgebungsvariable in die entsprechende globale Konfigurationsdatei (z.B. /etc/environment) einträgst, wird sie für jeden Benutzer automatisch gesetzt. Siehe https://help.ubuntu.com/community/EnvironmentVariables für weitere Informationen zu Umgebungsvariablen.

Gruß,
Philip
 
Zuletzt bearbeitet:

Ähnliche Themen

Kunden-Skript ausgelöst durch Linux-Cluster Pacemaker

Nginx: Virtuellen Unterordner im SCRIPT_FILENAME entfernen.

Amarok streikt bei *.m4a Dateien

CentOS - Samba Einrichtung will einfach nicht funktionieren

Wie bewegt Ihr zügig große Datenmengen von A nach B?

Zurück
Oben