This project has moved and is read-only. For the latest updates, please go here.

Cannot find header file

Feb 4 at 3:48 PM
Edited Feb 4 at 3:56 PM
I am trying to compile a stepper motor program that was provided by the same company.

I've copied the header file into almost every place conceivable for the compiler to locate it (where the other *.h files are located too) and I'm still receiving the same error....unable to open the include file 'phidget.h'.

the code from the co is below and either the compiler is not able to manage the provided code, which is standard C or the header file is not being found.

I tried to copy the header file but it's too large..(maybe that's the issue too?)... is there a limit with the compiler on the size of the header file....if someone needs to look at it the dropbox link is

It's been 20 years since I've programmed so I'm way behind the curve here but perhaps I'm missing something simple.

Any help is greatly appreciated. Brian
// This simple example sets up a Stepper object, hooks the event handlers and opens it for device connections.  
// Once an Advanced Servo is attached it will move the motor to various positions.
// Please note that this example was designed to work with only one Phidget Stepper connected. 
// Copyright 2008 Phidgets Inc.  All rights reserved.
// This work is licensed under the Creative Commons Attribution 2.5 Canada License. 
// view a copy of this license, visit

#include <stdio.h>
#include <phidget21.h>
//#include <unistd.h>

int CCONV AttachHandler(CPhidgetHandle stepper, void *userptr)
    int serialNo;
    const char *name;

    CPhidget_getDeviceName (stepper, &name);
    CPhidget_getSerialNumber(stepper, &serialNo);
    printf("%s %10d attached!\n", name, serialNo);

    return 0;

int CCONV DetachHandler(CPhidgetHandle stepper, void *userptr)
    int serialNo;
    const char *name;

    CPhidget_getDeviceName (stepper, &name);
    CPhidget_getSerialNumber(stepper, &serialNo);
    printf("%s %10d detached!\n", name, serialNo);

    return 0;

int CCONV ErrorHandler(CPhidgetHandle stepper, void *userptr, int ErrorCode, const char *Description)
    printf("Error handled. %d - %s\n", ErrorCode, Description);
    return 0;

int CCONV PositionChangeHandler(CPhidgetStepperHandle stepper, void *usrptr, int Index, __int64 Value)
    printf("Motor: %d > Current Position: %lld\n", Index, Value);
    return 0;

//Display the properties of the attached phidget to the screen.  We will be displaying the name, serial number and version of the attached device.
int display_properties(CPhidgetStepperHandle phid)
    int serialNo, version, numMotors;
    const char* ptr;

    CPhidget_getDeviceType((CPhidgetHandle)phid, &ptr);
    CPhidget_getSerialNumber((CPhidgetHandle)phid, &serialNo);
    CPhidget_getDeviceVersion((CPhidgetHandle)phid, &version);

    CPhidgetStepper_getMotorCount (phid, &numMotors);

    printf("%s\n", ptr);
    printf("Serial Number: %10d\nVersion: %8d\n# Motors: %d\n", serialNo, version, numMotors);

    return 0;

int stepper_simple()
    int result;
    __int64 curr_pos;
    const char *err;
    double minAccel, maxVel;
    int stopped;

    //Declare an stepper handle
    CPhidgetStepperHandle stepper = 0;

    //create the stepper object

    //Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error.
    CPhidget_set_OnAttach_Handler((CPhidgetHandle)stepper, AttachHandler, NULL);
    CPhidget_set_OnDetach_Handler((CPhidgetHandle)stepper, DetachHandler, NULL);
    CPhidget_set_OnError_Handler((CPhidgetHandle)stepper, ErrorHandler, NULL);

    //Registers a callback that will run when the motor position is changed.
    //Requires the handle for the Phidget, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
    CPhidgetStepper_set_OnPositionChange_Handler(stepper, PositionChangeHandler, NULL);

    //open the device for connections
    CPhidget_open((CPhidgetHandle)stepper, -1);

    //get the program to wait for an stepper device to be attached
    printf("Waiting for Phidget to be attached....");
    if((result = CPhidget_waitForAttachment((CPhidgetHandle)stepper, 10000)))
        CPhidget_getErrorDescription(result, &err);
        printf("Problem waiting for attachment: %s\n", err);
        return 0;

    //Display the properties of the attached device

    //read event data

    //This example assumes stepper motor is attached to index 0

    //Set up some initial acceleration and velocity values
    CPhidgetStepper_getAccelerationMin(stepper, 0, &minAccel);
    CPhidgetStepper_setAcceleration(stepper, 0, minAccel*2);
    CPhidgetStepper_getVelocityMax(stepper, 0, &maxVel);
    CPhidgetStepper_setVelocityLimit(stepper, 0, maxVel/2);

    //display current motor position if available
    if(CPhidgetStepper_getCurrentPosition(stepper, 0, &curr_pos) == EPHIDGET_OK)
        printf("Motor: 0 > Current Position: %lld\n", curr_pos);

    //keep displaying stepper event data until user input is read
    printf("Press any key to continue\n");

    //change the motor position
    //we'll set it to a few random positions to move it around

    //Step 1: Position 0 - also engage stepper
    printf("Set to position 0 and engage. Press any key to Continue\n");

    CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
    CPhidgetStepper_setEngaged(stepper, 0, 1);

    //Step 2: Position 200
    printf("Move to position 200. Press any key to Continue\n");

    CPhidgetStepper_setTargetPosition (stepper, 0, 200);

    //Step 3: Position -1200
    printf("Move to position -1200. Press any key to Continue\n");

    CPhidgetStepper_setTargetPosition (stepper, 0, -1200);

    //Step 4: Set to 0, wait for it to reach position, Disengage
    printf("Reset to 0 and disengage motor. Press any key to Continue\n");

    CPhidgetStepper_setTargetPosition(stepper, 0, 0);

    stopped = PFALSE;
        CPhidgetStepper_getStopped(stepper, 0, &stopped);

    CPhidgetStepper_setEngaged(stepper, 0, 0);

    printf("Press any key to end\n");

    //since user input has been read, this is a signal to terminate the program so we will close the phidget and delete the object we created

    //all done, exit
    return 0;

int main(int argc, char* argv[])
    return 0;