C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-27-2009, 12:02 AM   #1
Registered User
 
Join Date: Sep 2009
Posts: 7
what is the best standard C libary for ubuntu?

I want to do some graphics programming with gcc, and am wondering which is the best graphics libary to use.

Cheers Mick
mickpc is offline   Reply With Quote
Old 09-27-2009, 02:27 AM   #2
Registered User
 
Join Date: Jul 2007
Posts: 44
C standard library != graphics library. You already have a c standard library, most of your system depend on it. For graphics library check SDL for 2D and OpenGL for 3D. If you want to write GUI, read about Qt (C++, used by KDE) or Gtk (C, used by Gnome, pain in arse).
fronty is offline   Reply With Quote
Old 09-27-2009, 03:05 AM   #3
Registered User
 
Join Date: Sep 2009
Posts: 7
I used synaptic to download libsdl1.2-dev and tried to compile a sample file, but the headers were not recognised.

:|

Cheers Mick
mickpc is offline   Reply With Quote
Old 09-27-2009, 05:29 AM   #4
Registered User
 
Join Date: Jul 2007
Posts: 44
Are the headers located in some directory which is in your include path?
fronty is offline   Reply With Quote
Old 09-27-2009, 10:06 AM   #5
Allways learning
 
cs_student's Avatar
 
Join Date: Aug 2008
Location: ~/
Posts: 32
There is a pretty good guide for setting up and creating a simple test program at lazyfoo.net.

Just skip the part about downloading and installing the rpm since you have already installed the deb.

If your using automake && autoconf

Then just copy
Code:
<insert_var_here>_LDADD = -lSDL
to your Makefile.am
cs_student is offline   Reply With Quote
Old 09-27-2009, 12:16 PM   #6
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,944
I believe SDL is a C++ API.

If you want to use C, just use openGL (which is the 3D graphics part of SDL) with "glut".
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 09-27-2009, 04:58 PM   #7
Allways learning
 
cs_student's Avatar
 
Join Date: Aug 2008
Location: ~/
Posts: 32
Nope, it's a C graphics API, so you can use it with C or C++.
cs_student is offline   Reply With Quote
Old 09-27-2009, 06:58 PM   #8
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,139
Quote:
Originally Posted by MK27 View Post
I believe SDL is a C++ API.

If you want to use C, just use openGL (which is the 3D graphics part of SDL) with "glut".
Standard "glut" is abandoned. And the "forks" like freeglut don't really offer much. I'd go with SDL or glfw if you want to use OpenGL.
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim
zacs7 is offline   Reply With Quote
Old 09-27-2009, 08:42 PM   #9
Registered User
 
Join Date: Sep 2009
Posts: 7
Quote:
Originally Posted by cs_student View Post
There is a pretty good guide for setting up and creating a simple test program at lazyfoo.net.

Just skip the part about downloading and installing the rpm since you have already installed the deb.

If your using automake && autoconf

Then just copy
Code:
<insert_var_here>_LDADD = -lSDL
to your Makefile.am
Is that a already made makefile? Or will I have to create it? If not, where would I find it?
Also do I have to enter a value for insert_var_here?

Edit: up until now I have just been typing gcc -o test test.c

Last edited by mickpc; 09-27-2009 at 09:03 PM.
mickpc is offline   Reply With Quote
Old 09-28-2009, 10:40 AM   #10
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,944
Quote:
Originally Posted by zacs7 View Post
Standard "glut" is abandoned. And the "forks" like freeglut don't really offer much. I'd go with SDL or glfw if you want to use OpenGL.
Well, okay, I meant freeglut, since yes, the original glut is defunct. I've used it with all the standard docs that refer to glut (inc, eg, the OGL superbible, AND the red book). It is maintained and it works perfectly. I believe everything that was in glut is in freeglut*, I've seen this stated a number of times and never heard anything to the contrary, so you are are full of tish on this. If you go to the official openGL forum and make this claim, you will get laughed off the page. Sorry. Freeglut is widely used, and it functions identically w/r/t any documentation that includes glut (which is most or all OGL documentation for beginners).

