Crosscompile linking problems

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Crosscompile linking problems

Lukas Gebauer
Hi!

I am trying crosscompile my commandline application from Win32 to
linux. I have cross binutils, compiled linux RTL and other
packages... so, I have not any problem with crosscompile. I have a
problem with final linking of crosscompiled application only.

I have a few '.so' from Mandrake9 in my LIB directory, but linking
producing next errors:

C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libpthread.so: undefined reference to
`_rtld_global@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_start_profile@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_check_map_versions@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_mcount@GLIBC_2.1'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`__libc_enable_secure@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_get_origin@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_dst_substitute@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_debug_state@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_init@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`__libc_stack_end@GLIBC_2.1'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_dst_count@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_out_of_memory@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_signal_error@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_debug_printf@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_r_debug@GLIBC_2.0'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_map_object_deps@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_unload_cache@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_relocate_object@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_argv@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libdl.so: undefined reference to
`_dl_catch_error@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_lookup_symbol_skip@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_lookup_symbol@GLIBC_PRIVATE'
C:\FPC\2.0.0\lib\/libc.so: undefined reference to
`_dl_map_object@GLIBC_PRIVATE'

Have you some ideas? Have I missed somethink?

I call it by commandline:
fpc -Tlinux webtouch -XPi386-linux-

Thanks!


--
Lukas Gebauer.

E-mail: [hidden email]
http://www.ararat.cz/synapse/ - Ararat Synapse - TCP/IP Lib.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Crosscompile linking problems

Peter Vreman
> Hi!
>
> I am trying crosscompile my commandline application from Win32 to
> linux. I have cross binutils, compiled linux RTL and other
> packages... so, I have not any problem with crosscompile. I have a
> problem with final linking of crosscompiled application only.
>
> I have a few '.so' from Mandrake9 in my LIB directory, but linking
> producing next errors:
>
> C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> `_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
> C:\FPC\2.0.0\lib\/libpthread.so: undefined reference to
> `_rtld_global@GLIBC_PRIVATE'
> C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> `_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
> Have you some ideas? Have I missed somethink?
>
> I call it by commandline:
> fpc -Tlinux webtouch -XPi386-linux-

Looks like the dynamic linker loader (ld-linux.so) is missing




_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Crosscompile linking problems

Lukas Gebauer
> > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > `_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
> > C:\FPC\2.0.0\lib\/libpthread.so: undefined reference to
> > `_rtld_global@GLIBC_PRIVATE'
> > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > `_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
> > Have you some ideas? Have I missed somethink?
> >
> > I call it by commandline:
> > fpc -Tlinux webtouch -XPi386-linux-
>
> Looks like the dynamic linker loader (ld-linux.so) is missing

I have it in my lib directory... ld-linux.so and ld-linux.so.2 (copy
of ld-linux.so)



--
Lukas Gebauer.

E-mail: [hidden email]
http://www.ararat.cz/synapse/ - Ararat Synapse - TCP/IP Lib.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Crosscompile linking problems

Marco van de Voort
> > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > `_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
> > > C:\FPC\2.0.0\lib\/libpthread.so: undefined reference to
> > > `_rtld_global@GLIBC_PRIVATE'
> > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > `_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
> > > Have you some ideas? Have I missed somethink?
> > >
> > > I call it by commandline:
> > > fpc -Tlinux webtouch -XPi386-linux-
> >
> > Looks like the dynamic linker loader (ld-linux.so) is missing
>
> I have it in my lib directory... ld-linux.so and ld-linux.so.2 (copy
> of ld-linux.so)

I compiled Lazarus from win32 to Linux/FreeBSD a while ago, here are my
summary notes:


To compile linux lazarus on windows: (the procedure from freebsd will not
differ much, the cprt0 copying is not needed for FreeBSD)

Requirements:
- FPC 1.9.6 or higher. 1.9.4 might work, but untested.
- ftp://freepascal.stack.nl/pub/fpc/contrib/cross/mingw/binutils-2.15-win32-i386-linux.zip
- A FPC CVS repository.  (anything 1.9.6+ that is buildable will do)
- a lazarus tree. (anything buildable from the same period will do)
- Lots of libraries from the target linux system. One of the FPC servers is some SUSE,
    that's where I got the list below.

1) Download ftp://freepascal.stack.nl/pub/fpc/contrib/cross/mingw/binutils-2.15-win32-i386-linux.zip
2) extract it and move the i386* files to <fpcbindir>\bin\i386-win32  (e.g. c:\pp\bin\i386\win32)
3) enter FPC source dir
4) make clean
5) make OS_TARGET=linux all
6) make OS_TARGET=linux install INSTALL_PREFIX=<fpcbindir>
7) prepare the lib directory as in below instructions,  I used d:\fpc\linuxlib to store them.
8) go to <fpcbindir>\units\i386-linux\rtl  and copy cprt21.o over cprt0.o
9) enter lazarus dir
10) edit lazarus.pp and add {$linklib dl} and {$linklib gmodule} somewhere in the source.
11) make OS_TARGET=linux all OPT="-gl -Fld:\fpc\linuxlib -Xr/usr/lib -FL/usr/lib/ld-linux.so.2 "

