IDE: Why should I use Projects?

I've made quite a few programs so far (a timer, checkbook, flash cards, Ballot, etc.). I use Code::Blocks but am not very experienced at using/making projects. I would like to start, but I have no clue how projects are put together (what links what and why), what effects this will have on the outcome of my program, or if it's even worth using. I've searched but all I could find was a CB "manual" that basically lists the features (instead of telling you what they are and how to use them which makes it a brochure, not a manual at all) and does not explain how they work. That is the closest I could come to anything resourceful, so I decided to ask you: What are projects, how do they work/what is their purpose, and why should I use them. If you know a source that would better explain this to me, (for CB) please post the link. Thank you for your time.
You don't have to. You can do the whole thing with a handful of scripts and some makefiles.
... huh? what does that mean/do? Like I said before, I am used to writing 1 script.
It means that you don't have to use "projects". I don't use an IDE. I write my C++ code (not scripts - C++ is not a scripting language) in text files using a text editor.

I then use a number of scripts that I wrote myself to compile them and link them.

If you read up on what a compiler does and what a linker does, you'll have a much better understanding of what "projects" are all about.
Last edited on
... why do you need linkers, what is a linker, why do we need more than one script, and how can you run a compiler without a GUI (or how to through com. prompt)? I'm not sure, but if you havn't noticed, i know how to write C++ but absolutly nothing about linking, or whatever it is. Please refer me to an informative source or explain it yourself, because i can't google somthing I don't even know about. Thank you for your time.
http://en.wikipedia.org/wiki/Linker_(computing)

First hit on google for "what is a linker".

I suggest you pick up a basic C++ book. Whatever you're using to learn at the minute isn't teaching you the basics.
Last edited on
The internet isn't teaching me the basics...
here is the "basics":

http://www.cplusplus.com/reference/
http://www.cprogramming.com/tutorial/lesson6.html
http://www.cprogramming.com/tutorial/lesson7.html
http://www.cprogramming.com/tutorial/lesson8.html
http://www.cprogramming.com/tutorial/lesson18.html
http://www.google.com/search?q=C%2B%2B+GUI&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

these are only a small number of my sources, aside from my posts here.

now, back to the topic at hand:
I still dont understand...

Linking: wtf... why? what's the point? how? When should/what should it be used for?

I don't want to know all about linking. I WANT TO KNOW WHY I SHOULD LINK, OVER COMPILATION OF A SINGLE SCRIPT. Right now, i am writing single .cpp files and compiling them. I want to know how to use/why I should use a linker(s) or projects to write my programs.

EX: is there an advantage to using files/linkers? Better efficiency? Am I able to do more with them?

I have googled away to my hearts content but I do not have the time to spare which is the main reason I posted this. I cannot afford to google for 7 hours because I need this question answered. I have to work/go to school/study for my finals. I'm sorry if I'm coming off a bit demanding, but I can't seem to understand/find these answers (in detailed description for somone who has no concept of the topic) and I would like them. I really appreciate your time and effort.

Also, I would like to note that anyone who posts somthing that does not pertain to my question will recieve no response from me.

Thank you Moschops, but I need somthing that will explain this in the way a 'beginner' can understand it. The "why" and the "how" are questions that, when answered, do me a world of good. I appreciate your help.
I WANT TO KNOW WHY I SHOULD LINK, OVER COMPILATION OF A SINGLE SCRIPT


