Sign in Join

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

Mailing lists / fpc-devel / 2005-05

error when linking

18 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Linuxer Wang

Hi, all

I try to compile my program with chmlib.
There're chmlib.so and chmlib.a under /usr/lib. I find a wierd problem, when I compile my program, the compiler uses chmlib.so, and the compilation is successful.
But what I want is too compile it with chmlib.a so that the executable will be independent with chmlib.so. So I delete the chmlib.so and the compiler try to compile with chmlib.a, the following errors occur:

/usr/local/lib/libchm.a(chm_lib.o)(.text+0x3b1): In function `chm_set_param':
src/chm_lib.c:1034: undefined reference to `__moddi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xba6): In function `_chm_decompress_block':
src/chm_lib.c:1387: undefined reference to `__umoddi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xd4b):src/chm_lib.c:1454: undefined reference to `__umoddi3'
/usr/local/lib/libchm.a(chm_lib.o)(.text+0xf86): In function `chm_retrieve_object':
src/chm_lib.c:1500: undefined reference to `__udivdi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xf9c):src/chm_lib.c:1501: undefined reference to `__umoddi3'
/usr/local/lib/libchm.a(chm_lib.o)(.text+0xff8):src/chm_lib.c:1509: undefined reference to `__umoddi3'
Error: Error while linking
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specifiy a source file to be compiled)

So interesting, the same program compiled with different libs gives different results.

Can anyone give me some sugguestion? Thanks in advance.

Reply by email

Michael Van Canneyt
to Linuxer Wang
Linuxer Wang wrote 33 lines
Hi, all I try to compile my program with chmlib. There're chmlib.so and chmlib.a under /usr/lib. I find a wierd problem, when I compile my program, the compiler uses chmlib.so, and the compilation is successful. But what I want is too compile it with chmlib.a so that the executable will be independent with chmlib.so. So I delete the chmlib.so and the compiler try to compile with chmlib.a, the following errors occur: /usr/local/lib/libchm.a(chm_lib.o)(.text+0x3b1): In function `chm_set_param': src/chm_lib.c:1034: undefined reference to `__moddi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xba6): In function `_chm_decompress_block': src/chm_lib.c:1387: undefined reference to `__umoddi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xd4b):src/chm_lib.c:1454: undefined reference to `__umoddi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xf86): In function `chm_retrieve_object': src/chm_lib.c:1500: undefined reference to `__udivdi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xf9c):src/chm_lib.c:1501: undefined reference to `__umoddi3' /usr/local/lib/libchm.a(chm_lib.o)(.text+0xff8):src/chm_lib.c:1509: undefined reference to `__umoddi3' Error: Error while linking Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specifiy a source file to be compiled) So interesting, the same program compiled with different libs gives different results. Can anyone give me some sugguestion? Thanks in advance.

Try linking with libm.a and also check for the libgcc.a library.

Michael.

Reply by email

Linuxer Wang
to Michael Van Canneyt
Michael Van Canneyt wrote 43 lines
On Wed, 25 May 2005, Linuxer Wang wrote: >Hi, all > >I try to compile my program with chmlib. >There're chmlib.so and chmlib.a under /usr/lib. I find a wierd problem, >when I compile my program, the compiler uses chmlib.so, and the >compilation is successful. >But what I want is too compile it with chmlib.a so that the executable >will be independent with chmlib.so. So I delete the chmlib.so and the >compiler try to compile with chmlib.a, the following errors occur: > >/usr/local/lib/libchm.a(chm_lib.o)(.text+0x3b1): In function >`chm_set_param': >src/chm_lib.c:1034: undefined reference to `__moddi3' >/usr/local/lib/libchm.a(chm_lib.o)(.text+0xba6): In function >`_chm_decompress_block': >src/chm_lib.c:1387: undefined reference to `__umoddi3' >/usr/local/lib/libchm.a(chm_lib.o)(.text+0xd4b):src/chm_lib.c:1454: >undefined reference to `__umoddi3' >/usr/local/lib/libchm.a(chm_lib.o)(.text+0xf86): In function >`chm_retrieve_object': >src/chm_lib.c:1500: undefined reference to `__udivdi3' >/usr/local/lib/libchm.a(chm_lib.o)(.text+0xf9c):src/chm_lib.c:1501: >undefined reference to `__umoddi3' >/usr/local/lib/libchm.a(chm_lib.o)(.text+0xff8):src/chm_lib.c:1509: >undefined reference to `__umoddi3' >Error: Error while linking >Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not >specifiy a source file to be compiled) > >So interesting, the same program compiled with different libs gives >different results. > >Can anyone give me some sugguestion? Thanks in advance. > > Try linking with libm.a and also check for the libgcc.a library.
I added the following lines:
{$LINKLIB m}
{$LINKLIB gcc}
but still get the errors.

