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?
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
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:
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:
g++ -o my_exec my_exec.cpp -DWHATEVER_DEFINE -lGLEW -lglut -lGLU -lGL
or if you compile and link separately, something like this:
g++ -o my_exec.o -c my_exec.cpp -DWHATEVER_DEFINE
g++ -o my_exec my_exec.o -lGLEW -lglut -lGLU -lGL
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:
This last one is in french, but looks more precise:
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.