tags:

views:

663

answers:

18

I recommended my friend the libraries in the book Numerical Recipes. However, it seems that they are too challenging for him.

I am not sure which libraries are the best for a newbie in C/C++.

Which libraries should a C or C++ newbie know?

+3  A: 

libm. :)

chaos
+11  A: 

The standard library, STL and then whatever they need to do the task they want. Add in some boost stuff for what are essentially standard library extensions as well.

workmad3
Specifically boost::bind is very useful, as is boost/thread/*.
jeffamaphone
Also: BOOST_FOREACH, boost::function, boost::format, boost::shared_ptr, boost::optoinal
Trey Jackson
+5  A: 

libc. libstdc++.

You can be quite successful with just those two.

dicroce
+4  A: 

C++: Boost, STL

C: math

Andrew Coleson
Not sure boost will work for someone who is new and struggling.
Drew Hoskins
That's a fair point, it's probably better to be Aware of the existence of Boost as he gets more advanced rather than to be familiar with it as a beginner.
Andrew Coleson
+2  A: 

string.h would probably get used a lot and if you're dealing with some calculations then math.h

TStamper
Those are header files, not libraries.
anon
@Neil- I'm referring to the library in general, which is why I linked the math one
TStamper
+2  A: 

To code pure C, let him start with ncurses for example. It's fun.

Oh no. Curses is truly horrid. It's worse than GDI. It's worse than boost::interprocess. Save me; my operating systems project memories are all flooding back. MAH! I'm going to get coffee.
jeffamaphone
It is still fun to play with semigraphics and to create and use windows with a little of code.
+11  A: 

The ones in the C Standard Library and C++ Standard Library are a must (and as Neil mentioned in his answer, make sure they understand the distinction between C and C++). Other than that, he should learn the ones he's going to use on a project.

I leave out Boost for two reasons: 1) I don't consider it required by newbs, and 2) Much of it is planned to be rolled into the standard library once C++0x replaces the old standard.

Bill the Lizard
+1  A: 

Obviously the standard C library (good documentation of it is at http://www.cppreference.com/wiki/). Other than that it really depends on what sort of stuff your friend wants to do.

If he really wants to do numerical stuff (and care a great deal about performance) than libblas is what he'll want http://www.netlib.org/blas/.

stonea
+11  A: 

As there is no such language as "C/C++" the answers you get here are not likely to be very useful. C programs will not be able to use the C++ libraries, and C++ programs probably have better alternatives to any suggested C libraries.

anon
Be nice to the newbs.
Dietrich Epp
+2  A: 

It depends on what said newbie wants to do.

Your language's standard library is obviously pretty essential. Beyond that, it depends. A C++ programmer will probably want to be familiar with at least some of the Boost libraries.

jalf
+6  A: 
  • C: there is a good description of the C89 library here. Once he masters that, GLib is very useful. It provides linked lists, expandable strings, directory access functions, etc., and it's portable enough.
  • C++: I think that the standard library is difficult enough to understand. Once he understands iostreams, strings and so on, he should focus on advanced topics like templates, smart pointers, exceptions and polymorphism. This should take a while.
Bastien Léonard
+1  A: 

For C: string.h (for functions like strcpy, strcmp, memcpy and the like), and stdio.h (for printf and friends).

Steve Melnikoff
+2  A: 

It really depends what you're going to do... I use a lot of libCurl, because I do a lot of internet-related stuff.

AriX
+4  A: 

I teach C in a high school in Italy.
During 2 years, once they have get the core of the language (pointers and streams in C ), students have to learn a different library and "show and tell" some samples.
Libraries are given depending on what are their interests and skills.
some examples:
computer graphic -> freeimage
text matching -> regex
game -> allegro
networking -> socket
database -> sqllite

and so on... Basically I think once you understand the language (and also the data-structures...) it must be "time for fun" and follow your tendencies.

@urk: You say that you are a teacher. Do you have some multiple choice question exams in the web for C? I would love to rehearse my C++ skills with them.
Masi
+1  A: 

Regarding C++ the he Boost library (http://www.boost.org/) is the most used library so you should start by looking there, if you already know C++ (contrary to what I saw in some of the previous answers you must understand that the STL is now part of the standard and so part of the C++ language).

There are too many other libraries to pick, all depend on what you intend to produce, if there is any that you "must" know, it will undoubtedly be a GUI library and if you don't mind the bloat try to looking into the Qt ( www.qtcentre.org ) this one would give you an almost complete toolset.

Remember that before you invest some time learning a new API you should select the ones that aren't too recent and are truly free, with no strings attached and no platform lockin, this includes the GPL license since it will limit you to produce GPL code.

Panic
+2  A: 

For C:

  • the standard library: just makes sense to know this
  • glib: cross-platform, reasonably complete, widely-used, and well documented.
  • gtk: insanely complicated, but if you need to write graphical applications in C it is tough to beat.

For C++:

  • STL and Boost
  • Qt4: cross-platform, very complete, free, widely-used, and well documented.

Also, keep in mind that when you learn something like C or C++ (or even Java) you aren't really learning the "language" you are learning the "platform". Choose a platform with all of the basic components that you'll want when writing a real app and not toying around with syntax. To be proficient and efficient at using a language you really have to know what tools you have, and the only way to do that is to use good examples of already existing toolkits. My 2 cents anyway.

@littlenag: Which libraries have the best concrete examples?
Masi
@Masi: You can find good examples of how to use any of these libraries by googling. I wouldn't say any are the best. I know I've found that GTK has a reasonably complete, if quite dated, set of examples.
+1  A: 

I would recommend looking into the ACE libraries, especially if you want to get into distributed and cross-platform development. It may be a bit much for a "newbie", but it is a great next-step after learning STL, and Boost. ACE also provides implemented design patterns.

http://www.cse.wustl.edu/~schmidt/ACE.html

Dan
A: 

If writing for windows I would suggest MFC

gonzohunter