@mickpc: you need to use linker flags, eg for OGL/glut:

gcc test.c -lglut -lGLU -lGL -lXext -lX11 -lm

Maybe some nice person will post the flags for SDL; if not I am sure they are on page one of the intro tutorial or whatever...

* in any case, IMO you might as well keep your use of glut to a minimum; all it has to do is manage a window and an event loop. This way, when you want to really polish up and handle your own loop and window management, you will not find you have written something that involves a lot of higher-level functions from a secondary toolkit. The point of glut is just to allow you to do pure OpenGL programming easily. It is not to add a whole bunch of features like sound effects or whatever. It is a "low level" approach vs. the "high level" of SDL, which is it's own thing that potentially includes OGL -- whereas glut doesn't do anything except provide a cross-platform for OGL. It is and should be minimal. I have nothing against SDL, just this is apples and oranges. AFAICT (I have written a simple patch for tuxpaint, which is an SDL kid's game), you can do all kinds of stuff with SDL that really have absolutely nothing to do with 3D graphics programming.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS

Last edited by MK27; 09-28-2009 at 12:23 PM.
MK27 is offline   Reply With Quote
Old 09-28-2009, 11:16 AM   #11
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 801
kennedy != graphics programmer PERIOD!!!

. . . but, I thought that GTK was considered the "standard"?
Kennedy is offline   Reply With Quote
Old 09-28-2009, 11:26 AM   #12
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,944
Quote:
Originally Posted by Kennedy View Post
kennedy != graphics programmer PERIOD!!!

. . . but, I thought that GTK was considered the "standard"?
GTK is a GUI API, not 3D. Like firefox (in linux) uses GTK. I believe there is a widget to embed 3D stuff, namely OGL, but I've never tried it.

ps. you can thread GTK and OGL/glut together...
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 09-28-2009, 11:36 AM   #13
Registered User
 
Join Date: Jul 2007
Posts: 44
SDL is written in C, but it has bindings for frigging many languages. But basically it's a C library.

GTK is "standard" widget toolkit on GNU, because it's used by GNOME.

Portable graphics programming => SDL with OpenGL.
Non-portable graphics programming for Unix-likes => Xlib, GLX, GLUT or whatever you want.
Portable GUI => if you want C++, Qt, if you don't, just do it or suffer.
fronty is offline   Reply With Quote
Old 09-28-2009, 11:56 AM   #14
Registered User
 
Join Date: Oct 2006
Posts: 263
Quote:
Originally Posted by fronty View Post
SDL is written in C, but it has bindings for frigging many languages. But basically it's a C library.

GTK is "standard" widget toolkit on GNU, because it's used by GNOME.

Portable graphics programming => SDL with OpenGL.
Non-portable graphics programming for Unix-likes => Xlib, GLX, GLUT or whatever you want.
Portable GUI => if you want C++, Qt, if you don't, just do it or suffer.
Qt is not the only portable C++ gui toolkit. I use wxWidgets almost exclusively for gui stuff, and it's everything I need and more. it includes OpenGL stuff as well, and is certainly worth looking into if you want a truly cross-platform gui toolkit with OpenGL capability.
Elkvis is offline   Reply With Quote
Old 09-28-2009, 12:05 PM   #15
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,944
Actually GTK is cross-platform as well. AFAIK, glut is not tho [edit: wrong]. The GTK openGL extension does not appear to use glut.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS

Last edited by MK27; 09-28-2009 at 12:24 PM.
MK27 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard efficiency Jorl17 C Programming 3 06-18-2009 11:48 AM
array initialization & C standard jim mcnamara C Programming 2 09-12-2008 03:25 PM
include question Wanted420 C++ Programming 8 10-17-2003 03:49 AM
C/C++ standard confuted A Brief History of Cprogramming.com 3 07-06-2003 03:22 AM
standard language, standard compiler? doubleanti A Brief History of Cprogramming.com 8 09-03-2001 04:21 AM


All times are GMT -6. The time now is 03:23 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22