Author Topic: Creating a GLFW project in C::B.  (Read 6870 times)

Offline momaa

  • Multiple posting newcomer
  • *
  • Posts: 16
Creating a GLFW project in C::B.
« on: August 29, 2006, 10:50:38 am »
Code: cpp
Hello all and thanks for a great product.

I just created a new GLFW-project using the "new from template" dialog (in File -> New -> Project menu). 
GLFW is an open source, portable framework for OpenGL application development.
Picture 1: http://bildr.no/view/9536

1) But before that, I downloaded GLFW-framework from http://glfw.sourceforge.net/
And saved it to: $HOME/code/glfw/ folder.

Compiled GLFW as instructed in the readme.html file.
$ ./compile.sh
$ make x11-gcc

The compilation completed without errors.

Then installed libglfw.a  and glfw.h:

I copied $HOME/code/glfw/lib/x11/libglfw.a to  /usr/local/lib/GL/
$ sudo cp $HOME/code/glfw/lib/x11/libglfw.a  /usr/local/lib/GL/
(note: it's /lib/x11/ and not /lib/ )

And copied $HOME/code/glfw/include/GL/glfw.h to /usr/include/GL/
$ sudo cp $HOME/code/glfw/include/GL/glfw.h   /usr/include/GL/
--------

Problems when creating a GLFW-project from template.

I created a new project as shown here: http://bildr.no/view/9537. OK so far.

But then it asked for the location of GLFW library and include file.
See picture 2: http://bildr.no/view/9538

I pointed it to "$HOME/code/glfw/" directory, but it did not accept that. 
IT COULD NOT FIND "libglfw.a" there.

Why ?
Because it expects to find "libglfw.a" in lib/ directory, but "libglfw.a" is in lib/x11/ directory.

$ ls -l  lib/x11/
-rw-r--r-- 1 moma moma 64188 2006-08-29 08:30 lib/x11/libglfw.a

OK, I had to manually move the "libglfw.a" to the right place (under lib/ folder )

It also expects to find "glfw.h" in the same place, under include/ directory. The dialog blocks until you give the ""right"" information.
------------------------------------

Actually, this dialog (see: http://bildr.no/view/9538 ) is unnecessary (in Unix/Linux version of C::B). 
There's NO reason why it should ask where the "libglfw.a" and "glfw.h" files are.  It should not block.
AT LEAST IT SHOULD NOT EXPECT THAT THESE FILES ARE SAVED IN SOME FIXED LOCATION (AND THAT BOTH FILES ARE IN THE /SAME/ LOCATION). 

In my case, I had already installed the Library in /usr/local/lib/GL and the Include file in /usr/include/GL directory.

And the developer can easily add new paths and library names in Project -> 'Build options' dialog, under Linker and Directories tabs.

The above dialog should be turned to a message box that says:
"This project requires GLFW OpenGL framework. Make sure that libglfw.a and glfw.h are installed in your system.
Visit http://glfw.sourceforge.net/ for more information."

-----------------------------------------------------------------------

Despite this small problem I really love Code::Blocks.
Picture 3: http://bildr.no/view/9540
Thanks a lot.

Cheers,
// moma
------------------------------------------------------------------------

System information:

$ lsb_release  -a

Distributor ID:   Ubuntu
Description:   Ubuntu 6.06.1 LTS Linux
Release:   6.06
Codename:   dapper

$ uname -a
Linux ubuntux 2.6.15-26-k7 #1 SMP PREEMPT Thu Aug 3 03:40:32 UTC 2006 i686 GNU/Linux
-----

C::B's about-dialog shows this version string
Code::Blocks version 1.0 revision 2916 (2006-08-28 11:22:47) gcc 4.0.3 Linux/unicode

------------------------------------------------------------------------

PS. In case some of you want to develope GLFW applications on Ubuntu Dapper (Ubuntu 6.06) Linux, there's a minor tweak you need to do in addition to installation of GLFW and GLUT libraries.

The code from the GLFW project template failed with this error message:

/usr/bin/ld: cannot find -lXxf86vm
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)

See picture 4: http://bildr.no/view/9539

I had "libXxf86vm.so.1" in my system but the linker could not find it because it was not linked to "libXxf86vm.so"

$ locate Xxf86vm
/usr/lib/libXxf86vm.so.1
/usr/lib/libXxf86vm.so.1.0.0

So I linked the library to its real .so name which the linker is looking for.
$ sudo ln -s /usr/lib/libXxf86vm.so.1 /usr/lib/libXxf86vm.so

And the example code compiled and run very well.
----------------

Some of the examples on GLFW site (the Tutorials section) require also GLUT library. Install GLUT
$ sudo apt-get install freeglut3 freeglut3-dev 
Freeglut3 is the latest up2date version while libglut3 is obsolete.

Study this blog page... if you want to know the whole story.
 8)

« Last Edit: August 29, 2006, 05:32:52 pm by momaa »