Can we execute more than one programs in code:blocks

Viewed 561

SO I am writing a program and writing my code in the main.c file of the project I created.But if I want to sample test some code or function I cannot do so.

I tried adding a new file in the project but it automatically executes the main.c file.

Isn't there a way where I can run my codes in a different place without disturbing the code in the main.c file

2 Answers

Options for doing this:

Run two instances of Code::Blocks:

  • From IDE, uncheck Settings -> Environment -> Allow only one running instance
  • ...Or from command line: codeblocks --multiple-instance &

Create tool to allow target to run detached

  • From IDE: Use Tools -> Configure tools -> User-defined tools to create a new tool, for example call it exe_tester as shown in example image below. (this name is arbitrary) Note: The exe must have already been built. Use the ... navigate button to navigate to the actual location of the exe, and select the .exe (eg. it may be in C:\codeblocks\test\test.exe) This will be the actual executable that will run detached.

  • Note that working directory is optional, I do not normally use it. But experiment, it may be useful for what you want to do.

  • To run the tool, Go back to Tools menu, and you should see exe_tester. Click it and the .exe it is pointing to will launch detached from the IDE:

enter image description here

More on Code::Blocks Tools

Create two different projects, then add all files except the different mains to both projects. Example:

Project 1:

C:\something\abc.h
C:\something\abc.c
C:\something\xyz.h
C:\something\xyz.c
C:\something\release\main.c
C:\something\release\project1 // the actual IDE project file

Project 2:

C:\something\abc.h
C:\something\abc.c
C:\something\xyz.h
C:\something\xyz.c
C:\something\test\main.c
C:\something\test\project2 // the actual IDE project file
Related