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
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.
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.
DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.
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.
Be sure to install gcc-multilib
and g++-multilib
. These depend on both the 64 as the 32-bit gcc and stdc++ libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With