ibarwick / fbsql

fbsql is a simple command-line client for the Firebird database, inspired by PostgreSQL's psql
10 stars 0 forks source link

Compilation error #5

Closed mkgrgis closed 1 year ago

mkgrgis commented 1 year ago

Ubuntu, gcc, make

cd 'fbsql-master'
configure --prefix='/usr';

output

checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for string.h... (cached) yes
checking for stdlib.h... (cached) yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for gettimeofday... yes
checking for memmove... yes
checking for memset... yes
checking for strchr... yes
checking for strdup... yes
checking for strstr... yes
checking for strtol... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking dependency style of gcc... gcc3
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... -lfl
checking whether yytext is a pointer... yes
checking for bison... bison -y
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands

make or sudo make install output

Making all in src
make[1]: ディレクトリ 'fbsql-master/src' に入ります
gcc  -g -O2 -lfq -lfbclient -lreadline -lm  -o fbsql main.o common.o input.o inputloop.o tab-complete.o command.o command_test.o query.o strlcpy.o pgstrcasecmp.o fbsqlscan.o  
/usr/bin/ld: tab-complete.o: warning: relocation against `rl_completion_append_character' in read-only section `.text'
/usr/bin/ld: main.o: in function `main':
fbsql-master/src/main.c:103: undefined reference to `FQconnectdbParams'
/usr/bin/ld: fbsql-master/src/main.c:105: undefined reference to `FQstatus'
/usr/bin/ld: fbsql-master/src/main.c:112: undefined reference to `FQserverVersionString'
/usr/bin/ld: fbsql-master/src/main.c:113: undefined reference to `FQclientEncodingId'
...

many errors about undefined reference to FQ... In this environment libfq and firebird_fwd have been successfully compiled with no errors and no warnings and works in PostgreSQL.

find /usr -iname "*libfq*" output

/usr/lib/libfq-0.5.0.so
/usr/lib/libfq.so
/usr/lib/libfq.a
/usr/lib/libfq.la
/usr/include/libfq.h
/usr/include/libfq-expbuffer.h
/usr/include/libfq-int.h
ibarwick commented 1 year ago

Not sure why or when this started happening, but for whatever reason gcc does not consider libraries specified before the object files when linking; previously this was being generated:

gcc  -g -O2 -lfq -lfbclient -lreadline -lm  -o fbsql main.o common.o input.o inputloop.o tab-complete.o command.o command_test.o query.o strlcpy.o pgstrcasecmp.o fbsqlscan.o

Fixed so it builds with this invocation:

gcc  -g -O2   -o fbsql main.o common.o input.o inputloop.o tab-complete.o command.o command_test.o query.o strlcpy.o pgstrcasecmp.o fbsqlscan.o -lfq -lfbclient -lreadline -lm 
mkgrgis commented 1 year ago

Thanks, @ibarwick ! fbsql works fine. I'm going to debug https://github.com/ibarwick/fbsql/issues/1. Now there is only some code-style warnings like https://github.com/ibarwick/fbsql/issues/4.