I am on Ubuntu 12.04 and I try to compile and link the same code for both x86 and x64 architectures. It is a simple 3D application based on OpenGL. In fact it is not even 3D at the moment:
#include <GL/glut.h>
void draw(void)
{
// Background color
glClearColor(0, 1, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
// Draw order
glFlush();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50,25);
glutInitWindowSize(500,250);
glutCreateWindow("Green window");
glutDisplayFunc(draw);
glutMainLoop();
}
So, what I need is only lGL and lglut, right now. I installed them through the freeglut3 package and I suppose only the 64-bit version is what I got. When I compile and link for the 64-bit version (with -m64
) everything goes fine but when doing it with -m32
I get these errors:
/usr/bin/ld: warning: skipping incompatible //usr/lib/x86_64-linux-gnu/libGL.so while searching for GL
/usr/bin/ld: error: cannot find -lGL
/usr/bin/ld: warning: skipping incompatible //usr/lib/x86_64-linux-gnu/libglut.so while searching for glut
/usr/bin/ld: error: cannot find -lglut
Now, my question is: where and how do I get the 32-bit version of GL and glut and how do I link them when building the 32-bit binary, if that is possible?
UPDATE: I installed the :i386 variant of freeglut but now I get these linking errors for both architectures:
/usr/bin/ld: error: cannot find -lGL
/usr/bin/ld: error: cannot find -lglut
Using multiarch package options should make it. with the magic command:
dpkg --add-architecture <arch>
If still in trouble, the last solution would be a small 32bit chroot with debootstrap
/usr/sbin/debootstrap --arch i386 jessie \
/mnt/yournewsmall32bitenv http://ftp.us.debian.org/debian