1
\$\begingroup\$

I am a total beginner in C++ and programming generaly.

I have watched a couple hours of C++ tutorials and read a lot about it (Can anyone recommend some tutorials?), but what I've come across and couldn't understand was Libraries.

I want to develop games in C++ (I think, it seems the most interesting at the moment). I can understand that I need a library for game programming in C++, but I don't know much about libraries, what specifically a library is, or where to find these libraries.

Thank you for your time. This is my first question here. I apologize if it wasn't a proper question for this website, or if the english was bad. I still hope you can give me some kind of answer and/or reponse.

\$\endgroup\$
6
  • 3
    \$\begingroup\$ Well, lua is indeed very good, but not all games need scripting. For example, you'll make an tetris game, where will you need scripting? You can say one or other things, but of course, you can do all these hardcoded. But if you need a big game that needs flexibility and scripting systems(that im afraid you answer yes, because as you said, you're not very familiar with programming) then go for it, but its a little complicated to manage. \$\endgroup\$ Commented Jan 8, 2012 at 21:07
  • 1
    \$\begingroup\$ I would suggest taking a look at this question. Ought to help you get started on game programming in C++ and introduce you to a couple of libraries. \$\endgroup\$
    – Mike Cluck
    Commented Jan 9, 2012 at 1:33
  • 7
    \$\begingroup\$ "I am a total Beginner in C++ and programming generaly." OK, stop right there. If you're a total beginner at programming, then the first thing you should learn is, well, programming. If you really want to make games, you're going to need to learn how to program something. And you need that first, not while you're also learning the details of game development. \$\endgroup\$ Commented Jan 12, 2012 at 21:17
  • 2
    \$\begingroup\$ Welcome to the site! You really have two distinct questions here (asking about C++ libraries and asking about embedding Lua), which are fairly different. You may want to edit your question to make it more focused. I would recommend removing the Lua bits as they really are a more advanced topic -- you should learn to program first. \$\endgroup\$
    – user1430
    Commented Jan 25, 2012 at 16:09
  • 1
    \$\begingroup\$ I removed the question about Lua, please post it seperately. I've done this so that your question doesn't get closed, because it already has one close vote on it. I'll answer about libraries below. \$\endgroup\$
    – Engineer
    Commented Jan 25, 2012 at 18:53

1 Answer 1

2
\$\begingroup\$

C/C++ libraries are modules of already-compiled code which are accessed through code you will write.

For example, TinyXML is a library that provides a lot of the functionality you would need to parse XML data, allowing you to work with XML without having to write your own parser.

Libraries come in two different flavours: static libraries and dynamic libararies.

  • A static library is specifically used at compile time, which means the libary must be present in the correct location (often but not always somewhere in your project folder) when you want to compile your C/C++ application, since it is compiled into the executable, and indeed, the compiler knows it must be there and will not compile without it. Under Windows, static libraries are usually suffixed .lib, while under the *nixes (includes Android, iOS, MacOS), they are suffixed .a.

  • A shared library is only required to be present for use at runtime. Which means you can compile your code without it. Since a shared library is not actually a part of your application's code (although your application may need it to run without failing), there is a certain overhead, however negligible, in accessing shared libraries (and it is downright negligible). When you run your favourite games, you will often see DLL files hanging out in the game's root folder, beside the executable. Those are shared libraries which the executable will need to use when you run it. Under Windows, shared libraries are .dll. Under the *nixes, they are .so. There are many differences undoubtedly, but the principle is the same, and most of the time from a coder's point of view they are not noteworthy.

Compiling libaries is another matter, which you can research once you've written a few simple programs in C or C++ and understand the bigger picture a little better. But generally speaking, it isn't too hard and is much like compiling an executable, only the code gets compiled into a non-executable file instead.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .