User forums > Using Code::Blocks
Compiling with libpq-fe.h
(1/1)
gcclinux:
Hello,
I have now tried adding in link tab, directory search and everything I can think off but I can not get it to work in CodeBlocks...
Command line works:
$ gcc -o server_version server_version.c -I/usr/include/postgresql -L/usr/lib/postgresql/12/lib/ -lpq -std=c99
Error from Build Log in CodeBlocks :
-------------- Build: Release in postgresql (compiler: GNU GCC Compiler)---------------
gcc -Wall -I/usr/include/postgresql -I/usr/lib/postgresql/12/lib/ -c /home/ricardo/Programming/c/postgresql/server_version.c -o obj/Release/server_version.o
g++ -o bin/Release/postgresql obj/Release/server_version.o
/home/ricardo/Programming/c/postgresql/server_version.c:3:22: fatal error: libpq-fe.h: No such file or directory
#include <libpq-fe.h>
^
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Please can someone assist as I am trying postgresql for the first time and codeblocks is not helping me :-)
BlueHazzard:
--- Code: ---gcc -Wall -I/usr/include/postgresql -I/usr/lib/postgresql/12/lib/ -c /home/ricardo/Programming/c/postgresql/server_version.c -o obj/Release/server_version.o
g++ -o bin/Release/postgresql obj/Release/server_version.o
/home/ricardo/Programming/c/postgresql/server_version.c:3:22: fatal error: libpq-fe.h: No such file or directory
#include <libpq-fe.h>
--- End code ---
Why is there a g++ ?
Are you mixing cpp and c files?
Are you using a project?
Miguel Gimenez:
Have you tested #include "libpq-fe.h" (with double quotes, not angle brackets)?
Also, in the command line that works you have
--- Code: ----L/usr/lib/postgresql/12/lib/
--- End code ---
but in the generated one you have
--- Code: ----I/usr/lib/postgresql/12/lib/
--- End code ---
This is because you put /usr/lib/postgresql/12/lib in the compiler search path, but it must go in the linker search path.
Navigation
[0] Message Index
Go to full version