CLion MinGW freeglut opengl 库链接

CLion MinGW freeglut opengl library linking

我正在尝试按照 this guide 配置我的 freeglut 和 opengl。

我习惯了 android studio 的 intellij 环境,所以我想在 Clion 工作。

我卡在了那部分....

Libraries: the OpenGL library "libopengl32.a", GLU library "libglu32.a" and GLUT library "libfreeglut.a" are kept in "\lib" directory. This directory is in the implicit library-path. Nonetheless, we need to include these libraries in linking. They shall be referred to as "opengl32", "glu32", "freeglut" without the prefix "lib" and suffix ".a".

如何在 Clion 中添加这个?

CLion 使用 cmake 构建您的项目。按照以下步骤将 link 个库添加到您的项目中。 打开项目中的 CMakeLists.txt 文件并添加,

target_link_libraries(<target executable> libopengl32.a libglu32.a libfreeglut.a)

到那个文件。

target executable 是您要 link 这些库的可执行文件。通常这是您在 add_executable.

中定义的项目名称

注意: 如果在 add_executable.

之前放置 target_link_libraries,Cmake 将显示错误