Unable to Include a header into my application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark mrcw
    New Member
    • Mar 2012
    • 1

    Unable to Include a header into my application

    hi
    I'm new to c++ and hence my problem. I've downloaded a file that I need to include in a new project. It's called phidget21.h and it's sat on my desktop. I've tried copying it to lots of various places. But I still can't get a new source file to compile. I think I haven't copied it to the right place yet. Where should I have copied it to?

    Code:
    #include <cstdlib>
    #include <iostream>
    #include <phidgets21.h>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    it errors on line 3
  • Mariostg
    Contributor
    • Sep 2010
    • 332

    #2
    Well, the header file should be in a directory that is in your PATH. I doubt your desktop folder is.
    Did you install the phidget library? Maybe you chould check the phidgets forum if you did not. http://www.phidgets.com/phorum/

    Comment

    • divideby0
      New Member
      • May 2012
      • 131

      #3
      the "easiest" thing to do would be to put phidgets21.h in the same directory as your project files and add the line

      Code:
      #include "phidgets21.h"
      alternatively, as Mariostg mentions, you can copy phidgets21.h to the includes path of your compiler and leave your source file as it is.

      Code:
      #include <phidgets21.h>
      Your main issue afterward would be linking to any libraries that the header references and your program actually attempts to use.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        You shouldn't be copying the header around at all, that way lies chaos, especially on a large project with multiple people working on it.

        The header should be left in its install directory and the compiler should be told what directories to look in most commonly with a -I <dir> switch on its command line, or if you are using an IDE finding the place in the project where you list include directories.

        Comment

        Working...