How to compile OpenGL applications with GLUT
Compile manually with mingw
Set environment variables $CPATH$
and LIBRARY_PATH
to locate glut.h
and glut32.lib
.
If they are not set, use option -I'[include_path]'
and -L'[library_path]'
.
g++ [source_file] -o [target_file] -lfreeglut -lopengl32 -Wl,–subsystem,windows
Build with Sublime Text
Create a new build system.
{
“cmd”: [“g++”, “${file}”, “-o”,”${file_path}/${file_base_name}”,”-lfreeglut”,”-lopengl32”,”-lglu32”,”-Wl,–subsystem,windows”],
“working_dir”: “${file_path}”,
“variants”:
[
{
“name”: “Run”,
“cmd”: [“cmd”,”/C”,”${file_path}/${file_base_name}.exe &pause”]
}
]
}
Build with CMake
Help about configurationsCMakeLists
## OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
## OpenGL
FIND_PACKAGE(GLUT REQUIRED)
INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})
TARGET_LINK_LIBRARIES([project_name] ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
Error when starting GLUT app when compiled for 64 bit
The application was unable to start correctly (0xc000007b). Click OK to close the application.
Make sure to link with the correct (64-bit) version of the library, and there is the correct (64-bit) dll available on the path.
How to compile OpenGL applications with GLUT