Help Center/
GaussDB/
Developer Guide(Distributed_3.x)/
Application Development Guide/
Development Based on libpq/
Development Process
Updated on 2024-05-07 GMT+08:00
Development Process
To compile and develop source programs based on libpq, perform the following steps:
- Decompress the GaussDB-Kernel_Database version number_OS version number_64bit_Libpq.tar.gz file. The required header file is stored in the include folder, and the lib folder contains the required libpq library file.
In addition to libpq-fe.h, the include folder contains the header files postgres_ext.h, gs_thread.h, and gs_threadlocal.h by default. These three header files are the dependency files of libpq-fe.h.
- Develop the source program testlibpq.c. The source code file needs to reference the header file provided by libpq.
Example: #include <libpq-fe.h>
- To compile the libpq source program by running gcc, use the -I directory option to provide the installation location of the header file. (Sometimes the compiler looks for the default directory, so this option can be ignored.)
gcc -I (Directory where the header file is located) -L (Directory where the libpq library is located) testlibpq.c -lpq
Example:gcc -I $(GAUSSHOME)/include/libpq -L $(GAUSSHOME)/lib -lpq testlibpq.c -o testlibpq
- If the makefile is used, add the following option to variables CPPFLAGS, LDFLAGS, and LIBS:
CPPFLAGS += -I (Directory of the header file) LDFLAGS += -L (Directory of the libpq library) LIBS += -lpq
Example:CPPFLAGS += -I$(GAUSSHOME)/include/libpq LDFLAGS += -L$(GAUSSHOME)/lib
Parent topic: Development Based on libpq
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot