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 3 of 3

Thread: Compile for Linux on Windows 10?

  1. #1
    Junior Member Newbie
    Join Date
    May 2014
    Posts
    9

    Compile for Linux on Windows 10?

    Hello,

    I made a simple application with C++ and OpenGL in Visual Studio Community 2017. How can I compile this so it runs on linux as well? I had quite some issues setting up OpenGL under Windows and I have no clue how to set this up without Visual Studio helping me. I tried creating a new plattform but it doesn't seem to know the .libs like glu or opengl32 nor I do know what exactly I need to do. Also can someone explain me why I can't compile my project without having this settings in preprocessor definition?

    WIN32
    _WINDOWS
    TW_STATIC
    TW_NO_LIB_PRAGMA
    TW_NO_DIRECT3D
    GLEW_STATIC
    _CRT_SECURE_NO_WARNINGS
    CMAKE_INTDIR="Debug"

    This issue I had years ago and I did just figured it out after trying opengl again and carefully checking all settings from a different project, but in the project and in all other tutorials I found it is not mentioned that I need those defines, but I can't compile without manually adding them.

    Thanks for your help
    Last edited by QuesterDesura; 09-18-2017 at 07:30 AM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,123
    Quote Originally Posted by QuesterDesura View Post
    I made a simple application with C++ and OpenGL in Visual Studio Community 2017. How can I compile this so it runs on linux as well?
    Use CMake. It'll generate your Makefiles on Linux and your MSVS project/solution files on Windows.

    Here's a link to a short example:

    * Short, standalone GLUT/GLEW test program

    Alternatively, you can just create a completely separate Makefile for use under Linux, and then maintain both the MSVS proj/sln files and Linux Makefiles in parallel. But this is only practical for trivially-small apps (needless duplicate work gets to be a drag).

    I had quite some issues setting up OpenGL under Windows and I have no clue how to set this up without Visual Studio helping me. I tried creating a new plattform but it doesn't seem to know the .libs like glu or opengl32 nor I do know what exactly I need to do. Also can someone explain me why I can't compile my project without having this settings in preprocessor definition?
    Ultimately, you're trying to run compile and link commands that look something like this:

    Code :
    g++ -o my_exec my_exec.cpp -DWHATEVER_DEFINE -lGLEW -lglut -lGLU -lGL

    or if you compile and link separately, something like this:

    Code :
    g++ -o my_exec.o -c my_exec.cpp -DWHATEVER_DEFINE
    g++ -o my_exec my_exec.o -lGLEW -lglut -lGLU -lGL

  3. #3
    Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    418
    Quote Originally Posted by QuesterDesura View Post
    How can I compile this so it runs on linux as well?
    If, what you want is not to compile it again in Linux, then the words you are looking for are cross compilation. In that case, here are some links that could be interesting:

    http://metamod-p.sourceforge.net/cro...for.linux.html
    https://stackoverflow.com/questions/...ndows-to-linux

    This last one is in french, but looks more precise:
    http://tcuvelier.developpez.com/tuto...ss/?page=intro

Tags for this Thread

Posting Permissions

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