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: Can't compile under Windows but under Linux

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

    Can't compile under Windows but under Linux

    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?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,155
    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. 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 that should build/run on Windows and Linux you can play with if you'd like to try it out.

  3. #3
    Junior Member Newbie
    Join Date
    May 2014
    Posts
    11
    Quote Originally Posted by Dark Photon View Post
    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. 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 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.

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
  •