YOU ALREADY DO LINK. COMPILING SOME C++ CODE (WHICH IS NOT CALLED A SCRIPT - I ALREADY SAID THAT BUT I'LL SAY IT AGAIN - C++ CODE IS NOT SCRIPT BECAUSE C++ IS NOT A SCRIPTING LANGUAGE, IT IS NOT INTERPRETED, IT IS COMPILED) PRODUCES AN OBJECT FILE. THAT IS ALL IT DOES. THEN THE LINKER TAKES THE OBJECT FILES, INCLUDING ONES YOU DIDN'T WRITE BUT ARE NEEDED TO MAKE YOUR OBJECT FILES ACTUALLY DO ANYTHING, AND TURNS THEM INTO A LIBRARY OR AN EXECUTABLE. IF YOU DID NOT USE A LINKER YOU CODE WOULD NOT DO ANYTHING. IT WOULD NOT RUN. IT WOULD NOT BE TURNED INTO A PROGRAM. ONE C++ FILE IS TURNED INTO ONE OBJECT FILE BY THE COMPILER. THE LINKER TURNS OBJECT FILES INTO PROGRAMS. YOU'RE ALREADY USING THE LINKER.

is there an advantage to using files/linkers?

Without using files and linkers you would not be able to write and C++ code and you would not be able to turn that code into programs. So yes, there's a pretty big advantage.


Those links you linked to are NOT the basics. They are some brief notes on how to write C++ code (NOT SCRIPT). They are not the basics of programming in C++.

I do not have the time to spare which is the main reason I posted this.

Well then you don't have the time to learn C++. Sounds harsh, and it is harsh, but if you can't put in the time, you're better off doing something else.


Last edited on
IWishIKnew wrote:
Why should I use Projects?
To make your project (your work) organize. Also some features of codeblocks works only if you use projects.

IWishIKnew wrote:
... why do you need linkers, what is a linker,
First think how a program is built? Well according to the experts/books (not me), compiler turn your code to object files or binary files. The linker then builds the final executable binary that you can run on your system (like Microsoft Windows).

IWishIKnew wrote:
and how can you run a compiler without a GUI (or how to through com. prompt)?
Yes, it's through cmd on windows. So you see, when you installed code::blocks you also installed Mingw Compiler (a GCC port on windows). What actually happens when you use codeblocks is that it uses Mingw on the background when you click the compiler button to make your life easier.

If you want to learn how to compile manually without and IDE. Search for gcc tutorial. If that doesn't work for you try this http://www.youtube.com/watch?v=w2XLvEcSrgo There are also a lot of videos on youtube if that works better for you.

Additional Info:
Code::Blocks installer installs Mingw under C:\Program Files\CodeBlocks\MinGW\
The C++ compiler is: C:\Program Files\CodeBlocks\MinGW\bin\g++.exe
The linker is: C:\Program Files\CodeBlocks\MinGW\bin\ld.exe

So you see this two tools (compiler and linker) are command line tools.

Also try to enable html logging in code::blocks to see how the IDE uses the compiler and linker. Just goto Settings -> Compilers and Debuggers -> Others Settings [tab] then check "Save build log to html file"

I hope that helps. Good luck!!
If you're unwilling/can't learn on your own, you're not going to make it far in the comp. sci. world. And you would be well off learning to be respectful towards people in this forum. They've spent a lot of time and effort to be where they are, and have better things to do then to help some disrespectful kid.
Last edited on
Doing projects in an IDE is very useful as it provides a lot of flexibility and ease. Also it provides easy linking options and execution. Below is a link where you can find a lot of useful IDE's

http://programsplusplus.blogspot.com/p/test-page-1.html
Last edited on
Some basics are needed here. Not C++ basics but computer science basics.

Code::Blocks is an IDE. That means it's an Integrated Development Environment. IDE's have 3 parts:
1. A text editor. This is a GUI for looking at your actual code. Masochists like Moschops may like notepad, but I need to be able to mouse-over my variables to see the type and to right-click to find where they are declared or defined.

2. A compiler. This will take your source file, add the necessary headers, read through (parse) it and create an object that contains all of the necessary instructions for your machine to execute the code. This is really only half of the conversion process.

3. A linker. Often you will split up your code into multiple source (.cpp) files to make things easier to read, re-compile, share, divide work, etc. If you do this you'll get multiple objects from the compiler. If you've made a .exe, only ONE of these objects will contain int main(). That main object will then call functions or variables from the other objects. In order to see where these other objects are and what is available inside them the objects need to be "linked".

Text Editor -> Source files (.cpp .cc)-> Compiler -> Objects (.obj) -> Linker -> Binaries (.dll .exe .lib)


What are projects?
The scripts that Moschops was referring to simply fed the compiler and linker with instructions via a command line argument style interface. The IDE, or GUI version of doing this is with Projects. If you look at the project's properties (I use VS so mine will be a little different looking), you have a few options available. The main ones are whether to build a DLL or EXE. Are you going to use Unicode or Multi-Byte character sets? Are you going to use Standard windows libraries or another set? What files do you even plan on compiling? <<-- I just used "compiling" to mean compile and link.. These kind of options are important and are specified at the project level.

Why use multiple projects?
Well if each project creates another .exe or .dll, then perhaps you want to make an add-on for your main project or perhaps you want to make inter-changable modules. Perhaps you want to outsource specific functionality to another company so you'll ask them to make a DLL or two. This way you don't have to give them your source code. There are lots of reasons, the most basic is that you just want to organize your code in a certain way.
Last edited on
@blackcoder41 and Stewbond

Thank you! You have been very helpful to me. I appreciate your time. Your explanations have helped me grasp a basic understanding.

@ResidentBiscuit

If you're unwilling/can't learn on your own, you're not going to make it far in the comp. sci. world


I'm very willing to learn on my own, in fact every thing I've l;earned about C++ was through the internet and these forums. But one can not find an answer to somthing he doesn't know about. For example, I had no clue projects were the GUI way of linking/compiling multiple source codes or that I could only have 1 int main() in a project until now. This new insight also alows me a place to start my searches. I know you probably think I'm being lazy or arrogant (judging from your statements) but you have obviously forgotten what it was like when you were a complete beginner and didn't know what these things were.
I had no clue ... I could only have 1 int main() in a project until now.


Whatever you're using to learn from is doing you no favours at all. Find something better.

you have obviously forgotten what it was like when you were a complete beginner and didn't know what these things were.

This kind of passive-aggressiveness to the lounge, please :)
Last edited on
Topic archived. No new replies allowed.