[fpc-pascal] Search order for libraries, how to influence; using GMP

Michael Van Canneyt michael at freepascal.org
Tue Jun 12 23:10:28 CEST 2007



On Tue, 12 Jun 2007, Tom Verhoeff wrote:

> I am trying to use the GNU Multi-Precision (GMP) library with
> FreePascal under Linux.
> 
> I have a Pascal interface for GMP (originally for Kylix; translated
> from C header file).
> 
> The header file libgmp.pas and my using program testgmp.pas compile fine.
> 
> But linking fails.  The message is
> 
> /usr/bin/ld: skipping incompatible /usr/lib/crti.o when searching for /usr/lib/crti.o
> /usr/bin/ld: cannot find /usr/lib/crti.o
> 
> This might be caused by the fact that I use a 64-bit machine with
> a 32-bit version of FPC.
> 
> For that reason, I added the command-line option:
> 
> 	-Fl/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/32
> 
> Without this option, I get the message
> 
> /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtbegin.o when searching for /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtbegin.o
> /usr/bin/ld: cannot find /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtbegin.o
> 
> With the option, it does find the appropriate crtbegin.o.
> 
> Therefore, I also added the command-line option
> 
> 	-Fl/usr/lib32
> 
> But this does not help, since /usr/lib is searched first and there if
> finds the incompatible (64-bit?) version of crti.o, and fails.
> 
> How can I force the linker to look in /usr/lib32 before /usr/lib ?
> 
> When inspecting link.res, it starts out
> 
> SEARCH_DIR(/lib/)
> SEARCH_DIR(/usr/lib/)
> SEARCH_DIR(/usr/X11R6/lib/)
> SEARCH_DIR(/usr/lib32/)
> SEARCH_DIR(/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/32/)
> SEARCH_DIR(/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/)
> 
> Apparently, the first three are forced 'out of nowhere', then there are
> the two options from the command line, and then the one from /etc/fpc.cfg,
> followed by a long list of directories named /usr/lib/fpc/* .
> 
> Where do the first three come from?  Can those be (re)moved?

The compiler adds them by default, see systems/t_linux.pas.
You can't remove them except by editing link.res (or changing the compiler).

Michael.



More information about the fpc-pascal mailing list