Sign in to follow this  
Flashthinker

Massive confusion

Recommended Posts

Flashthinker    100
Hi, C++ totally confuses me. The language itself is easy as; what confuses me the most is all the different file types you have to deal with. Also, I've never seen a C++ tutorial that actually gives you the basics on how C++ work, they get down straight to the language bit. Here are my questions: 1. What's the difference between a '.dll' file, a '.a' file, a '.o' file, a '.lib' file and a '.h' file? What does each one do? 2. When you download an API such as DirectX, where should you put the files? I'm using Dev-C++ and all I know is that I need to put the header files in the 'include' directory... I have no idea where to put all the other files and I have no idea what most of them even do.

Share this post


Link to post
Share on other sites
fpsgamer    856
Quote:
Original post by Flashthinker
Here are my questions:

1. What's the difference between a '.dll' file, a '.a' file, a '.o' file, a '.lib' file and a '.h' file? What does each one do?


.dll
-----
A Dynamic Library under windows. An executable can link against this library at runtime as opposed to compile time.

.a
----
A static library under *nix platforms. Similarly a *.so file is a shared library under *nix platforms.

.o
----
Object file. What is created by a compiler for each source file. A linker takes these files and "links" them all together to make your final executable.

.lib
-----
A static library under windows (as well as under other platforms). Just like a *.a file.

.h
-----
A header file. Used to share declarations between source files. Technically no different than any other text file file. An "#include foo.h" simply copies the contents of that file in place of that line. That line could as easily read "#include foo.jpeg" as long as its a text file.

Quote:
Original post by Flashthinker
2. When you download an API such as DirectX, where should you put the files? I'm using Dev-C++ and all I know is that I need to put the header files in the 'include' directory... I have no idea where to put all the other files and I have no idea what most of them even do.


You'll have to navigate the menus in Dev-C++ and modify your project settings. The compiler and linker need to know where to find all the *.lib, *.dll and *.h files associated with that library.

Also, may I suggest you use Visual Studio Express as your IDE?

[Edited by - fpsgamer on August 4, 2007 9:15:22 PM]

Share this post


Link to post
Share on other sites
Scet    960
Quote:

1. What's the difference between a '.dll' file, a '.a' file, a '.o' file, a '.lib' file and a '.h' file? What does each one do?


A DLL file contains machine code just like an executable file(.EXE), it has a slightly different structure that allows executables to load them into memory and call the functions inside.

.A and .LIB are library files, I don't know exactly how they work, I believe they either contain machine code or "links" to functions inside DLLs.

.O is an "object file", these are created by your C++ compiler. The compiler creates a .O file for every C++ file, the linker then merges them and assembles the result, creating an executable(note that the assembler may be a different program then the linker).

.H is just a plain text header file, there's nothing special about its format. When you have an #include the compiler opens that .H file and inserts its contents into the C++ file at the point of the #include statement.

Quote:

2. When you download an API such as DirectX, where should you put the files? I'm using Dev-C++ and all I know is that I need to put the header files in the 'include' directory... I have no idea where to put all the other files and I have no idea what most of them even do.


Well first of all, Dev-C++ is an old hat and is no longer being updated. You can move to either Code::Blocks(same compiler package as Dev-C++) or Microsofts Visual C++ Express. Second, the libs and includes in the SDK are meant for Microsofts compilers and probably won't work with GCC(the compiler Dev-C++ and Code::Blocks use) so if you want to keep using it you're have to get the DirectX DevPak.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this