PDA

View Full Version : Can't compile under Windows but under Linux



QuesterDesura
10-20-2017, 10:56 AM
Hello,

I can compile a OpenGL application just fine doing so:

g++ -std=c++11 -o main Main.cpp FastNoise.cpp shader.cpp texture.cpp libglfw3.a lib
GLEW.a -Wl,-Bdynamic -lGL -lGLU -lX11 -lXxf86vm -lXrandr -lpthread -lXi -ldl -lXinerama -lXcursor

But if I compile it like this:

g++.exe -std=c++11 -o main Main.cpp FastNoise.cpp shader.cpp texture.cpp libglfw3.a lib
GLEW.a

Then I get tons of undefined reference errors. I have tried doing this under Ubuntu with MinGw64 and under Windows with MinGw and g++. I had the same issue under Visual Studio and I fixed it by adding this praeprocessor defintions:
WIN32
_WINDOWS
TW_STATIC
TW_NO_LIB_PRAGMA
TW_NO_DIRECT3D
GLEW_STATIC
_CRT_SECURE_NO_WARNINGS
CMAKE_INTDIR="Debug"

Is there any way to tell MinGw to use those praeprocessor defintions?

Dark Photon
10-21-2017, 10:32 AM
Building command-line on Windows can definitely be a pain compared to Linux, due to flavor-of-the-month MSVS environment and other build environments.

To make it easy, I'd recommend that you just use CMake (https://cmake.org/). Then you can use the same build config across Linux and all the myriad build environments for Windows, often with little to no change on your part, hiding most of that platform-specific voodoo.

Here's a simple example (https://www.opengl.org/discussion_boards/showthread.php/199957-Async-buffer-copies-from-fbo-pbo-am-I-doing-it-wrong) that should build/run on Windows and Linux you can play with if you'd like to try it out.

QuesterDesura
10-21-2017, 02:38 PM
Building command-line on Windows can definitely be a pain compared to Linux, due to flavor-of-the-month MSVS environment and other build environments.

To make it easy, I'd recommend that you just use CMake (https://cmake.org/). Then you can use the same build config across Linux and all the myriad build environments for Windows, often with little to no change on your part, hiding most of that platform-specific voodoo.

Here's a simple example (https://www.opengl.org/discussion_boards/showthread.php/199957-Async-buffer-copies-from-fbo-pbo-am-I-doing-it-wrong) that should build/run on Windows and Linux you can play with if you'd like to try it out.


I actually ended up making a CMake myself yesterday on my own. But I'm not sure how to compile for Windows the best way. Currently I'm using the CMakeGUI to create a new Visual Studio Project and use the builded .exe from the VS project. Is there any way to directy build a .exe from CMake? Also I managed to make a .exe with the g++.exe but sadly it shows me a error that a EntryPoint hasn't been found. More details are on stackoverflow (https://stackoverflow.com/questions/46853251/compile-linux-opengl-application-on-windows).