TL;DR:如何在 Ubuntu 上使用 FBExport/如何将 Firebird 查询结果导出到 csv 文件。
我想将查询结果从 firebird 数据库导出到 csv 文件。在 Windows 上,我使用 FBExport 做类似的工作。
不幸的是我不知道如何在 Ubuntu 上使用这个工具。
我从下载了包http://www.firebirdfaq.org/fbexport.php
当我尝试运行 ./fbexport 时出现错误:
./fbexport:加载共享库时出错:libfbclient.so.2:无法打开共享对象文件:没有此文件或目录
我也尝试编译包。
首先我更改了make
文件:
###############################################################################
.SUFFIXES: .o .cpp
OBJECTS_FBE=fbexport/ParseArgs.o fbexport/FBExport.o fbexport/cli-main.o
OBJECTS_FBC=fbcopy/args.o fbcopy/fbcopy.o fbcopy/TableDependency.o fbcopy/main.o
# Compiler & linker flags
COMPILE_FLAGS=-O1 -DIBPP_LINUX -DIBPP_GCC -Iibpp
LINK_FLAGS=-pthread -lfbclient
#COMPILE_FLAGS=-O1 -DIBPP_WINDOWS -DIBPP_GCC -Iibpp
#LINK_FLAGS=
all: exe/fbcopy exe/fbexport
exe/fbexport: $(OBJECTS_FBE) ibpp/all_in_one.o
g++ $(LINK_FLAGS) ibpp/all_in_one.o $(OBJECTS_FBE) -oexe/fbexport
exe/fbcopy: $(OBJECTS_FBC) ibpp/all_in_one.o
g++ $(LINK_FLAGS) ibpp/all_in_one.o $(OBJECTS_FBC) -oexe/fbcopy
# Linux only
# FB2.0: g++ -pthread -lfbclient $(OBJECTS) -o$(EXENAME)
# FB1.5: g++ -lfbclient $(OBJECTS) -o$(EXENAME)
# FB1.0: g++ -lgds -lcrypt -lm $(OBJECTS) -o$(EXENAME)
install:
install exe/fbcopy /usr/bin/fbcopy
install exe/fbexport /usr/bin/fbexport
.cpp.o:
g++ -c $(COMPILE_FLAGS) -o $@ $<
clean:
rm -f fbcopy/*.o
rm -f ibpp/all_in_one.o
rm -f exe/fbcopy*
rm -f fbexport/*.o
rm -f exe/fbexport*
#EOF
到:
###############################################################################
.SUFFIXES: .o .cpp
OBJECTS_FBE=fbexport/ParseArgs.o fbexport/FBExport.o fbexport/cli-main.o
# Compiler & linker flags
COMPILE_FLAGS=-O1 -DIBPP_LINUX -DIBPP_GCC -Iibpp
LINK_FLAGS=-pthread -lfbclient
#COMPILE_FLAGS=-O1 -DIBPP_WINDOWS -DIBPP_GCC -Iibpp
#LINK_FLAGS=
all: exe/fbexport
exe/fbexport: $(OBJECTS_FBE) ibpp/all_in_one.o
g++ $(LINK_FLAGS) ibpp/all_in_one.o $(OBJECTS_FBE) -oexe/fbexport
# Linux only
# FB2.0: g++ -pthread -lfbclient $(OBJECTS) -o$(EXENAME)
# FB1.5: g++ -lfbclient $(OBJECTS) -o$(EXENAME)
# FB1.0: g++ -lgds -lcrypt -lm $(OBJECTS) -o$(EXENAME)
install:
install exe/fbexport /usr/bin/fbexport
.cpp.o:
g++ -c $(COMPILE_FLAGS) -o $@ $<
clean:
rm -f ibpp/all_in_one.o
rm -f fbexport/*.o
rm -f exe/fbexport*
#EOF
(因为我喜欢只编译 FBExport(不包括 FBCopy))
经过这次改变后,我尝试make
在主文件夹中运行。
输出:
user@apiserver:~/fbexport-1.90$ make
g++ -c -O1 -DIBPP_LINUX -DIBPP_GCC -Iibpp -o fbexport/ParseArgs.o fbexport/ParseArgs.cpp
g++ -c -O1 -DIBPP_LINUX -DIBPP_GCC -Iibpp -o fbexport/FBExport.o fbexport/FBExport.cpp
fbexport/FBExport.cpp: In member function ‘std::string FBExport::CreateHumanString(IBPP::Statement&, int)’:
fbexport/FBExport.cpp:318:29: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
318 | sprintf(str, "%ld", x);
| ~~^ ~
| | |
| | int
| long int
| %d
fbexport/FBExport.cpp:40:21: warning: format ‘%lli’ expects argument of type ‘long long int’, but argument 3 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
40 | #define INT64FORMAT "%lli"
| ^~~~~~
fbexport/FBExport.cpp:351:26: note: in expansion of macro ‘INT64FORMAT’
351 | sprintf(str, INT64FORMAT, int64val);
| ^~~~~~~~~~~
fbexport/FBExport.cpp:40:25: note: format string is defined here
40 | #define INT64FORMAT "%lli"
| ~~~^
| |
| long long int
| %li
fbexport/FBExport.cpp: In member function ‘bool FBExport::CreateString(IBPP::Statement&, int, std::string&)’:
fbexport/FBExport.cpp:429:29: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
429 | sprintf(str, "%ld", x);
| ~~^ ~
| | |
| | int
| long int
| %d
fbexport/FBExport.cpp:435:29: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
435 | sprintf(str, "%ld", d.GetDate());
| ~~^ ~~~~~~~~~~~
| | |
| long int int
| %d
fbexport/FBExport.cpp:440:29: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
440 | sprintf(str, "%ld", t.GetTime());
| ~~^ ~~~~~~~~~~~
| | |
| long int int
| %d
fbexport/FBExport.cpp:40:21: warning: format ‘%lli’ expects argument of type ‘long long int’, but argument 3 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
40 | #define INT64FORMAT "%lli"
| ^~~~~~
fbexport/FBExport.cpp:462:26: note: in expansion of macro ‘INT64FORMAT’
462 | sprintf(str, INT64FORMAT, int64val);
| ^~~~~~~~~~~
fbexport/FBExport.cpp:40:25: note: format string is defined here
40 | #define INT64FORMAT "%lli"
| ~~~^
| |
| long long int
| %li
fbexport/FBExport.cpp: In member function ‘int FBExport::Export(IBPP::Statement&, FILE*)’:
fbexport/FBExport.cpp:487:18: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
487 | register int fc = st->Columns();
| ^~
fbexport/FBExport.cpp:491:23: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
491 | for (register int i=1; i<=fc; i++)
| ^
fbexport/FBExport.cpp:505:27: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
505 | for (register int i=1; i<=fc; i++) // ... export all fields to file.
| ^
fbexport/FBExport.cpp: In member function ‘int FBExport::ExportHuman(IBPP::Statement&, FILE*)’:
fbexport/FBExport.cpp:829:18: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
829 | register int fc = st->Columns();
| ^~
fbexport/FBExport.cpp:835:27: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
835 | for (register int i=1; i<=fc; i++) // output CSV header.
| ^
fbexport/FBExport.cpp:847:27: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
847 | for (register int i=1; i<=fc; i++) // ... export all fields to file.
| ^
fbexport/FBExport.cpp:860:27: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
860 | for (register int i=1; i<=fc; i++) // output CSV header.
| ^
fbexport/FBExport.cpp:875:27: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
875 | for (register int i=1; i<=fc; i++) // ... export all fields to file.
| ^
fbexport/FBExport.cpp: In function ‘int statement_length(FILE*)’:
fbexport/FBExport.cpp:1335:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1335 | register int c = 0, tmp = 0;
| ^
fbexport/FBExport.cpp:1335:31: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1335 | register int c = 0, tmp = 0;
| ^~~
fbexport/FBExport.cpp:1336:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1336 | register int l = 0;
| ^
fbexport/FBExport.cpp: In function ‘char* read_statement(char*, int, FILE*)’:
fbexport/FBExport.cpp:1376:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1376 | register int c = 0, tmp = 0;
| ^
fbexport/FBExport.cpp:1376:31: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1376 | register int c = 0, tmp = 0;
| ^~~
fbexport/FBExport.cpp:1377:25: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
1377 | register char *P;
| ^
fbexport/FBExport.cpp: In member function ‘std::string FBExport::CreateHumanString(IBPP::Statement&, int)’:
fbexport/FBExport.cpp:339:17: warning: ignoring return value of ‘char* gcvt(double, int, char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
339 | gcvt(fval, 19, str);
| ~~~~^~~~~~~~~~~~~~~
fbexport/FBExport.cpp:345:17: warning: ignoring return value of ‘char* gcvt(double, int, char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
345 | gcvt(dval, 19, str);
| ~~~~^~~~~~~~~~~~~~~
fbexport/FBExport.cpp: In member function ‘bool FBExport::CreateString(IBPP::Statement&, int, std::string&)’:
fbexport/FBExport.cpp:452:17: warning: ignoring return value of ‘char* gcvt(double, int, char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
452 | gcvt(fval, 19, str);
| ~~~~^~~~~~~~~~~~~~~
fbexport/FBExport.cpp:457:17: warning: ignoring return value of ‘char* gcvt(double, int, char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
457 | gcvt(dval, 19, str);
| ~~~~^~~~~~~~~~~~~~~
fbexport/FBExport.cpp: In member function ‘int FBExport::Import(IBPP::Statement&, FILE*)’:
fbexport/FBExport.cpp:706:26: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
706 | fread(buff, size, 1, fp);
| ~~~~~^~~~~~~~~~~~~~~~~~~
fbexport/FBExport.cpp: In member function ‘int FBExport::Init(Arguments*)’:
fbexport/FBExport.cpp:1211:41: warning: ‘__builtin___sprintf_chk’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
1211 | sprintf(num, "%d", i+1);
| ^
In file included from /usr/include/stdio.h:888,
from /usr/include/c++/11/cstdio:42,
from /usr/include/c++/11/ext/string_conversions.h:43,
from /usr/include/c++/11/bits/basic_string.h:6606,
from /usr/include/c++/11/string:55,
from ibpp/ibpp.h:91,
from fbexport/FBExport.cpp:44:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:38:34: note: ‘__builtin___sprintf_chk’ output between 2 and 11 bytes into a destination of size 10
38 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
g++ -c -O1 -DIBPP_LINUX -DIBPP_GCC -Iibpp -o fbexport/cli-main.o fbexport/cli-main.cpp
g++ -c -O1 -DIBPP_LINUX -DIBPP_GCC -Iibpp -o ibpp/all_in_one.o ibpp/all_in_one.cpp
g++ -pthread -lfbclient ibpp/all_in_one.o fbexport/ParseArgs.o fbexport/FBExport.o fbexport/cli-main.o -oexe/fbexport
在这种情况下我能做什么?
问候 Tomasz