Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: bloodhound on August 16, 2012, 10:17:18 pm

Title: Making a driver in a project
Post by: bloodhound on August 16, 2012, 10:17:18 pm
I want to test out a function in a separate file with it's own main(). What's the best way to do this? I added a new file to the project and can build it but how do I run it? Whenever I click the green arrow the non-testing main.cpp is run.
Title: Re: Making a driver in a project
Post by: oBFusCATed on August 16, 2012, 10:18:48 pm
You have to use two separate projects or have to use two targets.
Title: Re: Making a driver in a project
Post by: bloodhound on August 16, 2012, 10:30:33 pm
You have to use two separate projects or have to use two targets.
How do you have two targets?
Title: Re: Making a driver in a project
Post by: oBFusCATed on August 16, 2012, 10:33:47 pm
Have you tried Project -> Properties -> Build targets?
Title: Re: Making a driver in a project
Post by: bloodhound on August 16, 2012, 10:52:42 pm
Have you tried Project -> Properties -> Build targets?
Thanks that works. Out of curiosity when I tried building both files it fails because "multiple definitions of main". Why is that a problem, as long as they are in different files?
Title: Re: Making a driver in a project
Post by: oBFusCATed on August 16, 2012, 11:51:07 pm
Search for symbols, linking and other similar stuff...
Title: Re: Making a driver in a project
Post by: Jenna on August 17, 2012, 12:33:23 am
Keep both files (if both contain a main() function) in different targets or differerent projects.