eulerto / pgquarrel

pgquarrel compares PostgreSQL database schemas (DDL)
BSD 3-Clause "New" or "Revised" License
388 stars 42 forks source link

Make Fails (fatal error: c.h not found) #31

Closed chseip closed 7 years ago

chseip commented 7 years ago

cmake works well but make afterwards fails. It doesn't matter if I'm using the current Git clone or the 0.2 release. Any help much appreciated, thanks :-)

Here's the make process:

cseip@h2441487:~/pgquarrel-pgquarrel_0_2_0$ make
Scanning dependencies of target mini
[  3%] Building C object mini/CMakeFiles/mini.dir/mini-file.c.o
[  7%] Building C object mini/CMakeFiles/mini.dir/mini-parser.c.o
[ 10%] Building C object mini/CMakeFiles/mini.dir/mini-readline.c.o
[ 14%] Building C object mini/CMakeFiles/mini.dir/mini-strip.c.o
Linking C shared library libmini.so
[ 14%] Built target mini
Scanning dependencies of target pgquarrel
[ 17%] Building C object CMakeFiles/pgquarrel.dir/src/aggregate.c.o
In file included from /home/cseip/pgquarrel-pgquarrel_0_2_0/src/aggregate.h:4:0,
                 from /home/cseip/pgquarrel-pgquarrel_0_2_0/src/aggregate.c:1:
/home/cseip/pgquarrel-pgquarrel_0_2_0/src/common.h:9:41: fatal error: c.h: No such file or directory
 #include <c.h>   /* bool, true, false */
                                         ^
compilation terminated.
make[2]: *** [CMakeFiles/pgquarrel.dir/src/aggregate.c.o] Error 1
make[1]: *** [CMakeFiles/pgquarrel.dir/all] Error 2
make: *** [all] Error 2
eulerto commented 7 years ago

@chseip What is your OS version? Did you install postgresql-devel (Red Hat-like) or postgresql-server-dev (Debian-like)? If you compile postgres, use:

cmake -DCMAKE_INSTALL_PREFIX=/tmp/pgquarrel -DCMAKE_PREFIX_PATH=/home/euler/pg962 .

chseip commented 7 years ago

I think its Ubuntu 14.04. Don't know how Postgres was installed, it was already on the server, guess it was installed using apt-get. Does this have something to do with your tool? Really can't imagine that, but thanks for your fast reply so far :-) edit: it's Postgres 9.3.7 edit2: to be precise it's Ubuntu 14.04.2 LTS

chseip commented 7 years ago

just tried it in a VM (Ubuntu 15.10 with pg 9.4). I even fail with cmake, no matter what I try:

cmake .
cmake -DCMAKE_PREFIX_PATH==/usr/lib/postgresql/9.4/ .
cmake -DPostgreSQL_INCLUDE_DIR=/usr/lib/postgresql/9.4/ .

Result is always this error:

CMake Error at /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.2/Modules/FindPostgreSQL.cmake:169 (find_package_handle_standard_args)
  CMakeLists.txt:66 (find_package)

edit: although it does not seem to make sesne to me, I tried this as well cmake -DCMAKE_INSTALL_PREFIX=/tmp/pgquarrel -DCMAKE_PREFIX_PATH=/home/euler/pg962 . as expected did not work as well Made a cmake build with these parameters on the other machine as well, still the same error with make...

eulerto commented 7 years ago

@chseip It seems you are using wrong CMAKE_PREFIX_PATH. Try the same path as returned by 'pg_config --configure' (--prefix).

chseip commented 7 years ago

So, I digged deep into this. When I do pg_config --configure on the server this is the output:

'--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' '--with-tclconfig=/usr/lib/x86_64-linux-gnu/tcl8.6' '--with-includes=/usr/include/tcl8.6' 'PYTHON=/usr/bin/python' '--mandir=/usr/share/postgresql/9.3/man' '--docdir=/usr/share/doc/postgresql-doc-9.3' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/9.3' '--bindir=/usr/lib/postgresql/9.3/bin' '--libdir=/usr/lib/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--enable-nls' '--enable-integer-datetimes' '--enable-thread-safety' '--enable-debug' '--disable-rpath' '--with-ossp-uuid' '--with-gnu-ld' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5' '--with-krb5' '--with-gssapi' '--with-ldap' 'CPPFLAGS=-D_FORTIFY_SOURCE=2'

When I run cmake -DCMAKE_PREFIX_PATH=/usr/lib/postgresql/9.3/bin/pg_config -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/lib/postgresql/9.3/bin/pg_config . (tried also without /bin/pg_config) cmake is fine but make gives the same error as my original post....

Now I decided to setup a fresh Ubuntu 16.04 VM and these were my exact steps:

sudo apt-get install postgresql postgresql-contrib pgadmin3
sudo apt-get install postgresql-9.5-postgis-2.2 postgis
sudo apt-get install git
sudo apt-get install libpq-dev #because otherwise pg_config --configure won't work
git clone https://github.com/eulerto/pgquarrel.git
sudo apt-get install cmake
cmake -DCMAKE_PREFIX_PATH=/usr/bin/pg_config -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/lib/postgresql/9.5 .

make fails again exactly like all other tries...

ah, pg_config --configure output of the VM is:

'--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' '--with-tclconfig=/usr/lib/x86_64-linux-gnu/tcl8.6' '--with-includes=/usr/include/tcl8.6' 'PYTHON=/usr/bin/python' '--mandir=/usr/share/postgresql/9.5/man' '--docdir=/usr/share/doc/postgresql-doc-9.5' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/9.5' '--bindir=/usr/lib/postgresql/9.5/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--enable-nls' '--enable-integer-datetimes' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5' '--with-krb5' '--with-gssapi' '--with-ldap' '--with-selinux' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
SashaBorandi commented 7 years ago
cmake -DCMAKE_PREFIX_PATH=/usr/bin/pg_config -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/<VERSION>/server .
eulerto commented 7 years ago

For the record, I checked Ubuntu and it is necessary to install postgresql-server-dev-x.y package. I don't know why cmake does not detect PostgreSQL in a popular distro (indeed it detect but fails to figure out type-include-dir). The following cmake command could do the trick:

cmake -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/9.6/server -DCMAKE_INSTALL_PREFIX=/my/install/path .

colearendt commented 6 years ago

Just as a reference if others are experiencing the same make error after a successful cmake. I was using an incorrect -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/9.6/server/catalog since that is where the pg_type.h is... The fix was to use the directory referenced above:

cmake -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/9.6/server .