Why Can\'t I Statically Link My Go Application with Oracle Libraries, and How Can I Fix It?

Susan Sarandon
Release: 2024-11-26 19:53:15
Original
905 people have browsed it

Why Can't I Statically Link My Go Application with Oracle Libraries, and How Can I Fix It?

Cannot Find Oracle Library During Static Build

In an attempt to create a static Go executable with Oracle libraries on Ubuntu, errors were encountered while trying to link them. Despite successful dynamic builds, the static compiler reported an inability to find the Oracle library, despite the fact that the required files were present in the correct locations.

Resolution

  1. Use the $ORACLE_HOME/bin/relink tool to generate the libclntst.a library, as Oracle clients typically do not ship with this file. This static library contains missing symbols that are required for static linking.
  2. Compile the application with the libclntst.a library. Verify the absence of any unresolved symbols.
  3. Utilize the nm tool to identify the source of any outstanding missing symbols.
  4. As an example, in the case of Oracle 11gR2, the following compilation command successfully resolved all dependencies:
/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
Copy after login

This command includes additional static libraries to resolve dependencies, including libippdcmerged.a and libippsmerged.a.

In summary, static linking requires manual resolution of all dependencies, which may necessitate the inclusion of additional libraries not typically included in dynamic linking.

The above is the detailed content of Why Can\'t I Statically Link My Go Application with Oracle Libraries, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template