[Emacs-ada-mode] $ADA_INCLUDE_PATH problems

Stephen Leake stephen_leake at stephe-leake.org
Tue Jan 13 03:49:14 PST 2009


Joe Schafer <joseph.schafer at usma.edu> writes:

> I'm trying to compile a single file.  I have a couple of packages in a
> separate folder that I put in $ADA_INCLUDE_PATH.  The Gnat users guide
> says it automatically searches these directories.  The problem is that I
> get different results compiling in bash and compiling from within emacs
> ada mode.  I have the same problem when starting with "emacs -Q" so it's
> not any of my customizations.
>
> $ echo $ADA_INCLUDE_PATH 
> /usr/local/lib/ada:.
>
> --compiling from bash
> $ gnatmake hw2
> gcc-4.3 -c hw2.adb
> gcc-4.3 -c -I./ -I- /usr/local/lib/ada/testing.adb
> gnatbind -x hw2.ali
> gnatlink hw2.ali

Note that this compiles _two_ files (hw2.adb and testing.adb), not a
"single file" as you stated above. 

> --compiling from ada-mode
> gnatmake -o hw2 hw2 -g -cargs -gnatq -gnatQ -bargs  -largs 
> gcc-4.3 -c -g -gnatq -gnatQ hw2.adb
> hw2.adb:5:40: file "testing.ads" not found

It appears that ADA_INCLUDE_PATH is not inherited by the Emacs
process. To test this, start a bash shell under Emacs (M-x shell), and
see what the value of ADA_INCLUDE_PATH is there. Or execute (getenv
"ADA_INCLUDE_PATH") in the scratch buffer.

Most likely you are not starting Emacs from the process where
ADA_INCLUDE_PATH is set. Environment variables are not "global"; they
are inherited from the parent (not sibling) process.

> I tried adding $ADA_INCLUDE_PATH to ada-search-directories, but that
> didn't seem to have any effect.

ada-search-directories is only used by Emacs, not by the gnat compiler.


I always to do everything from within Emacs, and set the required
environment variables in .emacs, or in a Makefile. That way I don't
have to worry about .bash_profile vs .bashrc etc.

It's also better to set search paths in GNAT project files; that way
they will be the same for both GNAT and Emacs. But you can learn how
to do that later.

-- 
-- Stephe



More information about the Emacs-ada-mode mailing list