Я хотел бы библиотеки OpenGL настройки и запустить простой GL программка:Не удается скомпилировать GLUT HelloWorld с MinGW
#include <windows.h>
#include <Gl/glut.h>
int main()
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
return 0;
}
Я строю проект с использованием CLion и поэтому вот мой CMakeLists.txt:
cmake_minimum_required(VERSION 3.1)
project(MuspellsheimR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(MuspellsheimR ${SOURCE_FILES})
Я скачал GLUT here и положить glut.dll в C: \ Windows \ SysWOW64 (и в C: \ Windows \ System32 на всякий случай), glut.h в C: \ MinGW \ включать \ GL и glut32.lib в C: \ MinGW \ lib. Вот исходящее сообщение я получаю:
CMakeFiles\ProjectName.dir/objects.a(main.cpp.obj): In function `glutInit_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:486: undefined reference to `[email protected]'
CMakeFiles\ProjectName.dir/objects.a(main.cpp.obj): In function `glutCreateWindow_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:503: undefined reference to `[email protected]'
CMakeFiles\ProjectName.dir/objects.a(main.cpp.obj): In function `glutCreateMenu_ATEXIT_HACK':
c:/mingw/include/gl/glut.h:549: undefined reference to `[email protected]'
CMakeFiles\ProjectName.dir/objects.a(main.cpp.obj): In function `main':
PATH/main.cpp:7: undefined reference to `[email protected]'
PATH/main.cpp:8: undefined reference to `[email protected]'
PATH/main.cpp:10: undefined reference to `[email protected]'
PATH/main.cpp:11: undefined reference to `[email protected]'
PATH/main.cpp:12: undefined reference to `[email protected]'
PATH/main.cpp:13: undefined reference to `[email protected]'
PATH/main.cpp:14: undefined reference to `[email protected]'
PATH/main.cpp:15: undefined reference to `[email protected]'
PATH/main.cpp:16: undefined reference to `[email protected]'
PATH/main.cpp:17: undefined reference to `[email protected]'
какие сообщения об ошибках вы получаете? –
@ м.с. ах, вы, конечно. Добавление в сообщение. – omtcyfz
Никогда не помещайте такие вещи, как 'glut.dll' в' C: \ Windows'. Когда-либо. Просто поставьте его рядом с вашим исполняемым файлом. – rubenvb