Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Trouble in generating 32bit GLFW application on Ubuntu 17.04

  1. #1
    Newbie Newbie
    Join Date
    Jul 2017
    Location
    Los Angeles
    Posts
    2

    Trouble in generating 32bit GLFW application on Ubuntu 17.04

    Hi Everyone,

    I've been working on a 3D Engine supporting both 32bit and 64bit on Linux. I'm using GLFW and I was able to successfully generate a 64 bit(amd64) application. I used the in-build supplied Cmake stuff to generate GLFW make files and built.

    Whenever I try to build a 32bit(i386) application I always run into this error

    Code :
    skipping incompatible ../RenderingLibraries/lib/Linux/ when searching for -lglfw
    /usr/bin/ld: cannot find -lglfw

    I understand that the generated libglfw.so is of a 64bit version. My question is how to generate 32bit version of libglfw.so ?
    I don't have much experience in building 32 bit for linux. Any help is much appreciated.

    Thanks,
    Bharath
    Last edited by Bharath; 07-08-2017 at 03:14 PM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,090
    Quote Originally Posted by Bharath View Post
    Whenever I try to build a 32bit(i386) application I always run into this error

    Code :
    skipping incompatible ../RenderingLibraries/lib/Linux/ when searching for -lglfw
    /usr/bin/ld: cannot find -lglfw

    I understand that the generated libglfw.so is of a 64bit version. My question is how to generate 32bit version of libglfw.so ?
    The easiest thing to do is see if there are 32-bit GLFW package available in your distro's package manager. If so, just install them instead of building them. There may be one package for libs and one for devel (headers).

    If not, you'll need to build GLFW for 32-bit. It uses CMake, so for best results, websearch "cmake 32-bit build" and/or "ubuntu 32-bit build". I'd post some notes on how to do this with OpenSuSE, but that might not be much use to you.

    The main flag to look for in the directions is adding "-m32" to the compiler command line. For instance, here's a solution for Ubuntu that might work for you. Try doing this before you run cmake: Building a 32-bit app in 64-bit Ubuntu.
    Last edited by Dark Photon; 07-09-2017 at 02:40 PM.

  3. #3
    Member Regular Contributor
    Join Date
    Jul 2012
    Location
    France
    Posts
    400
    Just like for all debian-like distributions, you'll first need to enable multi-arch.
    Then you'll have to install all 32-bit packages required for building and linking with 32 binaries. This will include glfw, GL, X11 and probably many/several other packages.
    And after do what Dark Photon told about Building.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2017
    Posts
    7
    Sample code: the sample Makefile and source code build a simple line drawing application and runs on Linux, Mac OS X, and Windows platforms. You can also try out some examples with buffer objects and shaders.
    For instructions on how to build GLUT programs, please refer to the course note Building OpenGL/GLUT Programs. Please let me know if you have any correction or addition. Thanks.
    To find out how to specify command line options, add to header file search path, and link with libraries such as glew, expat, jpeg, and png, see the course note on these topics.

    Linux:
    version: Ubuntu 14.04.1 LTS (Trusty Tahr), 12.04.5 LTS (Precise Pangolin)
    gcc: 4.8.2, 4.6.3
    Eclipse 3.7.2-1 (Indigo)

    First install GLFW's dependencies, including OpenGL/Mesa:
    Code :
    sudo apt-get install cmake xorg-dev libglu1-mesa-dev
    You must have sudo privileges. (On Red Hat, you'll need to install cmake28 instead.)
    You should now have:
    /usr/include/GL
    /usr/lib/x86_64-linux-gnu/libGL.so
    At the time of writing, the GLFW package one gets with apt-get is version 2.7 whereas we're using version 3.0.4. So we need to install GLFW from source. Unzip the source file and change your working directory to the glfw-3.0.4 directory. Install GLFW:

    Code :
    cd glfw-3.0.4
    rehash
    cmake -G "Unix Makefiles"
    make
    sudo make install

    You should now have:
    /usr/local/include/GLFW
    /usr/local/lib/libglfw3.a
    In your OpenGL source files, include the following line:
    Code cpp:
    #include <GLFW/glfw3.h>
    You don't need to include gl.h as it is already included in glfw3.h.
    For an example, see the provided sample source code.
    If you want to include glu.h automatically, set the -DGLFW_INCLUDE_GLU compiler flag.
    To make a GLFW application on the command line, use the following linker options:
    -lglfw3 -lGL -lm -lXrandr -lXi -lX11 -lXxf86vm -lpthread
    The last three libraries are needed on Ubuntu 14.04.1.

    Eclipse 3.7.2 project (graphical step-by-step):
    To install Eclipse:
    Code :
    sudo apt-get install eclipse eclipse-cdt
    Start up Eclipse and choose your workspace, click "OK" (Fig. 1)
    Open the C/C++ perspective: on the main menu select "Window→Open Perspective→C/C++" (Fig. 2). If the C/C++ perspective is not available, choose "Other..." and it should show up in the window that pops up.
    Last edited by Dark Photon; 07-10-2017 at 03:06 PM.

  5. #5
    Newbie Newbie
    Join Date
    Jul 2017
    Location
    Los Angeles
    Posts
    2

    Phew !! Finally I was able to build libglfw.so, libglfw.so.3 libglfw.so.3.2 32 bit after installing a lot of dependencies !!!

    Just to help others I wanted to post here what I did.

    In order to build 32-bit glfw libraries on Linux(I used Ubuntu), execute the following commands and install the following list of all dependencies

    Commands :
    1) dpkg--add-architecture i386
    2) sudo apt-get update
    3) sudo apt-get install gcc-multilib libx11-6:i386 libxrandr-dev:i386 libxinerama-dev:i386 libxxf86vm-dev:i386 libxcursor-dev:i386

    install packages now

    packages :

    sudo apt-get install libx11-dev:i386
    sudo apt-get install libxrandr2:i386
    apt-get install libxinerama1:i386
    sudo apt-get install libxxf86vm1:i386
    sudo apt-get install libxcursor1:i386
    sudo apt-get install libvulkan-dev:i386
    sudo apt-get install libxrandr-dev:i386
    apt-get install libxinerama-dev:i386
    sudo apt-get install libxcursor-dev:i386
    sudo apt-get install libc-dev:i386
    sudo apt-get install libgl-dev:i386
    last command
    4) cmake -DCMAKE_C_FLAGS="-m32" -DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib/i386-linux-gnu path/to/glfw/source

    You can install built libraries using "make install", but it would just install in /usr/local/lib/.

    Make sure to copy all libglfw.so, libglfw.so.3 and libglfw.so.3.2 files to the /usr/lib/i386-linux-gnu folder as Ubuntu expects it to be in there for building GLFW applications.

    follow this link for more information http://discourse.glfw.org/t/trouble-...tu-17-04/942/7
    Hope this will help somebody :slight_smile: ...

    Thank you so much for your assistance guys. I appreciate it :slight_smile:

    -Bharath

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •