27th June

I am lucky to be at TCC because here everyone learns (or hear about/search) a new thing daily. So I came to know how a single or two keywords can give you the required results on the search engine. So to find a thing on Internet is not an easy task as we think it is. As from last two days, I found nothing about the hatching algorithm, but last night I added two keywords to my searches and I found some beneficial results to learn from. Firstly, I was searching like “hatching algorithm”, “hatching algorithm in c++”, in libreCAD , in CAD, and much more like this. But then last night, I searched “hatching algorithm with line”, I found a link “cs1.bradley.edu/public/jcm/cs535Hatching.html“. Then me and Gurpinder tried to compile the program. But it showed many errors.

#Installing OpenGL Libraries and errors faced

The program includes the OpenGL libraries like gl.h, glut.h etc. We must link them while compiling to execute the program. At first, I got errors like “windows.h  : no such file or directory”. Because it works in Microsoft Windows OS so I just excluded this line using “//” at the beginning of the line. Then the second error was like “gl/gl.h  :no such file or directory”. To solve this error we must install the OpenGL (Graphics Libraries) by typing in terminal:

sudo apt-get install freeglut3 freeglut3-dev

Also install the following library:

sudo apt-get install libglew1.5

Remove the spaces inside the < > brackets and instead of writing < GL/glew.h > write <GL/glew.h
Then I compiled the program referring the command from Internet:

g++-I/usr/include -L/usr/lib -lglut -lGL -lGLU -lGLEW example.cpp -o example

Here example.cpp is the main c++ program and example at the end is the executable file. It’s more likely that g++ by default looks for GL/glew.h in /usr/local/include.

And always type above command like this : GL/gl.h  Here GL must be in capital letters. If you had corrected these errors, then if there is still an error like “<iostream.h> no file or directory” then remove the .h and simply use #include<iostream>. Then after all header file errors were solved and there was an error like “main must return an int “. To correct this, use “int main()” instead of “void main()”.

After all above steps, when I recompiled it using command

g++ -I/usr/include/GL -I/usr/lib -lGL -lglut new.cpp

Then I got about 90 lines of error. Here is the errors : Link to errors

Then one of my friend Jagmeet Singh helped me and he wrote it like this:

g++ new.cpp -I/usr/include/GL -I/usr/lib -lGL -lglut

and then we were left with one error only. I was quite happy then. The error was

g++ new2.cpp  -I/usr/include/GL -I/usr/lib -lGL -lglut
/tmp/ccLO5WPf.o: In function `myInit()':
new2.cpp:(.text+0x13c): undefined reference to `gluOrtho2D'
collect2: error: ld returned 1 exit status

Then I excluded this line containing “gluOrtho2D” form the program. It showed a blank white window.

Then at home I searched on Internet about the error and found the result of linking the library.

So the final compiling code is :

g++ new2.cpp  -I/usr/include/GL -I/usr/lib -lGL -lglut -lGLU

Then a executable file will be created itself. Then execute that by ./ for example


in my case.

So, we can conclude that almost everything is on Internet. This is our way to search that matters. If we find a solution then we should present it in a better way so that in future it can help other Internet users.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close