Trying to build static CGO executable with oracle libraries on Linux/Ubuntu

前端 未结 1 380
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 07:48

I have already searched for some days, tried several suggestions but none helped. At the moment I just want to create a small Go snippet which connects to an Oracle Database

相关标签:
1条回答
  • 2021-01-03 08:10
    • Use $ORACLE_HOME/bin/relink tool to generate the library named libclntst.a The st stands for static library. Oracle client is not usually shipped with this file. The
    • Try to link your app with this library. You will most probably find many symbols missing.
    • Use nm tool to find the source of those missing symbols.
    • In case of 11gR2 this command worked for me:

      /usr/bin/c++ -Wall -ggdb3 -fPIC \
       CMakeFiles/opassgen.dir/opassgen.cpp.o \
       CMakeFiles/opassgen.dir/dbutils.cpp.o \
       CMakeFiles/opassgen.dir/common.cpp.o  \
       CMakeFiles/opassgen.dir/crypto.cpp.o  \
       n.o  -o opassgen                      \
       -rdynamic -static-libgcc -L. -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic \
       /home/oracle/ivan/openssl-1.0.1t/libcrypto.a  \
       /oracle/u01/db/11.2.0.4/lib/libclntst11.a     \
       /oracle/u01/db/11.2.0.4/lib/libippdcmerged.a  \
       /oracle/u01/db/11.2.0.4/lib/libippsmerged.a   \
       -Wl,--whole-archive libtrotl.a -Wl,--no-whole-archive \
       -lpthread -ldl
      

    Static linking requires, that you resolve all the dependencies manually. In this example libclntst11.a depends on symbols from libippdcmerged.a and libippsmerged.a.

    On older Oracle version the whole database was build and linked using Intel's ICC compiler. So when linking Oracle's client lib statically you also had to add some static libs from ICC's runtime.

    0 讨论(0)
提交回复
热议问题