Lazarus
Installation => Linux => Topic started by: Ocye on December 18, 2011, 01:38:35 pm
-
I switched recently from Ubunto to Arch Linux. All works fine except crosscompiling for 32bit. E.g. Lazarus tells me
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
/usr/lib32/libpthread.a /usr/lib32/libpthread_nonshared.a /usr/lib32/libpthread.so
When I run "fpc -Pi386 -vt bogus" it seems to be okay
Configfile search: /home/<name>/.fpc.cfg
Reading options from file /home/<name>/.fpc.cfg
Free Pascal Compiler version 2.7.1 [2011/10/02] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Searching file /lib/ld-linux.so.2... found
Compiler: /usr/local/lib/fpc/2.7.1/ppc386
Target OS: Linux for i386
Using executable path: /usr/local/lib/fpc/2.7.1/
...
Using unit path: /usr/local/lib/fpc/2.7.1/
Using library path: /usr/lib32/
Using library path: /lib32/
My ~/.fpc.cfg contains
#ifdef cpux86_64
-Fl/lib
-Fl/usr/lib
#endif
#ifdef cpui386
-Xd
-Fl/lib32
-Fl/usr/lib32
#endif
#ifdef cpuarm
-Xd
-Fl/usr/local/arm/libc/usr/lib
-CaEABI
-Parm
-CfSOFT
-CpARMV5
#endif
Project settings are:
-MObjFPC -Scghi -CX -Cirot -O2 -Pi386 -Xs -XX -vewnhib -l -FuSynapse -Fu/usr/local/bin/Lazarus/lcl/units/i386-linux/qt -Fu/usr/local/bin/Lazarus/lcl/units/i386-linux -Fu/usr/local/bin/Lazarus/components/lazutils/lib/i386-linux -Fu/usr/local/bin/Lazarus/packager/units/i386-linux -Fu. -vm5024,5057 -dLCL -dLCLqt
(gtk2 does not work for i386 too)
Multiarch libs are installed, even compiling for arm works. Which setting did I miss?
Lazarus 0.9.31 r33990M FPC 2.7.1 x86_64-linux-qt
Linux version 3.1.5-1-ARCH (tobias@T-POWA-LX) (gcc version 4.6.2 20111125 (prerelease) (GCC) ) #1 SMP PREEMPT Sat Dec 10 14:43:09 CET 2011
-
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
That is fine. What real error do you have? My fpc.cfg contains this:
#ifdef cpui386
-Xd
-Fl/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/32
-Fl/usr/lib32
#endif
-
It's not okay since I want to create a 32bit application. The linker should use /usr/lib32/libpthread instead of /usr/lib/. Of course, I switched to non standard path by -Xd as quoted.
-
If you still have problems, bisect the problem by looking at the ppas.sh and link.res files. (generated by using -s)
This allows you to pinpoint if your problem is in FPC (or its configuration), when it contains searchpaths for /usr/lib32,
OR
if it doesn't, it's the linker itself.
-
It's not okay since I want to create a 32bit application.
It's ok, because I have the same messages with ZenGL and everything compiles fine with these skipping messages... :)
-
If you still have problems, bisect the problem by looking at the ppas.sh and link.res files. (generated by using -s)
SEARCH_DIR(/usr/lib32/)
SEARCH_DIR(/lib32/)
SEARCH_DIR(./Synapse/)
SEARCH_DIR(/usr/local/bin/Lazarus/components/opengl/lib/i386-linux/gtk2/)
...
/usr/bin/ld -b elf32-i386 -m elf_i386 -s --dynamic-linker=/lib/ld-linux.so.2 -L. -o Scrabble3D link.res
lrwxrwxrwx 1 root root 22 3. Dez 04:06 /lib/ld-linux.so.2 -> ../lib32/ld-linux.so.2
lrwxrwxrwx 1 root root 12 2. Dez 19:29 /lib/ld-linux-x86-64.so.2 -> ld-2.14.1.so
ld -v says GNU ld (GNU Binutils) 2.22.0.20111201
Objects seems to be 32bit.
umessages.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
/lib32/libpthread-2.14.1.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), BuildID[sha1]=0xdaae775adca86bf1f87c0f36a90316624e657417, for GNU/Linux 2.6.27, not stripped
Strange.
-
SEARCH_DIR(/lib32/)
So the problem is clear: LD doesn't properly adapt the default paths if 32-bit mode is chosen.
I already suspected this. I would file a bug with the Linux distribution. Preferably see if you can reproduce it with gcc based code.
-
I would file a bug with the Linux distribution.
This is not a bug of ArchLinux. I also use this distro with installed binutils-multilib, gcc-libs-multilib, gcc-multilib and lib32* libraries - everything just works for FreePascal 2.4.4 and fixes_2_6 branch.
-
I would file a bug with the Linux distribution.
This is not a bug of ArchLinux. I also use this distro with installed binutils-multilib, gcc-libs-multilib, gcc-multilib and lib32* libraries - everything just works for FreePascal 2.4.4 and fixes_2_6 branch.
So how do you explain the above then? Not using multilib versions but the stock ones?
-
Not using multilib versions but the stock ones?
Multilib one is designed for using in such cases, and available in standard repository. You won't be able to compile anything 32-bit under 64-bit without it, because ArchLinux x86_64 by default is pure x86_64 system.
-
#include <stdio.h>
int main(void)
{
printf("Hello, World\n");
return 0;
}
gcc -m32 -o hello hello.c (no error, works)
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, BuildID[sha1]=0x35f957192f312df883c0bd943ce96992e9d286cf, not stripped
linux-gate.so.1 => (0xf77c8000)
libc.so.6 => /lib32/libc.so.6 (0xf7624000)
/lib32/ld-linux.so.2 (0xf77c9000)
cc -m32 hello.c (no error)
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, BuildID[sha1]=0x35f957192f312df883c0bd943ce96992e9d286cf, not stripped
/usr/bin/ld: error in ./a.out(.eh_frame); no .eh_frame_hdr table will be created.
./Hello: error while loading shared libraries: : cannot open shared object file: No such file or directory
./Hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, BuildID[sha1]=0x35f957192f312df883c0bd943ce96992e9d286cf, not stripped
./Hello: error while loading shared libraries: ./Hello: unsupported version 33619 of Verneed record
Is it really a question of ld if gcc works?
-
Is it really a question of ld if gcc works?
You see that FPC doesn't pass /usr/lib to LD. Then LD must do it itself. There is no other option.
It might be that gcc passes other parameters (e.g. uses --rpath-link to specify a different prefix, FPC option -Xr passes that to the compiler, but that requires an alternate dir that can be used as root). Parsing the gcc high verbosity output might help you find what it passes.
Anyway, it is all in the dual architecture setup from the distribution, so for more information I would ask on their development list/forum.
-
"gcc -v ..." prints a lot of information but nothing helpful (for me). For those who are interested: I posted the question in the Arch forum: https://bbs.archlinux.org/viewtopic.php?pid=1030127#p1030127
Thanks, marcov and Andru.
-
Please post the -v output somewhere. (output when compiling a 32-bit app of course)
-
gcc -m32 -v test.c
gcc -m32 -v test.c
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/lto-wrapper
Ziel: x86_64-unknown-linux-gnu
Konfiguriert mit: /build/src/gcc-4.6-20111125/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --enable-multilib --disable-libssp --disable-libstdcxx-pch --enable-checking=release --with-fpmath=sse
Thread-Modell: posix
gcc-Version 4.6.2 20111125 (prerelease) (GCC)
COLLECT_GCC_OPTIONS='-m32' '-v' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/cc1 -quiet -v -imultilib 32 test.c -quiet -dumpbase test.c -m32 -mtune=generic -march=x86-64 -auxbase test -version -o /tmp/ccdwHAIO.s
GNU C (GCC) Version 4.6.2 20111125 (prerelease) (x86_64-unknown-linux-gnu)
kompiliert von GNU-C-Version 4.6.2 20111125 (prerelease), GMP-Version 5.0.2, MPFR-Version 3.1.0-p3, MPC-Version 0.9.
GGC-Heuristik: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
nicht vorhandenes Verzeichnis »/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../x86_64-unknown-linux-gnu/include« wird ignoriert
#include "..." - Suche beginnt hier:
#include <...> - Suche beginnt hier:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/include
/usr/local/include
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/include-fixed
/usr/include
Ende der Suchliste.
GNU C (GCC) Version 4.6.2 20111125 (prerelease) (x86_64-unknown-linux-gnu)
kompiliert von GNU-C-Version 4.6.2 20111125 (prerelease), GMP-Version 5.0.2, MPFR-Version 3.1.0-p3, MPC-Version 0.9.
GGC-Heuristik: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a255f0a427d446be89ce347a664e79ea
COLLECT_GCC_OPTIONS='-m32' '-v' '-mtune=generic' '-march=x86-64'
as --32 -o /tmp/ccbSZcJm.o /tmp/ccdwHAIO.s
COMPILER_PATH=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/32/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib32/:/lib/../lib32/:/usr/lib/../lib32/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-m32' '-v' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/collect2 --build-id --eh-frame-hdr -m elf_i386 --hash-style=both -dynamic-linker /lib32/ld-linux.so.2 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib32/crt1.o /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib32/crti.o /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/32/crtbegin.o -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/32 -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib32 -L/lib/../lib32 -L/usr/lib/../lib32 -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2 -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../.. /tmp/ccbSZcJm.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/32/crtend.o /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib32/crtn.o
-
It seems collect simply avoids searching and fully qualifies all .o's.
-
Few days ago I bought SSD and installed fresh ArchLinux on it. Today I installed these multilib packages:
- binutils-multilib
- gcc-libs-multilib
- gcc-multilib
Also I insalled package fpc and built FreePascal 2.5.1 using this script:
export PPCBIN="ppcx64"
if [ -d ./fixes_2_6 ]; then
svn update ./fixes_2_6
else
svn co http://svn.freepascal.org/svn/fpc/branches/fixes_2_6 ./fixes_2_6
fi
cd ./fixes_2_6
make FPC=/usr/lib/fpc/2.4.4/$PPCBIN build OS_TARGET=linux CPU_TARGET=i386 CROSSOPT="-XP"
sudo make FPC=`pwd`/compiler/ppcross386 PREFIX=/opt/fpc crossinstall OS_TARGET=linux CPU_TARGET=i386 CROSSOPT="-XP"
sudo make distclean
Then I created symlink for this version. For switching between different versions of FreePascal I use this script(this one switch me to FreePascal 2.5.1):
sudo ln -sf /opt/fpc/lib/fpc/2.5.1/ppcx64 /usr/bin/ppcx64
sudo ln -sf /opt/fpc/lib/fpc/2.5.1/ppcross386 /usr/bin/ppc386
sudo ln -sf /opt/fpc/lib/fpc/2.5.1/ppcrossarm /usr/bin/ppcarm
mv ~/fpc.cfg ~/.fpc.cfg
And this one for back to FreePascal 2.4.4:
sudo ln -sf /usr/lib/fpc/2.4.4/ppcx64 /usr/bin/ppcx64
sudo ln -sf /usr/lib/fpc/2.4.4/ppcross386 /usr/bin/ppc386
sudo ln -sf /usr/lib/fpc/2.4.4/ppcrossarm /usr/bin/ppcarm
mv ~/.fpc.cfg ~/fpc.cfg
You will be needed only second line and last line. Content of mine fpc.cfg in $HOME directory(also you can add option "-Xd", but I use it separately in Makefile's/etc. of my projects):
#
# Config file generated by fpcmkcfg on 9-11-11 - 22:08:31
# Example fpc.cfg for Free Pascal Compiler
#
# ----------------------
# Defines (preprocessor)
# ----------------------
#
# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
#
# -d is the same as #DEFINE
# -u is the same as #UNDEF
#
#
# Some examples (for switches see below, and the -? helppages)
#
# Try compiling with the -dRELEASE or -dDEBUG on the commandline
#
# For a release compile with optimizes and strip debuginfo
#IFDEF RELEASE
-O2
-Xs
#WRITE Compiling Release Version
#ENDIF
# For a debug version compile with debuginfo and all codegeneration checks on
#IFDEF DEBUG
-glh
-Crtoi
#WRITE Compiling Debug Version
#ENDIF
# ----------------
# Parsing switches
# ----------------
# Pascal language mode
# -Mfpc free pascal dialect (default)
# -Mobjfpc switch some Delphi 2 extensions on
# -Mdelphi tries to be Delphi compatible
# -Mtp tries to be TP/BP 7.0 compatible
# -Mgpc tries to be gpc compatible
# -Mmacpas tries to be compatible to the macintosh pascal dialects
#
# Turn on Object Pascal extensions by default
#-Mobjfpc
# Assembler reader mode
# -Rdefault use default assembler
# -Ratt read AT&T style assembler
# -Rintel read Intel style assembler
#
# All assembler blocks are AT&T styled by default
#-Ratt
# Semantic checking
# -S2 same as -Mobjfpc
# -Sc supports operators like C (*=,+=,/= and -=)
# -Sa include assertion code.
# -Sd same as -Mdelphi
# -Se<x> compiler stops after the <x> errors (default is 1)
# -Sg allow LABEL and GOTO
# -Sh Use ansistrings
# -Si support C++ styled INLINE
# -SI<x> set interface style to <x>
# -SIcomCOM compatible interface (default)
# -SIcorbaCORBA compatible interface
# -Sm support macros like C (global)
# -So same as -Mtp
# -Sp same as -Mgpc
# -Ss constructor name must be init (destructor must be done)
#
# Allow goto, inline, C-operators, C-vars
-Sgic
# ---------------
# Code generation
# ---------------
# Uncomment the next line if you always want static/dynamic units by default
# (can be overruled with -CD, -CS at the commandline)
#-CS
#-CD
# Set the default heapsize to 8Mb
#-Ch8000000
# Set default codegeneration checks (iocheck, overflow, range, stack)
#-Ci
#-Co
#-Cr
#-Ct
# Optimizer switches for i386 compiler
# -Os generate smaller code
# -O1 level 1 optimizations (quick optimizations)
# -O2 level 2 optimizations (-O1 + slower optimizations)
# -O3 level 3 optimizations (same as -O2u)
# -Oa=N set alignment to N
# -OoX switch on optimalization X.
# -OoNOX switch off optimalization X.
# X is one of REGVAR UNCERTAIN STACKFRAME PEEPHOLE ASMCSE LOOPUNROLL
# -OpCPU set target processor.
# CPU is one of 386, PENTIUM, PENTIUM2, PENTIUM3, PENTIUM4, PENTIUMM
# -----------------------
# Set Filenames and Paths
# -----------------------
# Both slashes and backslashes are allowed in paths
# path to the messagefile, not necessary anymore but can be used to override
# the default language
#-Fr/opt/fpc/lib/fpc/$fpcversion/msg/errore.msg
#-Fr/opt/fpc/lib/fpc/$fpcversion/msg/errorn.msg
#-Fr/opt/fpc/lib/fpc/$fpcversion/msg/errores.msg
#-Fr/opt/fpc/lib/fpc/$fpcversion/msg/errord.msg
#-Fr/opt/fpc/lib/fpc/$fpcversion/msg/errorr.msg
# searchpath for units and other system dependent things
-Fu/opt/fpc/lib/fpc/$fpcversion/units/$FPCTARGET/
-Fu/opt/fpc/lib/fpc/$fpcversion/units/$FPCTARGET/*
-Fu/opt/fpc/lib/fpc/$fpcversion/units/$FPCTARGET/rtl
#IFDEF FPCAPACHE_1_13
-Fu/opt/fpc/lib/fpc/$fpcversion/units/$FPCTARGET/httpd13/
#ELSE
#IFDEF FPCAPACHE_2_0
-Fu/opt/fpc/lib/fpc/$fpcversion/units/$FPCTARGET/httpd20
#ELSE
-Fu/opt/fpc/lib/fpc/$fpcversion/units/$FPCTARGET/httpd22
#ENDIF
#ENDIF
# path to the gcclib
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/32
-Fl/usr/lib32
#endif
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2
#endif
# searchpath for libraries
#-Fl/opt/fpc/lib/fpc/$fpcversion/lib
#-Fl/lib;/usr/lib
# searchpath for tools
-FD/opt/fpc/lib/fpc/$fpcversion/bin/$FPCTARGET
#IFNDEF CPUI386
#IFNDEF CPUAMD64
#DEFINE NEEDCROSSBINUTILS
#ENDIF
#ENDIF
#IFNDEF Linux
#DEFINE NEEDCROSSBINUTILS
#ENDIF
# binutils prefix for cross compiling
#IFDEF FPC_CROSSCOMPILING
#IFDEF NEEDCROSSBINUTILS
-XP$FPCTARGET-
#ENDIF
#ENDIF
# -------------
# Linking
# -------------
# generate always debugging information for GDB (slows down the compiling
# process)
# -gc generate checks for pointers
# -gd use dbx
# -gg use gsym
# -gh use heap trace unit (for memory leak debugging)
# -gl use line info unit to show more info for backtraces
# -gv generates programs tracable with valgrind
# -gw generate dwarf debugging info
#
# Enable debuginfo and use the line info unit by default
#-gl
# always pass an option to the linker
#-k-s
# Always strip debuginfo from the executable
-Xs
# -------------
# Miscellaneous
# -------------
# Write always a nice FPC logo ;)
-l
# Verbosity
# e : Show errors (default) d : Show debug info
# w : Show warnings u : Show unit info
# n : Show notes t : Show tried/used files
# h : Show hints m : Show defined macros
# i : Show general info p : Show compiled procedures
# l : Show linenumbers c : Show conditionals
# a : Show everything 0 : Show nothing (except errors)
# b : Show all procedure r : Rhide/GCC compatibility mode
# declarations if an error x : Executable info (Win32 only)
# occurs
#
# Display Info, Warnings, Notes and Hints
-viwn
# If you don't want so much verbosity use
#-vw
So, I don't even know what can be wrong and don't work... everything is simple, without any magic at all :)
-
local/binutils-multilib 2.22-1 (multilib-devel)
local/gcc-libs-multilib 4.6.2-3
local/gcc-multilib 4.6.2-3 (multilib-devel)
local/lib32-glibc 2.14.1-4
local/libtool-multilib 2.4.2-2 (multilib-devel)
Fpc is v2.7.1 and thus build from svn.
-
I tried to build FreePascal 2.7.1 with my script and found that new version just ignores mine CROSSOPT. So I created symlink /usr/bin/i386-linux-ld to /usr/bin/ld and built it. And everything still works...
-
I was thinking about installing ArchLinux in a VM to test a bit and noticed that there are three editions. x86, x86_64 and biarch. What versions do you guys use?
(I assume the x86_64 version can be transformed into a biarch by installing packages, but for overview it would still be good to know what you guys started with)
-
We use separate x86 and x86_64 installations of
Archlinux netinstall.iso
Yes it's the hard way
I can post (after your request) our steps for installation of
lxde, xfce4, kde, gnome and mate desktops
to Virtual Box or PC
-
What versions do you guys use?
x86_64
Official Installation Guide: https://wiki.archlinux.org/index.php/Official_Installation_Guide
-
Please also see
http://www.lazarus.freepascal.org/index.php/topic,15828.msg85447.htm