So I have a project that I want to be able to build as a 64bit binary as well as as a 32bit one.
My machine itself is 64bit and the 64bit compile works just fine.
I am using cake
to build my project and I used the set_target_properties(clib PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
to force a 32bit build.
Whenever I try to build this the compiler throws an error, because I am including <iostream>
in my main program. At first it complained that it couldn't find <bits/c++config.h>
which gets included somewhere inside <iostream>
.
I found a couple of things online which led me to install g++-multilib
on my system. Now the previous error is gone but instead I am getting the error
/usr/include/linux/errno.h:1:10: fatal error: asm/errno.h: No such file or directory
which also has its origins in the #include <iostream>
.
I checked where this file is and I found it in /usr/include/x86_64-linux-gnu/asm/errno.h
but (as before with the c++config.h
the x86_64
folder appears to not be searched in a 32bit build (which kinda makes sense).
I also found it in /usr/include/linux/errno.h
which is identical to the precious one, but as you can see it is not in the asm
subfolder.
Obviously I could manually move it into that folder but I have the feeling that there is something generally wrong with my setup here.
So what else do I have to setup in order for me being able to compile my code (with a #include <iostream>
) as a 32bit executable? Is there something like a 32bit-version of the std-library?
EDIT:
I am using Linux Mint 18.3 with g++ --version
of g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
and cmake v.3.10.2
g++-multilib
and its dependencies (and obviously it doesn’t, I’m not questioning that). What distribution (including its version) are you using?cmake
? (This will help determine whetherg++
is causing problems, orcmake
.)g++ -m32 main.cpp
but it resulted in the same error