BTW, I am using Fedora4test3 which use gcc4. Should I recompile the whole fpc?

Thank you,

Show quoted text 8 lines
Michael. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Jeff Pohlmeyer
So I delete the chmlib.so and the compiler try to compile with chmlib.a

FPC tells the linker to look first in the current directory, so instead of deleting chmlib.so, you can just do this: % ln -s /usr/local/lib/libchm.a
in the directory of your pascal source.

undefined reference to `__moddi3'
Try adding this line to the top of your unit or program:
{$LINKLIB gcc_s}

- Jeff

Reply by email

Linuxer Wang
to Jeff Pohlmeyer
Jeff Pohlmeyer wrote 11 lines
>So I delete the chmlib.so and the >compiler try to compile with chmlib.a > > FPC tells the linker to look first in the current directory, so instead of deleting chmlib.so, you can just do this: % ln -s /usr/local/lib/libchm.a in the directory of your pascal source.

Great, thank you.

Show quoted text 11 lines
>undefined reference to `__moddi3' > > Try adding this line to the top of your unit or program: {$LINKLIB gcc_s}

There's no libgcc_s.a or something else in my computer:

/usr/bin/ld: cannot find -lgcc_s
Error: Error while linking

Show quoted text 9 lines
- Jeff _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Jeff Pohlmeyer
to Marco van de Voort
> {$LINKLIB gcc_s} Why _s? Is FC4 breaking compat here?

I think it is gcc that broke it, not Fedora. I am running SuSE 9.2 and I have /lib/libgcc_s.so.1 ( Installed from SuSE RPM )
and
/opt/gcc-3.4.0/lib/libgcc_s.so.1 ( Built directly from gnu.org sources )

- Jeff

Reply by email

Linuxer Wang
to Jeff Pohlmeyer: Do you have the libgcc libraries installed? It should be be something like this:…
Jeff Pohlmeyer wrote 14 lines
>/usr/bin/ld: cannot find -lgcc_s >BTW, I am using Fedora4test3 which use gcc4. > > Do you have the libgcc libraries installed? It should be be something like this: http://rpmfind.net//linux/RPM/fedora/devel/i386/libgcc-4.0.0-8.i386.html - Jeff

Yes! Thank you. I create a link to /usr/lib from
/usr/lib/gcc/i386-redhat-linux/4.0.0/libgcc_s.so, and then my program can compile with the libchm.a successfully.
Thank you all.

Reply by email

Michael Preslar
to Linuxer Wang

Another question from a newbie fpc coder..

When compiling my project, I do a:

fpc -XS -XX -O3 -So -Fu~/manndoor/units -Fu~/manndoor/units/elecom -Fu~/manndoor/units/unix lord.pas

it goes through with its thing, warning me of unused variables and whatnot, but finishes with:

lord.pas(1841,1) Error: Can't call the linker, switching to external linking Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specifiy a source file to be compiled)

Whats the error that Im getting and how can I fix it?

Reply by email

Marco van de Voort
to Michael Preslar

[ Charset ISO-8859-1 unsupported, converting... ]

