Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile 32bit with 64bit g++

I'm using codeblocks. I'm using ubuntu. Here is output of compilation.

g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/WEBGINE/Component.cpp -o obj/ReleaseCGI32/src/WEBGINE/Component.o
g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/WEBGINE/Debug/ComData.cpp -o obj/ReleaseCGI32/src/WEBGINE/Debug/ComData.o
g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/WEBGINE/Debug/DebugCom.cpp -o obj/ReleaseCGI32/src/WEBGINE/Debug/DebugCom.o
g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/WEBGINE/Error/ErrorCom.cpp -o obj/ReleaseCGI32/src/WEBGINE/Error/ErrorCom.o
g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/WEBGINE/Request.cpp -o obj/ReleaseCGI32/src/WEBGINE/Request.o
g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/WEBGINE/Site.cpp -o obj/ReleaseCGI32/src/WEBGINE/Site.o
g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/WEBGINE/WEBGINE.cpp -o obj/ReleaseCGI32/src/WEBGINE/WEBGINE.o
g++ -Wall  -O2  -m32 -nostdlib    -Iinclude  -c /home/miroslav/Development/WEBGINE/src/main.cpp -o obj/ReleaseCGI32/src/main.o
g++  -o /home/miroslav/htdocs/freelife/index32.cgi obj/ReleaseCGI32/src/WEBGINE/Component.o obj/ReleaseCGI32/src/WEBGINE/Debug/ComData.o obj/ReleaseCGI32/src/WEBGINE/Debug/DebugCom.o obj/ReleaseCGI32/src/WEBGINE/Error/ErrorCom.o obj/ReleaseCGI32/src/WEBGINE/Request.o obj/ReleaseCGI32/src/WEBGINE/Site.o obj/ReleaseCGI32/src/WEBGINE/WEBGINE.o obj/ReleaseCGI32/src/main.o   -s -m32 -L/usr/lib32/  
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.3/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.3/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.3/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.3/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++

Little info about 32bit libs:

miroslav@miroslav-desktop:/usr/lib32$ ls -la libst*
lrwxrwxrwx 1 root root     19 2010-06-21 20:50 libstdc++.so.6 -> libstdc++.so.6.0.13
-rw-r--r-- 1 root root 975088 2010-03-27 01:16 libstdc++.so.6.0.13
like image 779
kravemir Avatar asked Oct 10 '10 14:10

kravemir


People also ask

How to compile 32-bit program on 64-bit gcc in c?

Now in order to compile with 32-bit gcc, just add a flag -m32 in the command line of compiling the 'C' language program. For instance, to compile a file of geek. c through Linux terminal, you must write the following command with -m32 flag. After that you will be able to compile a 32-bit binary on a 64-bit system.

Is gcc 32 or 64-bit?

Compile 32-bit program on 64-bit gcc in C and C++Nowadays the compiler comes with default 64-bit version. Sometimes we need to compile and execute a code into some 32bit system. In that time, we have to use thisS feature. At first, we Shave to check the current target version of the gcc compiler.

What is difference between G ++ and gcc?

DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.

What is m32 flag?

The -m32 flag tells GCC to compile in 32-bit mode. The -march=i686 option further defines what kind of optimizations to use (refer to info gcc for a list of options). The -L flag sets the path to the libraries you want GCC to link to.


1 Answers

Be sure to install gcc-multilib and g++-multilib. These depend on both the 64 as the 32-bit gcc and stdc++ libraries.

like image 118
rubenvb Avatar answered Oct 11 '22 03:10

rubenvb