My first linuxOpenGL Program (ubuntu) -- Linux general technology-Linux programming and kernel information. The following is a detailed description. [Configuration is slightly troublesome]
Although it is expected to be a little more difficult in ubuntu than in windows, there are still insufficient preparation. At first, a package was installed less, and then the compilation parameters were mistakenly added ...... In order to prevent future forgetting and adding blog content by the way, I recorded my wall hitting this hour.
[Preparations]
To compile a cpp-based OpenGL program, we must first prepare a text editor, C ++ compiler, and OpenGL & GLut library file.
The ubuntu system comes with some text editors: vim used by veterans and gedit used by beginners. Since both linux and openGL/Glut are new to the first-class production model (all words are incoherent-_-B), it is necessary to use gedit.
The gcc compiler (SET) in linux is quite famous, but ubuntu does not come with it and needs to be installed on its own. On the command line, enter:
Sudo apt-get install build-essential
In fact, build-essential is not a compiler, but a dependency between a bunch of software packages. After it is installed, the general compiler problem is basically solved.
The problem is solved by the OpenGL/Glut library. Similarly, enter:
Int main (int argc, char ** argv)
{
Gluinit (& argc, argv );
Fig );
Valley createwindow ("Simple ");
Gludisplayfunc (RenderScene );
SetupRC ();
Glumainloop ();
Return 0;
}
[The Key to compilation is parameter]
Using gcc is different from using vs.net. IDE has done a lot of things for you. Here, we need to input the compilation parameters ourselves:
G ++ opgl. cc-o out. o-lglut-lGL-lGLU-lm-L/usr/X11R6/lib
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service