flat assembler
Message board for the users of flat assembler.

Index > Linux > Linker error with libcdemo

Author
Thread Post new topic Reply to topic
dstyl



Joined: 23 Jul 2015
Posts: 67
dstyl 03 Aug 2016, 09:39
Im trying to link the example libcdemo.o but i get the following error
Code:
gcc libcdemo.o -o libcdemo
/usr/bin/ld: i386 architecture of input file `libcdemo.o' is incompatible with i386:x86-64 output
collect2: error: ld returned 1 exit status
    

Does anyone know the reason?
Thx in advance
Post 03 Aug 2016, 09:39
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 03 Aug 2016, 10:12
Probably you are trying to link 32bit executable with 64bit linker. There should be some magic options to switch the target CPU.
Also, imho for assembly language programs it is better to use directly the linker ld, instead of the C++ compiler gcc.
Post 03 Aug 2016, 10:12
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
dstyl



Joined: 23 Jul 2015
Posts: 67
dstyl 03 Aug 2016, 12:53
JohnFound wrote:
Probably you are trying to link 32bit executable with 64bit linker. There should be some magic options to switch the target CPU.
Also, imho for assembly language programs it is better to use directly the linker ld, instead of the C++ compiler gcc.

Can you please post the cmd for ld, would help me a lot and thanks for your answer.
Post 03 Aug 2016, 12:53
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 03 Aug 2016, 12:57
I am using FASM to generate directly the executable files and hate the linkers since my childhood. Very Happy So, maybe someone else will be able to help you.
Post 03 Aug 2016, 12:57
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Melissa



Joined: 12 Apr 2012
Posts: 125
Melissa 04 Aug 2016, 23:56
try gcc -m32 ...
Post 04 Aug 2016, 23:56
View user's profile Send private message Reply with quote
dstyl



Joined: 23 Jul 2015
Posts: 67
dstyl 05 Aug 2016, 08:07
I get
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
from
gcc -m32 libcdemo.o -o libcdemo
Post 05 Aug 2016, 08:07
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 05 Aug 2016, 08:45
FYI, depending on your linux distro and whatever package manager you use, there are 32bit compat goods that are needed. I happily run openSUSE Leap, and using its package manager, if I search for gcc I see the following tidbits that would fix your -lgcc:

i | libgcc_s1-32bit | C compiler runtime library | package

There are likely other similar 32bit library requirements but that is the one your output is complaining about.
Post 05 Aug 2016, 08:45
View user's profile Send private message Reply with quote
dstyl



Joined: 23 Jul 2015
Posts: 67
dstyl 05 Aug 2016, 09:02
I have libgcc4.9 installed, it still searches for lgcc, i have linux mint as distro.
I get the same problem with nasm and ld -s -o xy xy.o
Post 05 Aug 2016, 09:02
View user's profile Send private message Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 05 Aug 2016, 17:48
What if you install lib32gcc-4.9-dev? I guess it pulls every necessary depending package as well, so don't be scared looking at the list of packages being installed Wink.


Last edited by Endre on 10 Dec 2016, 22:15; edited 1 time in total
Post 05 Aug 2016, 17:48
View user's profile Send private message Reply with quote
system error



Joined: 01 Sep 2013
Posts: 670
system error 18 Aug 2016, 19:09
I remember this problem. I don't know about Mint, but in Ubuntu you need to install "g++-multilib libc6-dev-i386" before you can use that -m32 switch.
Post 18 Aug 2016, 19:09
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.