Archived

This topic is now archived and is closed to further replies.

cody

opengl & linux

Recommended Posts

yesterday i installed suse linux 7.3. i wanted to make a small opengl program with gcc. but it doesnt find the gl headers and the lib file. so what do i need to compile a opengl program? a have already installed the nvidia display drivers for my geforce3 and it works. where do i get the library files, headers and dlls for gl? i noticed that linux uses other file extensions than windows. .dll=.so (i think) .lib=? what about kdevelop? is it good? it looks like vc... cody

Share this post


Link to post
Share on other sites
Well I''m not even as far along as you are. I''m still
trying to get Linux to play nice with all my hardware.
But hell that was an up hill battle in windows.
anyway, if I recall you will need to download the openGL
header files. They are not included directly with the OS
generaly. They do get around alot so you may pick up the source
code somewhere or I think they are avalible on whatever OpenGL
site you might find. Most prog. that use OpenGL probably are
already precompiled so they have little need to supply u with
the source code. I think thats what I read somewhere.

Share this post


Link to post
Share on other sites
Most Linux distros use Mesa, the Open Source implementation of the OpenGL spec (I believe it''s 1.2-compliant). Your GL header files should have been installed if you installed development packages; check your /usr/include directory. The appropriate libs should also be in /usr/lib.

Linux libraries are named lib*, where the * represents the package name. So the Standard C++ Library is libsdtc++, and the Mesa (OpenGL) libraries are libGL, libGLU (GLUT), etc. Library files come in two flavors: shared object and static libraries. Shared objecys (think: Windows DLLs) have the .so extensions, which would mean libGL.so for GL shared objects; and .a for static libs (libGL.a).

Have fun, kids!

Share this post


Link to post
Share on other sites
Actually, .lib != .a

Windows uses .libs for both static linking and dynamic linking. In the latter case, the .lib just holds information about which functions are in the .dll.

On Linux, you use .a for static linking, and the .so holds both the actual library code and the linking information used w/ dynamic linking.

cu,
Prefect

One line of sourcecode says more than a thousand words.

Share this post


Link to post
Share on other sites
Libraries under Linux have extensions with .so
or .so.. Example: libGL.so.1.2

If you have /usr/Somewhere/lib/libGL.so.1.2
then somewhere on yer linker line you need
-lGL and -L/usr/Somewhere/lib

Note that the lib prefix of the file name of
libGL.so.1.2 is omitted and also the extension
is omitted as well.

Share this post


Link to post
Share on other sites
Usually you will find the openGL-headers in /usr/include/GL.
So just include GL/GL.h (or possibly GL/gl.h, I can''t remember right now).
Note that linux is case-sensitive, so be sure that the directory is GL and not gl.

-Neophyte

Share this post


Link to post
Share on other sites
Did you include the OGL library in the command line for compiling:
gcc mysource.c -o myexecutable -lGL

I tried in vain to compile some oGL programs, and it worked after I included the GL library in the gcc command with the -l option.

I hope this helps

Share this post


Link to post
Share on other sites
thanks for your help, but i didnt get it to work:-(

my problem is:
i searched for gl.h, libGL etc. and found some files... all in different directories and cant imagine how gcc should find them... so where must these files be?

-lGL doesnt work, gcc sais there are undefined references.
i used this header:
/usr/share/doc/packages/nv_glx/usr/include/GL/gl.h
(how should somebody find that??)
-there is a libGL.so.1.0.1541.nv_glx in /usr/lib, however i dont know how to use it, gcc also doesnt work when i copy the libGL to my working directory.

-in /usr/include are no gl headers

i would like to use the nvidia headers and libs like obelix said.

im totally confused... windows is easier...

cody

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok, you need to link it against more libraries than just GL.

Try this :

gcc -lXext -lXmu -lXi -lX11 -lGL -o yourprogram source.c

You might also need -lGLU if you''re using GLU, and -lm, depending on your program.

Hope this helps.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ah and create a symlink to your gl libraries.

su
password:
cd /usr/lib
ln -s libGL.so.1.0.1541.nv_glx libGL.so

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
.lib=.a and .so=.dll

Actually .o is also a kind of lib file under Linux. .a files are simply archives of .o files.

.o - object file (lib)
.a - archive file (lib)
.so - shared object file (dll and lib)

Share this post


Link to post
Share on other sites
I installed too linux, Mandrake 8.1 and installation was very very easy.

I have a problem with KDevelop. I can''t create new projects/files (lol). The new button on toolbar and menu are grayed.
Maybe there''s something I don''t know yet about Linux
Hepl me to create new project/files.

Share this post


Link to post
Share on other sites
quote:
Original post by stefu
I have a problem with KDevelop. I can''t create new projects/files (lol). The new button on toolbar and menu are grayed.


That''s odd. Not much lost though, I didn''t like KDevelop much when I tried it (it is overly complex for simple projects). If you get the time, read a tutorial on makefiles (they really aren''t as hard to do as they seem), maybe you''ll like using the command line as much as I do? (Anjuta and ETerm are all I need )

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
No worry I'll do it command line

I just found that I need to first make new project: Project -> ApplicationWizard. I was too common with VisualC ad looked just File -> New

edit:

Actually I found after a moment KDevelop complex, I'll not use it.

PS. Where to get glu.h for linux?

more edit:

Shall I ask where to put all sources, libraries ... in linux, how to organize all. Are there any rules/considerations so that whenever I get a code and it requires some libraries and header files to compile, it comples without any changes? Sorry for dumb question, but I'm quite first timer with Linux

Edited by - stefu on October 31, 2001 9:25:39 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hmm, I found KDevelope to be outstanding. The new project button is in the top/center of the main screen. Use what ever you find more comfortable but personally I found it refreshing to see there is a comparable setup to MSVC++(which I also liked)

Share this post


Link to post
Share on other sites