using gcc -m32 flag cannot find -lgcc and -lgcc_s - linux

I'm trying to compile a 32 bit assembly code(NASM) on my 64 bit Linux, but I can't, I have tried others tutorials about it and I installed ia32-libs...
When I try run it as:
gcc asm1.o -o asm1
i386 of the file input `asm1.o' is incompatible with the output i386:x86-64
And when I try run it as:
gcc -m32 asm1.o -o asm1
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: connot find -lgcc_s
collect2: error: ld returned 1 exit status
Thanks for helps.
OBS: Sorry for my english, I'm not from US.

Need to install gcc-multilib.

Related

HEXAGON Halide Tools 2.3: /usr/bin/ld: cannot find -lc++abi

I did not get response from Qualcomm forum so I decided to post here. When I was trying to run examples of Halide for Hexagon by running make run as written in the document. Then I got the following issue. The -lc++abi is missing.
clang++ -std=c++11 -I /opt/qcom/Hexagon_SDK/4.3.0.0/tools/HALIDE_Tools/2.3.03/Halide/include -stdlib=libc++ -O3 -g -fno-rtti -rdynamic conv3x3_generator.cpp /opt/qcom/Hexagon_SDK/4.3.0.0/tools/HALIDE_Tools/2.3.03/Halide/lib/libHalide.a /opt/qcom/Hexagon_SDK/4.3.0.0/tools/HALIDE_Tools/2.3.03/Halide/tools/GenGen.cpp -o /opt/qcom/Hexagon_SDK/4.3.0.0/tools/HALIDE_Tools/2.3.03/Halide/Examples/build/offload/hexagon_benchmarks/bin/conv3x3.generator -lz -lrt -ldl -lpthread -lm
/usr/bin/ld: cannot find -lc++abi
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked the /usr/lib and find. So it should be there?
./x86_64-linux-gnu/libc++abi.so.1.0
./x86_64-linux-gnu/libc++abi.so.1
./llvm-10/lib/libc++abi.so.1.0
./llvm-10/lib/libc++abi.so.1
Did I miss anything or make anything stupid? Thanks!
ld is your system's host linker -- that's GNU BFD ld. clang++ must be in your PATH but it's the host clang++ and not the hexagon-clang++ that would be with Halide/Hexagon tools.
I contacted the person from Qualcomm. I am not supposed to use either /usr/bin/clang++ nor hexagon-clang++. I downloaded clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz from https://releases.llvm.org/7.0.1/. You should use clang++ under the bin folder after you extract it. Now it works for me.

/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libQtCore.so when searching for -lQtCore

When I try to build a new project using Qt Creator, I get these errors:
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libQtGui.so when searching for -lQtGui
/usr/bin/ld: cannot find -lQtGui
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libQtCore.so when searching for -lQtCore
/usr/bin/ld: cannot find -lQtCore
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so when searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.a when searching for -lpthread
collect2: error: ld returned 1 exit status
make: *** [untitled] Error 1
This is the command line from Compile Output:
g++ -m32 -o untitled main.o mainwindow.o moc_mainwindow.o -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
It seems it is trying to build in 32-bit mode even though I'm on Ubuntu 64-bit.
I found the problem - my Qt Kits were all wrong. I had reinstalled Ubuntu recently, switching from 32-bit to 64-bit, but I had preserved my home folder, and I had a stale configuration at ~/.config/QtProject/. Deleting that folder fixed my problem and now Qt Creator builds projects fine.

Compiling for 32 bit on a 64 bit DMD

I am using xubuntu 16.04 amd64, and use the D Language. I used to use DMD i386 on a 32 bit machine (ubuntu 14.04), but now, for some reason, I can't (or don't want to) install DMD_i386 on my system, so I installed the one for amd64. All of my projects were written on a 32 bit machine, and I used the int type instead of the long type that's available on 64bit. Now whenever I try to compile something that I wrote earlier, that looks something like this, gives an error;
void someFunction(){
string[] someArray;
uint ln = someArray.length;//This compiled perfectly on 32 bit, but now it says that someArray.length is ulong, and ln is uint.
}
I know that changing ln's type to ulong will fx it, but I wan't to compile this for 32 bit, and not 64 bit, and on 32 bit, the long/ulong type isn't available, since it uses 64 bits.
What I've tried:
I've tried using the -m32 switch to make DMD produce 32 bit output. The error mentioned above is fixed by this, but a linker (ld) error shows up:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
--- errorlevel 1
How do I get DMD to produce 32 bit output on a 64 bit DMD?
Solved the problem myself. Turns out, I was missing some packages needed by the linker. This solved the problem:
sudo apt install gcc-multilib

Cross-compiling Snap7 for MIPS with OpenWrt as OS

Currently i'm working on a project to log data out of a Siemens PLC. To achieve this i'm using Snap7. Snap7 (http://snap7.sourceforge.net/) is a communication library.
I've managed to get it work on my linux desktop but when i try to cross-compile the snap7 library i get some errors
The error is generated when linking all of the object files.
g++ -shared -fPIC -o ../bin/mips-openwrt-linux-g++/libsnap7.so #"filelist.txt" -L. -lpthread -lrt -O3
/usr/bin/ld: ../temp/mips-openwrt-linux/sys_snap_msgsock.o: Relocations in generic ELF (EM: 8)
./temp/mips-openwrt-linux/sys_snap_msgsock.o: could not read symbols: File in wrong format
collect2: error: ld returned 1 exit status
make: *** [../bin/mips-openwrt-linux-g++/libsnap7.so] Error 1
If i'm correct i think it's using the wrong linker, it should use the linker of the toolchain located at: openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
I've also tried to compile the software with mips-openwrt-linux-g++.
Now another error is given:
mips-openwrt-linux-g++ -shared -fPIC -o ../bin/mips-openwrt-linux-g++/libsnap7.so #"filelist.txt" -L. -lpthread -lrt -O3
openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.8.3/../../../../mips-openwrt-linux-uclibc/bin/ld: ../temp/mips-openwrt-linux/sys_snap_msgsock.o: relocation R_MIPS_26 against `close' can not be used when making a shared object; recompile with -fPIC
../temp/mips-openwrt-linux/sys_snap_msgsock.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [../bin/mips-openwrt-linux-g++/libsnap7.so] Error 1
I hope someone is familiar with this error and can help me out.
Thanks in advance.
edit1:
There are some pre-compiled binaries. In the makefiles i changed the CC to my g++ directory. There is no LD flag so i cannot set my linker over there.
Can you cross compile and run a "hello world" program?
What is the output of file ../temp/mips-openwrt-linux/sys_snap_msgsock.o?

Not found z library when compiling zabbix-server

I have a problem with compiling zabbix-server on CentOS 6.2.
Command line is:
./configure --enable-server --with-mysql --with-net-snmp --with-libcurl
--with-jabber --with-ssh2 --with-openipmi --with-ldap --enable-static
But error occures:
checking for main in -lz... no
configure: error: Not found z library;
Full configure output is here: http://pastebin.ru/WmDP7UL0
I already tried to do:
yum install zlib zlib-devel zlib-static zlibrary zlibrary-devel
But it was unsuccessfully.
Thank you for your attention.
UPD. Config log posted here: http://pastebin.ru/WNtQu9eR and shows this error:
configure:7366: checking for main in -lz
configure:7385: gcc -o conftest -g -O2 -rdynamic -static conftest.c -lz -lm -lrt -lresolv >&5
/usr/bin/ld: cannot find -lm
collect2: ld returned 1 exit status
Here's the actual error:
/usr/bin/ld: cannot find -lm
But it is found previously, which points to something else. Check your ulimits to make sure you don't have a low max open file count.

Resources