If some linker error (most specifically linker can't find -l<something>) then

12) manually edit link.res if needed (see below for gtk remarks) and adapt the -l<x> names at the bottom of the files. I had to add -1.2 to all gtk
    libs, to keep them apart from gtk2
13) run ppas.bat to restart the linker

----------- Libraries

These are the libraries I collected for both lazarus and the textmode IDE
(lazarus doesn't need pthread).

I gathered these from the target system, and renamed all from
lib<name>.so.x.y to lib<name>.so.

libgcc.a and a few others are easiest found by doing gcc -v and look for a line like

"Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs"

then some of the libs are in  /usr/lib/gcc-lib/i486-linux/3.3.5/
Some other good locations are /lib /usr/lib /usr/local/lib /usr/x11R6/lib and /opt/gnome/lib

libpthread.so.0
libdl.so
libc.so
ld-linux.so.2
crtbegin.o
crtbeginS.o
crtbeginT.o
crtend.o
crtendS.o
crtn.o
crti.o
libgcc.a
libX11.so
libXi.so
libglib-1.2.so
libgmodule-1.2.so.0
libgdk_pixbuf.so
libgdk-1.2.so
libgtk-1.2.so
libXext.so
libm.so
libdl.so.2
libgmodule-1.2.so

Note that some directories are duplicate, with a suffix and not. These are required because some other lib has a dependancy on that
exact name (so the form lib<name>.so.x) we can't symlink on windows, so I simply copy it.

Making mistakes with renaming is not that bad, there will be chances to fix it. Make sure all crt* and a file "libc.so" are available, otherwise
generating link.res will go wrong. (Yes, Peter, that was my fault :-)

In my case compilation for step 11 will go ok, but the linker will complain it can't find libgtk.so and the other libraries marked with -1.2
This is because on the target system, libgtk is gtk 2.0, while we want gtk1.2 for lazarus.

To fix this I manually added -1.2 to the corresponding -l lines in the bottom of the link.res file that was generated by step 11

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Crosscompile linking problems

Lukas Gebauer
> > > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > > `_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
> > > > C:\FPC\2.0.0\lib\/libpthread.so: undefined reference to
> > > > `_rtld_global@GLIBC_PRIVATE'
> > > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > > `_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
> > > > Have you some ideas? Have I missed somethink?
> > > >
> > > > I call it by commandline:
> > > > fpc -Tlinux webtouch -XPi386-linux-
> > >
> > > Looks like the dynamic linker loader (ld-linux.so) is missing
> >
> > I have it in my lib directory... ld-linux.so and ld-linux.so.2 (copy
> > of ld-linux.so)
>
> I compiled Lazarus from win32 to Linux/FreeBSD a while ago, here are my
> summary notes:

I know this your message before, however it not solve my problems.
:-(



--
Lukas Gebauer.

E-mail: [hidden email]
http://www.ararat.cz/synapse/ - Ararat Synapse - TCP/IP Lib.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Crosscompile linking problems

L505
In reply to this post by Marco van de Voort
Another option is to use CoLinux, which let's you compile anything once you just
get Linux up and running on windows. I found was a lot less work in the end.
You have access to all linux related commands and linux related everything,
since you are essentially running linux in windows.


|
| Requirements:
| - FPC 1.9.6 or higher. 1.9.4 might work, but untested.
| -
ftp://freepascal.stack.nl/pub/fpc/contrib/cross/mingw/binutils-2.15-win32-i386-l
inux.zip
| - A FPC CVS repository.  (anything 1.9.6+ that is buildable will do)
| - a lazarus tree. (anything buildable from the same period will do)
| - Lots of libraries from the target linux system. One of the FPC servers is
some SUSE,
|     that's where I got the list below.
|
| 1) Download
ftp://freepascal.stack.nl/pub/fpc/contrib/cross/mingw/binutils-2.15-win32-i386-l
inux.zip
| 2) extract it and move the i386* files to <fpcbindir>\bin\i386-win32  (e.g.
c:\pp\bin\i386\win32)
| 3) enter FPC source dir
| 4) make clean
| 5) make OS_TARGET=linux all
| 6) make OS_TARGET=linux install INSTALL_PREFIX=<fpcbindir>
| 7) prepare the lib directory as in below instructions,  I used d:\fpc\linuxlib
to store them.
| 8) go to <fpcbindir>\units\i386-linux\rtl  and copy cprt21.o over cprt0.o
| 9) enter lazarus dir
| 10) edit lazarus.pp and add {$linklib dl} and {$linklib gmodule} somewhere in
the source.
| 11) make OS_TARGET=linux all
OPT="-gl -Fld:\fpc\linuxlib -Xr/usr/lib -FL/usr/lib/ld-linux.so.2 "
|
| If some linker error (most specifically linker can't find -l<something>) then
|
| 12) manually edit link.res if needed (see below for gtk remarks) and adapt
the -l<x> names at the bottom of the files. I had to add -1.2 to all gtk
|     libs, to keep them apart from gtk2
| 13) run ppas.bat to restart the linker
|
| ----------- Libraries
|
| These are the libraries I collected for both lazarus and the textmode IDE
| (lazarus doesn't need pthread).
|
| I gathered these from the target system, and renamed all from
| lib<name>.so.x.y to lib<name>.so.
|
| libgcc.a and a few others are easiest found by doing gcc -v and look for a
line like
|
| "Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs"
|
| then some of the libs are in  /usr/lib/gcc-lib/i486-linux/3.3.5/
| Some other good locations are /lib /usr/lib /usr/local/lib /usr/x11R6/lib and
/opt/gnome/lib
|
| libpthread.so.0
| libdl.so
| libc.so
| ld-linux.so.2
| crtbegin.o
| crtbeginS.o
| crtbeginT.o
| crtend.o
| crtendS.o
| crtn.o
| crti.o
| libgcc.a
| libX11.so
| libXi.so
| libglib-1.2.so
| libgmodule-1.2.so.0
| libgdk_pixbuf.so
| libgdk-1.2.so
| libgtk-1.2.so
| libXext.so
| libm.so
| libdl.so.2
| libgmodule-1.2.so
|
| Note that some directories are duplicate, with a suffix and not. These are
required because some other lib has a dependancy on that
| exact name (so the form lib<name>.so.x) we can't symlink on windows, so I
simply copy it.
|
| Making mistakes with renaming is not that bad, there will be chances to fix
it. Make sure all crt* and a file "libc.so" are available, otherwise
| generating link.res will go wrong. (Yes, Peter, that was my fault :-)
|
| In my case compilation for step 11 will go ok, but the linker will complain it
can't find libgtk.so and the other libraries marked with -1.2
| This is because on the target system, libgtk is gtk 2.0, while we want gtk1.2
for lazarus.
|
| To fix this I manually added -1.2 to the corresponding -l lines in the bottom
of the link.res file that was generated by step 11
|
| _______________________________________________
| fpc-pascal maillist  -  [hidden email]
| http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Crosscompile linking problems

Marco van de Voort
In reply to this post by Lukas Gebauer
> > > > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > > > `_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
> > > > > C:\FPC\2.0.0\lib\/libpthread.so: undefined reference to
> > > > > `_rtld_global@GLIBC_PRIVATE'
> > > > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > > > `_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
> > > > > Have you some ideas? Have I missed somethink?
> > > > >
> > > > > I call it by commandline:
> > > > > fpc -Tlinux webtouch -XPi386-linux-
> > > >
> > > > Looks like the dynamic linker loader (ld-linux.so) is missing
> > >
> > > I have it in my lib directory... ld-linux.so and ld-linux.so.2 (copy
> > > of ld-linux.so)
> >
> > I compiled Lazarus from win32 to Linux/FreeBSD a while ago, here are my
> > summary notes:
>
> I know this your message before, however it not solve my problems.
> :-(

So you have a -FL parameter?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Crosscompile linking problems

Lukas Gebauer
> > > > > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > > > > `_dl_lookup_versioned_symbol_skip@GLIBC_PRIVATE'
> > > > > > C:\FPC\2.0.0\lib\/libpthread.so: undefined reference to
> > > > > > `_rtld_global@GLIBC_PRIVATE'
> > > > > > C:\FPC\2.0.0\lib\/libc.so: undefined reference to
> > > > > > `_dl_lookup_versioned_symbol@GLIBC_PRIVATE'
> > > > > > Have you some ideas? Have I missed somethink?
>
> So you have a -FL parameter?

I have solution! :-)

I must add ld-linux explicitly by -k parameter first! After this
linking is OK. -k parameters seems to be a trick what I missed
before...

Just linked executable is not runnable under linux until I add -FL.
(because otherwise it is linked with ld-linux.so.1)

So, my commandline is now:

fpc webtouch -Tlinux -XPi386-linux- -kc:\fpc\2.0.0\lib\ld-
linux.so.2 -FL/lib/ld-linux.so.2

(and I have -Fl in FPC config, of course!)

My appliation run on linux wery well now.
Thanks for your comments!



--
Lukas Gebauer.

E-mail: [hidden email]
http://www.ararat.cz/synapse/ - Ararat Synapse - TCP/IP Lib.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal