feat: add lib-version

This commit is contained in:
dancingCycle 2023-01-05 12:14:52 +01:00
parent dd56a9cd5b
commit 9130887d03
6 changed files with 116 additions and 0 deletions

9
lib-version/main.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
#include <libpq-fe.h>
int main() {
int lib_ver = PQlibVersion();
printf("Version of libpq: %d\n", lib_ver);
printf("Version of libpq: %d\n", lib_ver);
printf("Version of libpq: %d\n", lib_ver);
return 0;
}

21
lib-version/makefile Normal file
View File

@ -0,0 +1,21 @@
# Docu
#
#$@ is the name of the file to be made
#$? is the names of the changed dependents
#$< the name of the related file that caused the action
#$* the prefix shared by target and dependent files
#
# Others
RM = /bin/rm -f
#
# Source, Executable, Includes, Library Defines
EXE = main
#
# Compiler, Linker Defines
CC = /usr/bin/gcc
#
all:
$(CC) main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99 -Wall -o $(EXE)
# Clean Up Objects, Exectuables, Dumps out of source directory
clean:
$(RM) *.o $(EXE) *~

39
lib-version/makefile-fail Normal file
View File

@ -0,0 +1,39 @@
# Docu
#
#$@ is the name of the file to be made
#$? is the names of the changed dependents
#$< the name of the related file that caused the action
#$* the prefix shared by target and dependent files
#
#CFLAGS:Extra flags to give to the C compiler
#LDFLAGS:Extra flags to give to compilers when they are supposed to invoke the linker, `ld'.
#
# Source, Executable, Includes, Library Defines
INCL =
SRC = main.c
OBJ = $(SRC:.c=.o)
LIBS = -lpq
EXE = main
INC = -I. -I$(pg_config --includedir)
# Compiler, Linker Defines
CC = /usr/bin/gcc
CFLAGS = -std=c99 -Wall
LIBPATH = -L. -L$(pg_config --libdir)
LDFLAGS = -o $(EXE) $(LIBPATH) $(LIBS)
RM = /bin/rm -f
# Compile and Assemble C Source Files into Object Files
%.o: %.c
$(CC) $(INC) $(CFLAGS) -c $*.c
# Link all Object Files with external Libraries into Binaries
$(EXE): $(OBJ)
$(CC) $(LDFLAGS) $(OBJ)
# Objects depend on these Libraries
$(OBJ): $(INCL)
# Clean Up Objects, Exectuables, Dumps out of source directory
clean:
$(RM) $(OBJ) $(EXE)

View File

@ -0,0 +1,21 @@
# Docu
#
#$@ is the name of the file to be made
#$? is the names of the changed dependents
#$< the name of the related file that caused the action
#$* the prefix shared by target and dependent files
#
# Others
RM = /bin/rm -f
#
# Source, Executable, Includes, Library Defines
EXE = main
#
# Compiler, Linker Defines
CC = /usr/bin/gcc
#
all: main.o
$(CC) main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99 -Wall -o $(EXE)
# Clean Up Objects, Exectuables, Dumps out of source directory
clean:
$(RM) *.o $(EXE) *~

21
lib-version/makefile-fine Normal file
View File

@ -0,0 +1,21 @@
# Docu
#
#$@ is the name of the file to be made
#$? is the names of the changed dependents
#$< the name of the related file that caused the action
#$* the prefix shared by target and dependent files
#
# Others
RM = /bin/rm -f
#
# Source, Executable, Includes, Library Defines
EXE = main
#
# Compiler, Linker Defines
CC = /usr/bin/gcc
#
all:
$(CC) main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99 -Wall -o $(EXE)
# Clean Up Objects, Exectuables, Dumps out of source directory
clean:
$(RM) *.o $(EXE) *~

5
lib-version/readme.md Normal file
View File

@ -0,0 +1,5 @@
* build instruction
```
gcc -o main main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99
```