Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

APRE options

At first, We recommend you to read manuals for APRE (http://atc.altibase.com/sub09/551b/html/Precompiler/ch02s02.html)

Makefile

Sample Makefile.

Code Block
none
none
connect1.cpp: connect1.sc
              apre -t cpp connect1.sc

connect1: connect1.cpp
          $(LD) -o connect1 connect1.cpp -I${ALTIBASE_HOME}/include -L${ALTIBASE_HOME}/lib -lapre -lodbccli
  • You can see a makefile in $ALTIBASE_HOME/sample/APRE directory.
  • You need to specify system-libraries which is defined at $ALTIBASE_HOME/install/altibase_env.mk (For example, In Linux, "LIBS= -ldl -lpthread -lcrypt -lrt")

In Linux, Sample makefile

Code Block
none
none
LD=g++

connect1.cpp: connect1.sc
              apre -t cpp connect1.sc

connect1: connect1.cpp
          $(LD) -o connect1 connect1.cpp -I${ALTIBASE_HOME}/include -L${ALTIBASE_HOME}/lib -lapre -lodbccli -ldl -lpthread -lcrypt -lrt
Info

ALTIBASE HDB supports gnumake by default.

 

Errors during Compilation

  1. If you don't define directory of header-files for APRE.
    Code Block
    none
    none
    as48-x64#~/work/altibase_home/sample/APRE] make -f makefile connect1
    g++ -o connect1 connect1.cpp
    connect1.cpp:9:29: ulpLibInterface.h: No such file or directory     <=== here
    connect1.cpp: In function `int main()':
    
  2. If you don't define directory of library-files for APRE.
    Code Block
    none
    none
    as48-x64#~/work/altibase_home/sample/APRE] make -f makefile connect1
    g++ -o connect1 connect1.cpp -I/home/lim272/work/altibase_home/include
    /tmp/ccrXuPio.o: In function `main':
    connect1.cpp:(.text+0x122): undefined reference to `ulpGetSqlca'    <=== here
    connect1.cpp:(.text+0x12e): undefined reference to `ulpGetSqlcode'
    connect1.cpp:(.text+0x13a): undefined reference to `ulpGetSqlstate'
    connect1.cpp:(.text+0x17a): undefined reference to `ulpDoEmsql'
    connect1.cpp:(.text+0x1cf): undefined reference to `ulpGetSqlca'
    
  3. If you specify wrong compile-bit.
    Code Block
    none
    none
    as48-x64#~/work/altibase_home/sample/APRE] make -f makefile connect1
    g++ -m32 -o connect1 connect1.cpp -I/home/lim272/work/altibase_home/include -L/home/lim272/work/altibase_home/lib  -lapre -lodbccli -ldl -lpthread -lcrypt -lrt
    /usr/local/bin/ld: skipping incompatible /home/lim272/work/altibase_home/lib/libapre.a when searching for -lapre
    /usr/local/bin/ld: cannot find -lapre
    collect2: ld returned 1 exit status
    
    Linker can not find a valid library because of wrong compile-bit.
    Check library-bit
    Code Block
    none
    none
    /home/lim272/work/altibase_home/lib/libapre_sl.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
    
    as48-x64#~/work/altibase_home/sample/APRE] file $ALTIBASE_HOME/bin/apre
    /home/lim272/work/altibase_home/bin/apre: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped
    
  4. If you don't define system-library-files for APRE.
    Code Block
    none
    none
    as48-x64#~/work/altibase_home/sample/APRE] make -f makefile connect1
    g++ -o connect1 connect1.cpp -I/home/lim272/work/altibase_home/include -L/home/lim272/work/altibase_home/lib  -lapre -lodbccli
    /home/lim272/work/altibase_home/lib/libapre.a(ulpLibInterface.o): In function `ulpGetSqlca':
    ulpLibInterface.cpp:(.text+0x49e): undefined reference to `pthread_once'
    ulpLibInterface.cpp:(.text+0x55a): undefined reference to `pthread_getspecific'
    /home/lim272/work/altibase_home/lib/libapre.a(ulpLibInterface.o): In function `ulpGetSqlcode':
    
    This sample message can be occured in LINUX system. (This message can be varied by compiler) We need "-ldl -lpthread -lcrypt -lrt
    Code Block
    none
    none
    as48-x64#~/work/altibase_home/sample/APRE] make -f makefile connect1
    g++ -o connect1 connect1.cpp -I/home/lim272/work/altibase_home/include -L/home/lim272/work/altibase_home/lib  -lapre -lodbccli -ldl -lpthread -lcrypt -lrt
    as48-x64#~/work/altibase_home/sample/APRE] ./connect1
    <CONNECT 1>
    ------------------------------------------------------------------
    [Connect]
    ------------------------------------------------------------------
    Success connection to altibase server