Code::Blocks Forums

User forums => Help => Topic started by: encio on October 22, 2012, 11:59:24 am

Title: how to compile and run c++ project downloaded from the web
Post by: encio on October 22, 2012, 11:59:24 am
I know this is a really dumb question, but this is the first time I'll be using and IDE.

How do you build and run c++ projects downloaded from the web?
Title: Re: how to compile and run c++ project downloaded from the web
Post by: encio on October 22, 2012, 12:02:45 pm
or how do you add includes and arguments if you want to manually build the program? like in geany?
Title: Re: how to compile and run c++ project downloaded from the web
Post by: Jenna on October 22, 2012, 12:15:33 pm
or how do you add includes and arguments if you want to manually build the program? like in geany?
I suggest reading the manual: http://www.codeblocks.org/user-manual (http://www.codeblocks.org/user-manual)
and the wiki: http://wiki.codeblocks.org/ (http://wiki.codeblocks.org/)
Title: Re: how to compile and run c++ project downloaded from the web
Post by: Radek on October 22, 2012, 04:25:48 pm
You'd better not use an IDE and compile from the commandline using ./configure and ./make. The scripts in your project are tailored especially for it, you cannot do it better most likely. Use compiling from an IDE only if you run into problems which you cannot fix using parameters of configure or make or if your project does not contain configure and make at all.

In the later case, you need to build a project by adding all source files to the project (keeping the directory structure of the project) and setting build options. You need to set

(1) Include directories. This can be done in Project -> Build Options -> Search directories. Add all directories which contains headers or other files which are included by the source code.
(2) Libraries. This can be done in Project -> Build options -> Linker Options. Add needed libraries.

Save the project and build. You will solve subsequent problems as they come. A more difficult problem arises if the project is "multi target", for example, it builds some libraries which it then uses in linking the final executable or even executables. In this case, you will need to define a multi target project. It's possible but more complex than a single target project. You will to define targets in Project -> Properties, specify types of the targets and define source files belonging to each target. Then you will build one target after another, in the correct order.

Really, using the predefined commandline tools is much simpler :)
Title: Re: how to compile and run c++ project downloaded from the web
Post by: encio on October 23, 2012, 08:15:46 am
Got it working finally!!!!

Thank you so much for the help.

I really should've read the documentation carefully rather than skimming through it. I then missed some important points.

Again thank you so much Radek and jens