0
Can i set up and run openGL without IDE in windows 7 32bit on command prompt ? If possible, how can i do it ?
I search on gg but can't understand it
8 ответов
+ 1
Important question before proceeding: Why do you want to work without an IDE?
Now the (hopefully-)useful bit:
OpenGL is not something that you can "run". It's merely an interface that's used to communicate with the graphics processor. But, assuming you meant a program that *uses* OpenGL...
You need:
1. Some sort of Windowing library, so you have something to render stuff in. GLFW ( https://www.glfw.org ) is a good candidate. (Win32 API works too)
2. An OpenGL function loader, which basically provides your program with function pointers and utilities that you can use to communicate with the graphics processor. GLAD ( https://glad.dav1d.de ) is a good candidate. You can do this manually too, but it's quite a hassle to get working and *very* platform dependent.
3. A compiler to, well, compile the project. MSVC is the go-to solution on Windows. GCC and Clang-cl are also available.
4. A build system to invoke the compiler with the correct flags, file order, and link libraries. Also, to keep you sane :) ( https://cmake.org )
5. Obviously, a text editor of some sort. There are plenty of those. Sublime Text 3 is very lightweight and feature rich.
+ 1
Some important bits of information are missing for us to be able to help.
> I downloaded GLFW and put it into minGW
MinGW is a set of tools. How exactly did you put it into MinGW?
Are you using a build system, or calling the compiler (g++ i assume, since you're using MinGW) directly? If using a build system, which one? If g++ directly, what command are you using (the exact command)?
Did you download a precompiled version of GLFW (the headers and '.lib' files) or the source? If the source, did you build it (you have to!)?
> I included GLFW and it's ok
Like. `#include` the glfw header and the project compiled fine? If yes, then this is good!
> but I can't run it
No clue what this means.. Did you get an exe that's not working or a compile error? If compile error then what is it (the exact error message)? If you got an exe then how is it "not working" exactly? Any errors? Nothing's happening?
Also, there is no need to download GLAD if the GLFW window is not popping up. First get GLFW working then install GLAD. Setting it up should be easier than GLFW.
+ 1
> I put GLFW include part into minGW include Path in C drive
Under the 'include' directory, i assume? That's not really how it's done as that's for the system includes.
Usually, it should be in the same directory as your project, then you simply point the compiler to GLFW's include directory.
For example create a directory called 'external', copy GLFW's 'include/GLFW' (the whole directory called GLFW) to 'external/include/GLFW', then in the compiler command line add the switch '-I external/include' (-I is a capital i, not a lowercase L), so the command would look like (from the root of the project):
g++ -I external/include src/source1.cpp src/source2.cpp -o myProgram
As for the linker error "undefined reference to 'glfwInit'", that's because you provided the header file, but didn't link the library. In this case, it haven't been built yet.
To do that, follow the official guide: https://www.glfw.org/docs/latest/compile_guide.html
It should be as simple as:
- Install CMake
- Open CMD/Powershell in GLFW's source directory
- Run 'cmake -S . -B build'
- Run 'cmake --build build'
Now copy the generated 'glfw3.lib' (not 100% sure about the name, but it should have a '.lib' extension) from somewhere under 'build' to 'external/lib'
So to reiterate:
- Create the directories 'external', 'external/include', 'external/lib' in your project's directory
- Copy GLFW's 'include/GLFW' directory to 'external/include/GLFW'
- Build GLFW and copy the resulting glfw3.lib (or whatever the name .lib) to 'external/lib'
- Build the project
The command to build it, and correctly link GLFW should be something like (in the project root):
g++ -I external/include -L external/lib -l glfw3 -o myproj source1.cpp source2.cpp
-I (capital i) means "look for header files in this directory"
-L means "look for library files in this directory"
-l (lowercase L) means "link the project against this library". The name should be the same as that of the '.lib' file minus the extension, so if the name is 'glfw.lib',
+ 1
On a separate note, i highly recommend that you learn (and use) a build system as manually calling the compiler to build the project will quickly get out of hand. A build system will make your life much easier.
An easy to use, and quite feature rich build system is Premake: https://premake.github.io
A more "professional" and widely used build system is CMake (which GLFW happens to use): https://cmake.org
Though CMake is quite more complex and harder to learn, the features it provides makes it worth the effort.
0
Isho ,my machine can not run IDE. I downloaded GLFW and put it into minGW , I included GLFW and it's ok , but I can't run it . So will I download GLAD and also put it into minGW file ?
0
I put GLFW include part into minGW include Path in C drive and I run "#include "GLFW/glfw3.h" , it's not rising bug .and then I run command "glfwInit()" and "glfwTerminate()" it rise bug called " C:\Users\AppData\Local\Temp\ccONqq9T.o: Codeo.cpp : <.text+0xc> : undefined reference to 'glfwInit' . Collect2.exe : error : ld returned 1 exit status " .
0
I use minGW directly and run it in command prompt
0
I downloaded source package and put it directly without build, how can I build it Isho 🤔