ecpg can't find includes unless executed from the directory containing the source files

StackOverflow https://stackoverflow.com/questions/17647090

  •  03-06-2022
  •  | 
  •  

Question

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
Was it helpful?

Solution

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

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