Show quoted text 16 lines
Another question from a newbie fpc coder.. When compiling my project, I do a: fpc -XS -XX -O3 -So -Fu~/manndoor/units -Fu~/manndoor/units/elecom -Fu~/manndoor/units/unix lord.pas it goes through with its thing, warning me of unused variables and whatnot, but finishes with: lord.pas(1841,1) Error: Can't call the linker, switching to external linking Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specifiy a source file to be compiled) Whats the error that Im getting and how can I fix it?

Typically this means "can't find binutils error".

So either you don't have binutils, or there is something wrong wiht it.

Reply by email

Michael Preslar
to Marco van de Voort
Show quoted text 11 lines
>lord.pas(1841,1) Error: Can't call the linker, switching to external linking >Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you >did not specifiy a source file to be compiled) > > >Whats the error that Im getting and how can I fix it? Typically this means "can't find binutils error". So either you don't have binutils, or there is something wrong wiht it.

Marco and Michael,

game]$ ld
ld: no input files

So it exists.. And I know it works (I compiled apache, et al).. or could this particular version of ld be messed up?

Reply by email

Michael Van Canneyt
to Michael Preslar: Another question from a newbie fpc coder.. When compiling my project, I do a: fpc -XS -XX…
Michael Preslar wrote 16 lines
Another question from a newbie fpc coder.. When compiling my project, I do a: fpc -XS -XX -O3 -So -Fu~/manndoor/units -Fu~/manndoor/units/elecom -Fu~/manndoor/units/unix lord.pas it goes through with its thing, warning me of unused variables and whatnot, but finishes with: lord.pas(1841,1) Error: Can't call the linker, switching to external linking Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specifiy a source file to be compiled) Whats the error that Im getting and how can I fix it?

You don't have the binutils installed. The compiler doesn't find 'ld'.

try executing the 'ld' command on a command prompt. If you get something like ld: Command not found
then you know ld is not installed, and you should install the binutils package.

Michael.

Reply by email

Michael Preslar
to Jonas Maebe

Marco and Jonas,

ld --version:
GNU ld version 2.14.90.0.4 20030523

Add the "-s" option to your command line options when compiling, and afterwards run ./ppas.sh. Then you can see what error ld gives.

Added -s to the command line, ran ppas.sh, and it linked. Strange, eh?

Reply by email

Michael Van Canneyt
to Michael Preslar
Michael Preslar wrote 11 lines
Marco and Jonas, ld --version: GNU ld version 2.14.90.0.4 20030523 > Add the "-s" option to your command line options when compiling, and > afterwards run ./ppas.sh. Then you can see what error ld gives. Added -s to the command line, ran ppas.sh, and it linked. Strange, eh?

Try running the compiler with -va, and examine the output. It should say where it looks for binaries, and why it didn't find 'ld'.

Michael.

Reply by email

Michael Preslar
to Michael Van Canneyt
Michael Van Canneyt wrote 20 lines
On Thu, 26 May 2005, Michael Preslar wrote: >Marco and Jonas, > > >ld --version: >GNU ld version 2.14.90.0.4 20030523 > > > >>Add the "-s" option to your command line options when compiling, and >>afterwards run ./ppas.sh. Then you can see what error ld gives. > >Added -s to the command line, ran ppas.sh, and it linked. Strange, eh? Try running the compiler with -va, and examine the output. It should say where it looks for binaries, and why it didn't find 'ld'.

(

just to keep the thread current, my current command line is:

fpc -va -XS -XX -O3 -So -Fu~/manndoor/units -Fu~/manndoor/units/elecom -Fu~/manndoor/units/unix lord.pas

)

Okay.. Running with -va.. The first time I run it, I get the following..

Searching file /usr/local/lib/fpc/2.0.0/ld... not found ...
Searching file /usr/bin/ld... found
Using util /usr/bin/ld
lord.pas(1841,1) Error: Can't call the linker, switching to external linking Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specifiy a source file to be compiled)

But the second time I run it

Searching file /usr/local/lib/fpc/2.0.0/ld... not found ...
Searching file /usr/bin/ld... found
Using util /usr/bin/ld
1969 Lines compiled, 9.7 sec

I can then recompile, over and over, without issue..

Reply by email