Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-05

Static linking against the indigo cheminformatics package under Linux x64 complains undefined reference to __dso_handle when Free Pascal is used

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xichen Li

### The source code of [the indigo cheminformatics package][1] can be compiled into static libraries and provides a plain-C API interface to its C++ core.
The procedure is shown:

cd indigo
module add gcc/4.7.2 # or gcc/4.3.2
module add cmake/2.8.8
python ./build_scripts/indigo-release-libs.py --preset=linux64

Part of the tree structure is shown:

indigo
./dist/indigo-libs-1.1.12-linux64-static.zip
./dist/LICENSE.GPL
./dist/indigo-inchi.h
./dist/indigo-renderer.h
./dist/indigo.h
./dist/static
./dist/static/Linux
./dist/static/Linux/x64
./dist/static/Linux/x64/libcairo.a
./dist/static/Linux/x64/libcommon.a
./dist/static/Linux/x64/libgraph.a
./dist/static/Linux/x64/libinchi.a
./dist/static/Linux/x64/libindigo-inchi-static.a
./dist/static/Linux/x64/libindigo-renderer-static.a ./dist/static/Linux/x64/libindigo-static.a
./dist/static/Linux/x64/liblayout.a
./dist/static/Linux/x64/libmolecule.a
./dist/static/Linux/x64/libpixman.a
./dist/static/Linux/x64/libpng.a
./dist/static/Linux/x64/libreaction.a
./dist/static/Linux/x64/librender2d.a
./dist/static/Linux/x64/libtinyxml.a
./dist/static/Linux/x64/libz.a

###To compile .c and static link against the static indigo libraries: Source code of a sample cTest.c file is shown:

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "indigo.h"
    int main (void) { printf("%s\n", indigoVersion()); }

, the procedure is shown:

cd indigo/dist/static/Linux/x64
module add gcc/4.7.2 # or gcc/4.3.2
g++ -I../../../ cTest.c -o cTest libindigo-static.a libreaction.a liblayout.a libmolecule.a libgraph.a libcommon.a libz.a libtinyxml.a -lpthread

###To compile .pp and static link against the static indigo libraries: Source code of a sample fpcTest.pp file is shown:

    program fpcTest;
    {$MODE DELPHI}
    {$APPTYPE CONSOLE}
    uses
      SysUtils;
     // {$linklib stdc++}
     {$link /usr/lib64/libstdc++.so.6}
     {$linklib pthread}
     {$linklib libindigo-static}
     {$linklib libreaction}
     {$linklib liblayout}
     {$linklib libmolecule}
     {$linklib libgraph}
     {$linklib libcommon}
     {$linklib libz}
     {$linklib libtinyxml}
     function indigoVersion (): PChar; cdecl; external 'libindigo-static';
    begin
      WriteLn(indigoVersion);
    end.

, the procedure is shown:

cd indigo/dist/static/Linux/x64
~/fpc-2.6.4/bin/fpc fpc_static.pp

However, it complains "undefined reference to __dso_handle". The Error msg is shown below:

Free Pascal Compiler version 2.6.4 [2014/03/03] for x86_64 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Linux for x86-64
Compiling fpc_static.pp

    fpc_static.pp(4,2) Note: APPTYPE is not supported by the target OS
    Linking fpc_static
    /usr/bin/ld: warning: link.res contains output sections; did you

forget -T?
./libindigo-static.a(option_manager.cpp.o): In function `_GLOBAL__sub_I_option_manager.cpp':
option_manager.cpp:(.text.startup+0x3): undefined reference to `__dso_handle'
./libindigo-static.a(indigo.cpp.o): In function `Indigo::init()': indigo.cpp:(.text+0x3bf): undefined reference to `__dso_handle' ./libindigo-static.a(indigo.cpp.o): In function
`_GLOBAL__sub_I_indigo.cpp':
indigo.cpp:(.text.startup+0x2e): undefined reference to `__dso_handle' indigo.cpp:(.text.startup+0x5b): undefined reference to `__dso_handle' ./libcommon.a(profiling.cpp.o): In function
`_GLOBAL__sub_I_profiling.cpp':
profiling.cpp:(.text.startup+0x22): undefined reference to `__dso_handle'
./libcommon.a(profiling.cpp.o):profiling.cpp:(.text.startup+0x40): more undefined references to `__dso_handle' follow

    fpc_static.pp(25,1) Error: Error while linking
    fpc_static.pp(25,1) Fatal: There were 1 errors compiling module,

stopping
Fatal: Compilation aborted
Error: ~/fpc-2.6.4/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)

Could you help to comment about the reason and the workaround ?

[1]: http://www.ggasoftware.com/download/indigo

Reply by email

Jonas Maebe
to Xichen Li
Xichen Li wrote
However, it complains "undefined reference to __dso_handle". The Error msg is shown below:

You also have to link against libc. gcc does that by default, but FPC does not.

Joans

Reply by email