C:\MinGW " as the address, but if it bothers you, you can choose another one, for example, " C:\Program Files\Common Files\MinGW ".MinGW\bin " and " MinGW\msys\1.0\bin ". To do this, go to Start -> Control Panel -> System -> Advanced System Settings ; In the Advanced tab, click below the button Environment Variables . From the list of system variables, select Path , and separate the full addresses to the folders “ MinGW\bin ” and “ MinGW\msys\1.0\bin ” with a semicolon.cmd ), and write the following commands: mingw-get update Update information about available packages. mingw-get show g mingw-get show g++ Display the full gcc and g ++ package names, mingw-get upgrade mingw32-gcc mingw-get upgrade mingw32-gcc-g++ Update these packages to the latest available MinGW versions.freeglut.dll from the bin folder we throw in " C:\Windows\System32 " (for x86) or " C:\Windows\SysWOW64 " (for x64), or any other folder that is specified in the PATH . The contents of the include and lib folders can be copied either to " MinGW\include " and " MinGW\lib " (this will be easier), or to separate created folders " MinGW\freeglut\include " and " MinGW\freeglut\lib ".#include <GL/freeglut.h> gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 ar cr lib/libglew32.a src/glew.o As a result, 3 files appeared in the lib folder: glew32.dll , glew32.dll.a and glew32.a .glew32.dll copied to the same place where freeglut.dll previously copied, the other 2 - to the folder " MinGW\lib " or " MinGW\glew\lib ".include folder, copy the contents into " MinGW\include " or " MinGW\glew\include ".#include <GL/glew.h> , but this must be done before connecting other gl libraries. #include <iostream> #include <GL/glew.h> #include <GL/freeglut.h> #include <GL/gl.h> int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(512, 512); glutInitContextVersion(4, 1); // OpenGL, glutInitContextProfile(GLUT_CORE_PROFILE); glutCreateWindow(argv[0]); if (glewInit()) { std::cerr << "Unable to initialize GLEW ... exiting\n"; exit(EXIT_FAILURE); } glutMainLoop(); } glewinfo.exe from the bin folder. It will generate the glewinfo.txt file, which will describe in detail what your video card supports and what doesn't. Sometimes the functionality can be expanded by installing a more recent video driver.test.cpp and write the following command: g++ -o test.exe test.cpp -lglew32 -lfreeglut -lopengl32 -lglu32 -Wl,--subsystem,windows In case you created separate folders freeglut and glew , here you must additionally indicate the corresponding additional folders include and lib . Then the command example looks like this: g++ -o test.exe test.cpp -lglew32 -lfreeglut -lopengl32 -lglu32 -Wl,--subsystem,windows -I"C:\MinGW\freeglut\include" -L"C:\MinGW\freeglut\lib" -I"C:\MinGW\glew\include" -L"C:\MinGW\glew\lib" -Wl,--subsystem,windows flag -Wl,--subsystem,windows indicates to the compiler that it should create a graphical application, not a console one.test.exe out, you should get the test.exe file, which when launched creates a white window 512x512.freeglut.dll and glew32.dll .C:\Users\%Username%\AppData\Roaming\Sublime Text 2\Packages\C++\C++.sublime-build "C:\Users\%Username%\AppData\Roaming\Sublime Text 2\Packages\User\C++\++ OpenGL.sublime-build " "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"], We supplement the connection of libraries: "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "-lfreeglut -lopengl32 -lglew32 -Wl,--subsystem,windows"], "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"] supplement to "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' -lglew32 -lfreeglut -lopengl32 -lglu32 -Wl,--subsystem,windows && '${file_path}/${file_base_name}'"] If you created separate folders under freeglut and glew, these commands should be supplemented by specifying the addresses of additional folders include and lib . "selector": "source.c, source.c++", add "encoding": "cp1251", test.cpp open, choose Tools -> Build system -> C ++ OpenGL .GL/gl.h header file is not enough. It contains outdated version 1.1, and this file is no longer being updated. In addition to this, you need to connect GL/glext.h (the latest version of which you need to download from here ) and GL/wglext.h ( from here ). For Linux, the last file is replaced with GL/glxext.h ( link ). The downloaded files need to be replaced with their outdated versions at the address " MinGW/include/GL/ ".Source: https://habr.com/ru/post/177885/
All Articles