Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start a Codeblocks project from external code and Makefile?

I have C++ code that depends on boost and other libraries, and therefore this code has a makefile that invokes boost.

I am now trying to start developing this code in codeblocks in linux, so in order to do that I have two basic questions:

(1) How can I import the code into codeblocks as a codeblocks new project? This seems to be a good rec: http://www.programmingforums.org/thread44976.html

(2) How do I invoke the makefile with codeblocks instead of codeblocks trying to compile the code (which it would fail since codeblocks does not know that it needs to invoke boost).

like image 566
Dnaiel Avatar asked Nov 22 '12 17:11

Dnaiel


People also ask

How do I run a makefile in CodeBlocks?

If you decide that you want to use your own makefile, you need to enter the screen from project->Properties and you will see a tick box for 'this is a custom makefile'. Tick this box, make sure the name just above it is the one you want for your makefile. You should also look at project->build options.

How do I change the working directory in CodeBlocks?

It looks like you can set the working directory that is used to run your program in Project > Properties > Build Target > Execution Working Directory. If you set that to the directory where your source files are located, your file should be created in that directory as well.

How do I create an application in Codeblocks?

You need to start with a CodeBlocks project. It’s possible to use either an existing project or create a new project to hold the files. In either case, once you have a project to use, you simply add the files you want to it, set the build options for those files, and then create your application.

How to create a new project using Codeblocks IDE?

How to create a new project using the CodeBlocks IDE? Step-1: Open CodeBlocks IDE and click on File > New > Project. Step-2: Select the application type as a console application and click on Go. Step- 3: Then Click on “NEXT”. Step-4: In the next window, select C as your language and click on next.

How can I import the code into Codeblocks as a project?

How can I import the code into codeblocks as a codeblocks new project? add files recursively. I recommend that you create Code::Blocks project new project at the top-level of you source (and not e.g. in a dedicated ~/codeblocks directory), or else it will show long file paths.

How do I create a release build target in code blocks?

The Makefile:options are used only if the project should use a makefile instead of Code::Blocks' internal build system (see Code::Blocks and Makefilesfor further details). Adding a new build target Switch to the Build targetstab. Click Addto create a new build target and name it Release Small.


2 Answers

How can I import the code into codeblocks as a codeblocks new project?

File > New > Project > Empty project

Create the project, then:

  • right click on the project name on the "Projects" pane;
  • add files recursively.

I recommend that you create Code::Blocks project new project at the top-level of you source (and not e.g. in a dedicated ~/codeblocks directory), or else it will show long file paths.

How do I invoke the makefile with codeblocks instead of codeblocks trying to compile the code (which it would fail since codeblocks does not know that it needs to invoke boost).

Asked at: Is it possible to use an existing Makefile to build a project in Code::Blocks?. For quick reference, the solution is to go to Project > Properties and toggle on the option This is a custom Makefile. Further options can be specified from the same window.


Most projects can be compiled without makefile, so just include files, and if you need extra library include that in project. If your project uses header only boost librarys and you have packet installed libboost-dev (this is on my debian) then it is included automaticaly. Else just use proper library name in settings (I cant remeber if you need to append l to name).

like image 27
Luka Rahne Avatar answered Oct 01 '22 23:10

Luka Rahne