1

ecpg can find EXEC SQL INCLUDE header files just fine when run from the directory containing the source, but not from any other directory.

Here is an illustration. Successful compile:

> ecpg -o dbconnect.c dbconnect.pgc

Missing include parameter so expected to fail:

> cd ..
> ecpg -o src/dbconnect.c src/dbconnect.pgc
src/dbconnect.pgc:28: ERROR: could not open include file "vet_config.h" on line 28

Add ecpg include parameter. Still fails:

> ecpg -I src -o src/dbconnect.c src/dbconnect.pgc 
src/dbconnect.pgc:28: ERROR: could not open include file "vet_config.h" on line 28

I've tried specifying the absolute path to the src directory. No improvement. I'm aware that the -o is not necessary.

I'm using PostgreSQL 9.2. Here is the version information from ecpg:

> ecpg -v -I src -o src/dbconnect.c src/dbconnect.pgc 
ecpg, the PostgreSQL embedded C preprocessor, version 4.8.0
EXEC SQL INCLUDE ... search starts here:
 src
 .
 /usr/local/include
 /usr/pgsql-9.2/include
 /usr/include
end of search list
kithril
  • 1,183
  • 2
  • 12
  • 22
  • Your example works for me. – Peter Eisentraut Jul 16 '13 at 16:22
  • I am baffled as to where to go from here. I've tried numerous variations. I tried downloading the source and debugging it, but I can't get into the relevant object code which seem to be in a shared object. I know I've debugged shared object code before, so it shouldn't be this hard. Obviously the -v option says the include path is correct. The compiled source code behaves exactly the same way as my current installation. It is using all of the default paths. But it refused to find my header file when moved to a non-default path. – kithril Aug 20 '13 at 05:46

1 Answers1

0

After days of fruitless research and attempts to debug the code, I finally found the answer here on this page: http://www.postgresql.org/docs/9.2/static/ecpg-preproc.html

My whole problem was that I had the filename enclosed in double quotes. From the documentation:

But when EXEC SQL INCLUDE "filename" is used, only the current directory is searched.

I removed the double quotes, and all is well

kithril
  • 1,183
  • 2
  • 12
  • 22