Menu

Help using a Project and using a CPP file

Help
2007-06-12
2013-04-25
  • CaptainBeck

    CaptainBeck - 2007-06-12

    Ok i've started an empty project called Robot and its loaded a blank standed project
    ---------------------
    // Robot.h

    #pragma once

    using namespace System;

    namespace Robot {

        public ref class Class1
        {
            // TODO: Add your methods for this class here.
        };
    }
    ---------------------

    then started a new file called code1.cpp

    ---------------------

    #include "NXT++.h"

    int main()
    {
        if(NXT::OpenBT()) //initialize the NXT and continue if it succeeds
        {
            NXT::Motor::SetForward(OUT_A, 50); //turn both motors on 50% power
            NXT::Motor::SetForward(OUT_C, 50);
            Wait(2000); //wait 2 seconds
            NXT::Motor::Stop(OUT_A, false); //stop both motors with no braking
            NXT::Motor::Stop(OUT_C, false);
            NXT::CloseBT(); //close the NXT
        }
        return 0;
    }

    ---------------------

    I've loaded the libariries and stuff but i'm not sure how to add the cpp file to the project since i'm new to uusing project stuff.

    Cheers Chris

     
    • Cory Walker

      Cory Walker - 2007-06-12

      For VC++ Express, all you do is right-click on the Source Files folder in the Solution Explorer. You then go to Add->Existing Item... and browse to the file you want to add.

      -Cory Walker

       
    • Nobody/Anonymous

      // Robot.h
      #include "NXT++.h"
      #include <iNXT.h>

      #pragma once

      using namespace System;

      namespace Robot {

      int main()
      {
          if(NXT::Open()) //initialize the NXT and continue if it succeeds
          {
              NXT::Motor::SetForward(OUT_A, 50); //turn both motors on 50% power
              NXT::Motor::SetForward(OUT_C, 50);
              Wait(2000); //wait 2 seconds
              NXT::Motor::Stop(OUT_A, false); //stop both motors with no braking
              NXT::Motor::Stop(OUT_C, false);
              NXT::Close(); //close the NXT
          }
          return 0;
      }

      is the code i tried to make.

      ------ Build started: Project: Robot, Configuration: Release Win32 ------
      Compiling...
      Robot.cpp
      c:\program files\code\nxt\comm.h(19) : fatal error C1083: Cannot open include file: 'fantom/iNXT.h': No such file or directory
      Build log was saved at "file://c:\Program Files\Code\Robot\Robot\Release\BuildLog.htm"
      Robot - 1 error(s), 0 warning(s)
      ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

      is the error i get how can i get rid of this

      cheers captain beck

       
    • Cory Walker

      Cory Walker - 2007-06-18

      Did you add the directories I told you to on the MSDN forums?

       
    • Nobody/Anonymous

      yeah i followed it all like u had sed. yet still get the errors

       
    • Cory Walker

      Cory Walker - 2007-06-19

      All I can suggest now is to browse to the file that has iNXT.h and put that in the 'Additional Include Directories' field.

       
    • Nobody/Anonymous

      You only have to include the NXT++.h file the rest he find himself. And put all the headerfiles in the same directory as the NXT++.h file. I had also problems and follow your discusion on msdn and by me it's working now. Not all the header files are in the same directory, that's the problem I guess.

      Rockderakker

       

Log in to post a comment.