Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You must select a host application to run a commands only target? Code::Blocks

Tags:

c++

codeblocks

I'm running my code and it compiles fine with no errors, and used to send an output to the terminal, however it now gives me a prompt saying You must select a host application to "run" a commands only target.

I don't know what I've done, and I have never come across this before. Has anyone any ideas how to select the correct host application?

Any help is much appreciated, thanks a million.

Here's a test.cc file code that I'm trying to run.

#include <iostream>
#include <fstream>

#include <TrajectoryDSGenerator.hh>
#include <DSAdjust.hh>

int
main()
{
    // REAL THING!!
  // Initial conditions
  uu::Vector x0(2);
  x0.set(0, 5.0);
  x0.set(1, 10.0);
  // Real Parameter
  uu::Vector P(4);
  P.set(0, 2);
  P.set(1, 20);
  P.set(2, x0[0]);
  P.set(3, x0[1]);

  uu::TrajectoryDSGenerator ds(2, 4);
  ds.setParameters(P);

  // Where to compute the trajectory
  uu::TrajectoryDSGenerator::TimeStamps T;
  T = ds.generateTimeStamps(0.0, 10.0, 0.1);

  // Generate the sample trajectory at the given timestamps
  uu::VectorTrajectory Tr(2);
  uu::TimedVector xic(0.0, x0);
  Tr = ds.generate(xic, T);
  // Store the sample trajectory
  std::ofstream ofd;
  ofd.open("sample.traj");
  ofd << Tr;
  ofd.close();
  std::cout << "Trajectory Saved" << std::endl;





  // Now read the sample trajectory from the file
  std::ifstream ifd;
  uu::VectorTrajectory iTr(2);
  ifd.open("sample.traj");
  ifd >> iTr;
  ifd.close();
  std::cout << "Trajectory Loaded" << std::endl;

  // Vector with the initial guess of the parameters
  uu::Vector P0(4);
  P0.set(0, 10);
  P0.set(1, 5);
  P0.set(2, 20);
  P0.set(3, 2);
  //  P0 = P;
  //P0.set(0, 5);
  uu::TrajectoryDSGenerator ods(2, 4);
  uu::DSAdjust adj(&ods, P0);
  std::cout << "Added sample trajectory" << std::endl;
  adj.addSampleTrajectory(iTr);

  std::cout << "Optimising" <<std::endl;

  uu::Vector Pf(adj.optimise()); // Learnt parameters from the real trajectory (thing)
                                // This improves your initial guess of the parameters

  std::cout << "Real Parameters: " << P;
  std::cout << "Initial guess: " << P0;
  std::cout << "Learnt Parameters: " << Pf;

   // Generate a trajectory with the learnt parameters
  ds.setParameters(Pf);
  uu::VectorTrajectory TrPf(2);
  x0.set(0, Pf[2]);
  x0.set(1, Pf[3]);
  uu::TimedVector xic1(0.0, x0);
  TrPf = ds.generate(xic1, T);

  // Store the trajectory with the improved guess of the parameters
  ofd.open("result.traj");
  ofd << TrPf;
  ofd.close();
  std::cout << "Trajectory Saved" << std::endl;
  return 0;
}
like image 745
Josh Lewis Avatar asked Aug 30 '14 20:08

Josh Lewis


1 Answers

The same thing happened to me. To fix this:

  • Go to Project->Properties

Step 1

  • Go to the Build Targets tab

Step 2

  • Change the "Type" drop-down box to "Console Application"

Step 3

  • (Optional) Check the box "Pause when execution ends" if you don't want the terminal window to instantly close when it pops up

Step 4

  • Click the "...", select the output file that you want to run, and click "Save". If a box pops up asking about replacing the file, replace it.

Step 5

Problem solved!

like image 73
kirbyfan64sos Avatar answered Sep 27 '22 22:09

kirbyfan64sos