# Building 32bit libraries on a 64bit ubuntu

**URL:** <https://discourse.glfw.org/t/building-32bit-libraries-on-a-64bit-ubuntu/680>\
**Category:** support\
**Created:** [June 14, 2016, 9:30am UTC](https://discourse.glfw.org/t/building-32bit-libraries-on-a-64bit-ubuntu/680 "2016-06-14T09:30:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@Peter](https://discourse.glfw.org/u/Peter)\
**Post date:** [June 14, 2016, 9:30am UTC](https://discourse.glfw.org/t/building-32bit-libraries-on-a-64bit-ubuntu/680/1 "2016-06-14T09:30:11Z")

</div>

Hello,

I’m running the 64bit version of ubuntu 16.04LTS on my computer.  
In the first phase of my project I compiled a 64bit executable on it, everything was ok, glfw was doing ok.  
But now in the second phase, I have to compile the same program as a 32bit application.

As I’m using ubuntu I need to compile the glfw library from the source code using cmake.

My question now how can I build a 32bit glfw library on a 64bit operating system using cmake.  
And can the 64bit glfw3 library and its 32bit equivalent exist next to each other.

In the make file of **my** program I already specified the -m32, but I think the glfw3 library is still a 64bit library.  
When I compile my program I have the following errors:

/usr/bin/ld: skipping incompatible /usr/local/lib/libglfw3.a when searching for -lglfw3  
/usr/bin/ld: skipping incompatible //usr/local/lib/libglfw3.a when searching for -lglfw3  
/usr/bin/ld: cannot find -lglfw3  
/usr/bin/ld: cannot find -lXrandr  
/usr/bin/ld: cannot find -lXinerama  
/usr/bin/ld: cannot find -lXcursor  
/usr/bin/ld: cannot find -lXrender  
collect2: error: ld returned 1 exit status  
makefile:145: recipe for target ‘bin/SolOS’ failed  
make: \*\*\* [bin/SolOS] Error 1

As I’m completely new to this 32bit vs 64bit compatibility issue, all help is welcome.

Peter

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [June 16, 2016, 1:05pm UTC](https://discourse.glfw.org/t/building-32bit-libraries-on-a-64bit-ubuntu/680/2 "2016-06-16T13:05:43Z")

</div>

I don’t have any of my Linux environments with me at the moment, but have you tried [this stackoverflow answer on 32bit compilation on a 64bit machine with gcc/cmake](http://stackoverflow.com/questions/1272357/how-to-compile-a-32-bit-binary-on-a-64-bit-linux-machine-with-gcc-cmake) ?

Alternatively, if you use add\_subdirectory( glfw ) to include the glfw cmake project in your projects cmake file then I think the build flag -m32 should carry over. Note you need glfw to be a subdir of your project above where you have the cmakelists.txt file.
