![]() |
|
#1
|
||||
|
||||
Bloodshed Dev C++ Project OptionsI finally dusted that C++ programming book I bought 2 years ago and read a couple of chapters again.
Maybe it's all the reading I do on this C++ forum and the easy-to-understand posts & example codes by our senior members, but I find that it is a lot easier to understand what I was reading this time around (or maybe I am just a little more interested). That's the background... now I want to ask my question. I installed Bloodshed Dev C++ 4.9.9.2 and when I start the program, it prompts me about the "Project". One of the tabs, Basic, lists options like:
Who can explain what each means, in plain English? __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#2
|
||||
|
||||
Re: Bloodshed Dev C++ Project Options
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#3
|
||||
|
||||
Re: Bloodshed Dev C++ Project OptionsHi J,
Welcome back to C++. Here is some info: What is a Project ? A Project is a center for managing your different source files and options inside an IDE. It helps you navigate through your code, and easily set different parameters, like the type of program you are doing (GUI, console, DLL ...). When to use Projects ? - If you have more than one source file, you must create a project in order to link all your source files together, after they were compiled. - If you need to create a DLL or static library, or want to use Resources files(icons, bitmaps, dialogs etc) in your program Console application Creates a console application. Console programs are developed with Console Functions, which provide character-mode support in console windows. The run-time libraries also provide output and input from console windows with standard I/O functions, such as printf() and scanf(). A console application has no graphical user interface. It compiles into an .exe file and can be run as a stand-alone application from the command line. Windows application Creates a Win32 program. A Win32 program is an executable application (EXE) written in C or C++, using calls to the Win32 API to create a graphical user interface. DLL Creates a Win32 dynamic-link library (DLL). A Win32 DLL is a binary file, written in C or C++, that acts as a shared library of functions that can be used simultaneously by multiple applications. Static library Creates a static library. A static library is a file containing objects and their functions and data that links into your program when the executable file is built. Empty project Specifies that the project files are blank. If you have a set of source code files (such as .cpp files, header files, icons, toolbars, dialog boxes, and so on) and want to create a project in the IDE, you must first create a blank project, then add the files to the project. Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#4
|
||||
|
||||
Re: Bloodshed Dev C++ Project OptionsI appreciate the replies, really I do but I was looking for a more dumbed-down explanation, like you would explain this stuff to a 5,... I mean a 10 year old.
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#5
|
||||
|
||||
Projects In Dev C++Quote:
I'll try to explain this as far as i can: I assume the 10 year old has basic knowledge of C/C++ files and header files. What are Projects in Dev C++ or an IDE? A project (extension is ".dev") is how Dev-C++ (and other IDEs) keep track of multiple source files. If we have only one source file, there is no need to create a project. A project also has many other uses which will be explained later. Consider that we have two source files for a program. One is a header file which contains functions we are going to use and the other is a C/C++ source file. If we want to compile and run the program we should create a project and add that files to that project so that we can link those two files for compiling. When to use Projects ? - If we have more than one source file, we must create a project in order to link all our source files together, after they oure compiled. - If we need to create a DLL or static library(explained later), or want to use Resources files(icons, bitmaps, dialogs etc) in our program. What are the different types of projects available? There are five basic projects in most of the IDEs. They are:
Dev C++ allowes us to create project in choosing any of the languages C or C++. Let us discuss those one by one. First, lets discuss about console applications. Console Applications: Console applications are programs that will run in a Console (MS-DOS) window. This is much easier to program than any other application. A console application can have many source files and header files. Console programs are developed with Console Functions such as printf() and scanf(). All the console applications only have character-mode support. The project source compiles into an .exe file and can be run as a stand-alone application from the command line. Console applications are the basic applications all the new users would start with. Here is a sample C console application: CPP / C++ / C Code:
Note: we should not use the system("PAUSE") function anyway. Why? Visit this link to find out: Pausing a program Windows Application: Windows applications are the Graphical User Interface(GUI) programs we use, like a Windows Calculator. When we create a Windows Application in Dev C++, it automatically creates a main file which we can save it in a location. When we run that, a simple window opens up, looks somewhat like an empty window. we can add similar source files and header files. Console functions such as printf and scanf cannot be used in this case. So, programming a windows application is a little different and difficult than programming a console application. Google it for more information. Static Library: Until now, we discussed simple console and windows applications. But in real programming, the code becomes larger and larger, bringing up overall compilation and linking time larger. It is this point where we start thinking about combining out source code into small units of related files, called library, which can be used by a different programmer also. We know that Object files are intermediate representation of code generated by a compiler. Hence, a library is a file containing several object files, that can be used as a single entity in a linking phase of a program. Normally the library is indexed, so it is easy to find symbols (functions, variables and so on) in them. Also, when using a library, we have fewer files to look for and open, which even further speeds up linking. There are two kinds of libraries - static libraries and shared (or dynamic) libraries. Static libraries are simply a collection of ordinary object files; conventionally, static libraries end with the ".a" suffix. Static libraries permit users to link to programs without having to recompile its code, saving recompilation time. Static libraries are often useful for developers if they wish to permit programmers to link to their library, but don't want to give the library source code (which is an advantage to the library vendor, but obviously not an advantage to the programmer trying to use the library). Static libraries aren't used as often as they once were, because of the advantages of dynamic libraries (DLL). Still, they're sometimes created, they existed first historically, and they're simpler to explain. So, in a Dev C++ static library project, we can create or add many C/C++ files and header files. Then if we compile successfully, a "project.a" is created which can be used in another program. Here is an example: Consider that we have created a new static library project named print. Create a new file in the project say "print.h" and add this code to the project: CPP / C++ / C Code:
Now, a static library named "print.a" will be created. Now, in a console application project, just add that print.a to the project. Then we can add the "print.h" we have created. Here is a sample: CPP / C++ / C Code:
I hope you understand this bit. Now, on to the most important one DLL DLL: Dynamic Link Library The Windows operating system relies heavily on data contained in special libraries called “dynamic-link libraries” or DLLs for short. Note that DLLs do not run under MS-DOS. So, we can consider that static libraries can be used in console applications and DLLs can be used in Windows Applications. DLLs are linked into the program in two stages unlike the static libraries. First, during compile time, the linker verifies that all the symbols (again, functions, variables and the like) required by the program, are either linked into the program. However, the object files from the dynamic library are not inserted into the executable file. Instead, when the program is started, a program in the system (called a dynamic loader) checks out which shared libraries oure linked with the program, loads them to memory, and attaches them to the copy of the program in memory. This makes launching the program slightly slower, but this is a very insignificant drawback, that is out-weighted by a great advantage - if a second program linked with the same DLL is executed, it can use the same copy of the shared library, thus saving a lot of memory. This means we can use far less memory to run our programs, and the executable files are much smaller, thus saving a lot of disk space as well. Explaining how to create a DLL in Dev C++ is a little bit complex. Google it for more information on that. Finally the Empty Project. Empty Project: Empty vessels make much noise. We can create whatever we want from the empty project i think. The project files are blank. We can add our own files which we have created sometime earlier. So, if we have a set of source code files (such as .cpp files, header files, icons, toolbars, dialog boxes, and so on) and want to create a project in the IDE, we must first create a blank project, then add the files to the project and compile it. Its Over! I hope this is somewhat near to what we wanted J. Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#6
|
||||
|
||||
Re: Projects In Dev C++Now, let's correct some misinformation...
Console Applications: Console applications are programs that will run in a Console (MS-DOS) window. This is much easier to program than any other application. A console application can have many source files and header files. Console programs are developed with Console Functions such as printf() and scanf() [not to mention cin, cout]. All the console applications only have character-mode support. The project source compiles into an .exe file and can be run as a stand-alone application from the command line. Console applications are the basic applications all the new users would start with. [I'll buy this ] Static Library: Static libraries are simply a collection of ordinary object files; conventionally, static libraries end with the ".a" [or more predominately ".lib"] suffix. Static libraries permit users to link to programs without having to recompile its code, saving recompilation time. Static libraries are often useful for developers if they wish to permit programmers to link to their library, but don't want to give the library source code (which is an advantage to the library vendor, but obviously not an advantage to the programmer trying to use the library). [Well, not really. They are created because of the "why reinvent the wheel" idea. Since programmer 1 wrote a few functions of universal appeal, he packages those functions in a library so ALL programmers can use the same functions. The source is not needed by the other programmers so it saves the "bookkeeping" of remembering whose source code is the most current. Also makes the programs built consisant and with fewer bugs. Updating libraries allows projects to be upgraded more efficiently. ] Static libraries aren't used as often as they once were, because of the advantages of dynamic libraries (DLL). Still, they're sometimes created, they existed first historically, and they're simpler to explain. [Not in my world. The are use just as much as before. DLLs are simply a newer addition to the programming scene, necessary because of the bloat from Windows programming.] DLL: Dynamic Link Library The Windows operating system relies heavily on data contained in special libraries called “dynamic-link libraries” or DLLs for short. Note that DLLs do not run under MS-DOS. [This is true] So, we can consider that static libraries can be used in console applications and DLLs can be used in Windows Applications. [This is untrue. DLLs can be used in console apps. After all a "console" is part of Windows. DLLs aren't just for GUI functions.] This [dynamic loader] makes launching the program slightly slower, but this is a very insignificant drawback, that is out-weighted by a great advantage - if a second program linked with the same DLL is executed, it can use the same copy of the shared library, thus saving a lot of memory. This means we can use far less memory to run our programs, and the executable files are much smaller, thus saving a lot of disk space as well. [Except that, in the case of static libraries, good compilers will only load the functions necessary and not load functions that are not needed. The DLL as a whole is loaded into memory, even though only 1 function is needed. Not much of a savings on the whole. The only real savings is that the program (.EXE) itself is smaller because a lot of the functionality is in the DLL, not in the program.] Quote:
Console apps -- good Windows apps -- bad Libraries -- maybe later DLLs -- fergit em' __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#7
|
||||
|
||||
Re: Projects In Dev C++Paramesh, your Static Library explanation and code examples were EXACTLY what I was hoping for. I get it now...
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
First week of IA training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with Simple 1D Array coding project | rho | CPP / C++ Forum | 2 | 27-Jun-2005 19:05 |
| c programming : project idea ??? | batrsau | CPP / C++ Forum | 2 | 09-Jun-2005 04:55 |
| project in c | pointer | C Programming Language | 1 | 26-Apr-2005 15:46 |
| Community Project Proposal | dsmith | Miscellaneous Programming Forum | 71 | 19-Feb-2005 12:26 |
| Help with project. | anignna | C Programming Language | 12 | 27-Apr-2004 07:51 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The