0

TL;DR : How use FBExport on Ubuntu / how export Firebird query result to csv file.

I would to like export query result from firebird database to csv file. On Windows I do similary job using FBExport.

Unfortunetly I don't know use this tool on Ubuntu.

I downloaded pack from http://www.firebirdfaq.org/fbexport.php

When I try run ./fbexport i got error:

./fbexport: error while loading shared libraries: libfbclient.so.2: cannot open shared object file: No such file or directory

Also I tried compile pack.

First I changed make file from:

###############################################################################
.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

to:

###############################################################################
.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

(because I like to compile only FBExport (excluding FBCopy))

After this change I tried run make in main folder.

Output:

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

What can I do in this case?

Regards Tomasz

  • Hi, as a workaround, can you copy the firebird database to a Windows machine to do the task ? I ask as I know firebird database is single file – yagmoth555 Apr 04 '22 at 19:51
  • @yagmoth555 - thanks for your reply. I can't do this. Database is huge. I need only about 1% data. – Tomasz Filipek Apr 05 '22 at 05:07

0 Answers0