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 configurations
CMakeLists

## 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.

OpenGL编程起步

先不提OpenGL,因为我好像并不懂C++项目的构建。

error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCR…

http://blog.csdn.net/playstudy/article/details/6661868

C语言运行时找不到适当的程序入口函数

灵活运用一下

http://www.cnblogs.com/qinfengxiaoyue/archive/2012/05/27/2519706.html

调用库

#pragma comment(lib,”opengl32.lib”)