Library build error (HELP ME)

i'm trying to create a library to have motor control through a sabertooth 2 x 10A motor controller when i put the header file and the cpp file in the arduino/hardware/librairies/motorcontrol and open the arduino program it gives me this error:

MotorControl.cpp:142: error: expected unqualified-id before 'void'

my cpp file:
/*
MotorControl.h - Library for motor control through the sabertooth montor controller
Created by Eric Morin, March 03, 2009.
all Copyrights to Eric Morin (C)
*/

#include "WProgram.h"
#include "MotorControl.h"

MotorControl::MotorControl(int motor1, int motor2)
{
pinMode(motor1,OUTPUT);
_motor1 = motor1;
pinMode(motor2,OUTPUT);
_motor2 = motor2;
}

void MotorControl::FORWARD()
{
digitalWrite(_motor1, LOW);
digitalWrite(_motor1, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor1, LOW);
delay(3);
digitalWrite(_motor2, LOW);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor1, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor1, LOW);
delay(3);
digitalWrite(_motor2, LOW);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor1, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor1, LOW);
delay(3);
digitalWrite(_motor2, LOW);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor2, LOW);
delay(3);
}

void MotorControl::BACKWARD()
{
digitalWrite(_motor1, LOW);
digitalWrite(_motor1, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor1, LOW);
delay(3);
digitalWrite(_motor2, LOW);
digitalWrite(_motor2, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor1, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor1, LOW);
delay(3);
digitalWrite(_motor2, LOW);
digitalWrite(_motor2, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor1, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor1, LOW);
delay(3);
digitalWrite(_motor2, LOW);
digitalWrite(_motor2, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor2, LOW);
delay(3);
}

void MotorControl::SPINRIGHT()
{
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(2000);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
}

void MotorControl::SPINLEFT()
{
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1000);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
}

void MotorControl::void STOP()
{
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1500);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1500);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1500);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
digitalWrite(_motor1, HIGH);
digitalWrite(_motor2, HIGH);
delayMicroseconds(1500);
digitalWrite(_motor1, LOW);
digitalWrite(_motor2, LOW);
delay(3);
}

my header file:
/*
MotorControl.h - Library for motor control through the sabertooth montor controller
Created by Eric Morin, March 03, 2009.
all Copyrights to Eric Morin (C)
*/

#ifndef MotorControl_h
#define MotorControl_h

#include "WConstants.h"

class MotorControl
{
public:
MotorControl(int motor1, int motor2);
void FORWARD();
void BACKWARD();
void SPINRIGHT();
void SPINLEFT();
void STOP();
private:
int _motor1;
int _motor2;
};

#endif

Hey, look at the line 142 :slight_smile: You have there

void MotorControl::void STOP()

The second void is your problem.

THANKS what a simple mistake i was looking at it for too long
but im still getting errors now that i modiffied my program

the .pde file is:

#include <MotorControl.h>

int led = 13; // LED connected to digital pin 13

MotorControl motorcontrol(10,11)

void setup() // run once, when the sketch starts
{
int y;

pinMode(led, OUTPUT);
Serial.begin(115200); // set up Serial library at 115200 bps
LEDBurst();
LEDBurst();
LEDBurst();
LEDBurst();
LEDBurst();
}

int x,y;

void loop() // run over and over and over and over and over and over and over again
{
LEDBurst();
MotorControl.STOP();
delay(80);

LEDBurst();
MotorControl.FORWARD();
delay(80);

LEDBurst();
MotorControl.STOP();
delay(80);

LEDBurst();
MotorControl.SPINRIGHT();
delay(100);

LEDBurst();
MotorControl.STOP();
delay(80);

LEDBurst();
MotorControl.SPINLEFT();
delay(100);

LEDBurst();
MotorControl.STOP();
delay(80);

LEDBurst();
MotorControl.BACKWARD();
delay(80);

}

void LEDBurst()
{
for (x=0;x<5;x++)
{
digitalWrite(led, HIGH); // sets the LED on
delay(25); // waits for a second
digitalWrite(led, LOW); // sets the LED off
delay(25); // waits for a second
}
}

but the error when i try to compile this is:

In file included from C:\Users\User\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:4,

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected identifier before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected `)' before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected initializer before ')' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared

In file included from C:\Users\User\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:6,

In function 'void loop()':

i tried to modify all the function calls with
motorcontrol.forward();
instead of
MotorControl.forward(); the error when i try to compile this are

In file included from C:\Users\User\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:4,

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected identifier before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected `)' before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected initializer before ')' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared

In file included from C:\Users\User\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:6,

I think that your problem is on the line

MotorControl motorcontrol(10,11)

You are missing a semicolon there. Should be

MotorControl motorcontrol(10,11);

Also, you have to use

motorcontrol.forward();

not your original

MotorControl.forward();

ok so i fixed what you said so my code is now:

#include <MotorControl.h>

int led = 13; // LED connected to digital pin 13

MotorControl motorcontrol(10,11);

void setup() // run once, when the sketch starts
{
int y;

pinMode(led, OUTPUT);
Serial.begin(115200); // set up Serial library at 115200 bps
LEDBurst();
LEDBurst();
LEDBurst();
LEDBurst();
LEDBurst();
}

int x,y;

void loop() // run over and over and over and over and over and over and over again
{
LEDBurst();
motorcontrol.STOP();
delay(80);

LEDBurst();
motorcontrol.FORWARD();
delay(80);

LEDBurst();
motorcontrol.STOP();
delay(80);

LEDBurst();
motorcontrol.SPINRIGHT();
delay(100);

LEDBurst();
motorcontrol.STOP();
delay(80);

LEDBurst();
motorcontrol.SPINLEFT();
delay(100);

LEDBurst();
motorcontrol.STOP();
delay(80);

LEDBurst();
motorcontrol.BACKWARD();
delay(80);

}

void LEDBurst()
{
for (x=0;x<5;x++)
{
digitalWrite(led, HIGH); // sets the LED on
delay(25); // waits for a second
digitalWrite(led, LOW); // sets the LED off
delay(25); // waits for a second
}
}

my errors or now:

In file included from C:\Users\User\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:4,

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected identifier before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected `)' before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected initializer before ')' token

c:/users/user/desktop/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared

In file included from C:\Users\User\Desktop\arduino-0012\hardware\cores\arduino/WProgram.h:6,

I think you might want to look at the source files in the output directory. These are what the compiler really sees after the arduino environment does it's magic. Likely there is something screwed up with the way one of those files looks.

so this is the file reporting errors. i have not attempted to edit any of this:

/* Copyright (c) 2002, Marek Michalkiewicz
Copyright (c) 2004,2007 Joerg Wunsch

Portions of documentation Copyright (c) 1990, 1991, 1993, 1994
The Regents of the University of California.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the
    distribution.

  • Neither the name of the copyright holders nor the names of
    contributors may be used to endorse or promote products derived
    from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

$Id: stdlib.h,v 1.33.2.2 2008/03/16 13:44:44 dmix Exp $
*/

#ifndef STDLIB_H
#define STDLIB_H 1

#ifndef ASSEMBLER

#define __need_NULL
#define __need_size_t
#define __need_wchar_t
#include <stddef.h>

#ifndef __ptr_t
#define __ptr_t void *
#endif

#ifdef __cplusplus
extern "C" {
#endif

/** \file */

/** \defgroup avr_stdlib <stdlib.h>: General utilities
\code #include <stdlib.h> \endcode

This file declares some basic C macros and functions as
defined by the ISO standard, plus some AVR-specific extensions.
*/

/@{/
/** Result type for function div(). */
typedef struct {
int quot; /< The Quotient. */
int rem; /
< The Remainder. */
} div_t;

/** Result type for function ldiv(). */
typedef struct {
long quot; /< The Quotient. */
long rem; /
< The Remainder. */
} ldiv_t;

/** Comparision function type for qsort(), just for convenience. /
typedef int (
__compar_fn_t)(const void *, const void *);

#ifndef DOXYGEN

#ifndef ATTR_CONST
#define ATTR_CONST attribute((const))
#endif

#ifndef ATTR_MALLOC
#define ATTR_MALLOC attribute((malloc))
#endif

#ifndef ATTR_NORETURN
#define ATTR_NORETURN attribute((noreturn))
#endif

#ifndef ATTR_PURE
#define ATTR_PURE attribute((pure))
#endif

#endif

/** The abort() function causes abnormal program termination to occur.
This realization disables interrupts and jumps to _exit() function
with argument equal to 1. In the limited AVR environment, execution is
effectively halted by entering an infinite loop. */
extern void abort(void) ATTR_NORETURN;

/** The abs() function computes the absolute value of the integer \c i.
\note The abs() and labs() functions are builtins of gcc.
*/
extern int abs(int __i) ATTR_CONST;
#ifndef DOXYGEN
#define abs(__i) __builtin_abs(__i)
#endif

/** The labs() function computes the absolute value of the long integer
\c i.
\note The abs() and labs() functions are builtins of gcc.
*/
extern long labs(long __i) ATTR_CONST;
#ifndef DOXYGEN
#define labs(__i) __builtin_labs(__i)
#endif

/**
The bsearch() function searches an array of \c nmemb objects, the
initial member of which is pointed to by \c base, for a member
that matches the object pointed to by \c key. The size of each
member of the array is specified by \c size.

The contents of the array should be in ascending sorted order
according to the comparison function referenced by \c compar.
The \c compar routine is expected to have two arguments which
point to the key object and to an array member, in that order,
and should return an integer less than, equal to, or greater than
zero if the key object is found, respectively, to be less than,
to match, or be greater than the array member.

The bsearch() function returns a pointer to a matching member of
the array, or a null pointer if no match is found. If two
members compare as equal, which member is matched is unspecified.
*/
extern void *bsearch(const void *__key, const void __base, size_t __nmemb,
size_t __size, int (
__compar)(const void *, const void *));

/* __divmodhi4 and __divmodsi4 from libgcc.a /
/
*
The div() function computes the value \c num/denom and returns
the quotient and remainder in a structure named \c div_t that
contains two int members named \c quot and \c rem.
/
extern div_t div(int __num, int __denom) asm("__divmodhi4") ATTR_CONST;
/
*
The ldiv() function computes the value \c num/denom and returns
the quotient and remainder in a structure named \c ldiv_t that
contains two long integer members named \c quot and \c rem.
*/
extern ldiv_t ldiv(long __num, long __denom) asm("__divmodsi4") ATTR_CONST;

/**
The qsort() function is a modified partition-exchange sort, or
quicksort.

The qsort() function sorts an array of \c nmemb objects, the
initial member of which is pointed to by \c base. The size of
each object is specified by \c size. The contents of the array
base are sorted in ascending order according to a comparison
function pointed to by \c compar, which requires two arguments
pointing to the objects being compared.

The comparison function must return an integer less than, equal
to, or greater than zero if the first argument is considered to
be respectively less than, equal to, or greater than the second.
*/
extern void qsort(void *__base, size_t __nmemb, size_t __size,
__compar_fn_t __compar);

/**
The strtol() function converts the string in \c nptr to a long
value. The conversion is done according to the given base, which
must be between 2 and 36 inclusive, or be the special value 0.

The string may begin with an arbitrary amount of white space (as
determined by isspace()) followed by a single optional \c '+' or \c '-'
sign. If \c base is zero or 16, the string may then include a
\c "0x" prefix, and the number will be read in base 16; otherwise,
a zero base is taken as 10 (decimal) unless the next character is
\c '0', in which case it is taken as 8 (octal).

The remainder of the string is converted to a long value in the
obvious manner, stopping at the first character which is not a
valid digit in the given base. (In bases above 10, the letter \c 'A'
in either upper or lower case represents 10, \c 'B' represents 11,
and so forth, with \c 'Z' representing 35.)

If \c endptr is not NULL, strtol() stores the address of the first
invalid character in \c *endptr. If there were no digits at all,
however, strtol() stores the original value of \c nptr in \c
*endptr. (Thus, if \c *nptr is not \c '\0' but \c **endptr is \c '\0'
on return, the entire string was valid.)

The strtol() function returns the result of the conversion, unless
the value would underflow or overflow. If no conversion could be
performed, 0 is returned. If an overflow or underflow occurs, \c
errno is set to \ref avr_errno "ERANGE" and the function return value
is clamped to \c LONG_MIN or \c LONG_MAX, respectively.
*/
extern long strtol(const char *__nptr, char **__endptr, int __base);

/**
The strtoul() function converts the string in \c nptr to an
unsigned long value. The conversion is done according to the
given base, which must be between 2 and 36 inclusive, or be the
special value 0.

The string may begin with an arbitrary amount of white space (as
determined by isspace()) followed by a single optional \c '+' or \c '-'
sign. If \c base is zero or 16, the string may then include a
\c "0x" prefix, and the number will be read in base 16; otherwise,
a zero base is taken as 10 (decimal) unless the next character is
\c '0', in which case it is taken as 8 (octal).

The remainder of the string is converted to an unsigned long value
in the obvious manner, stopping at the first character which is
not a valid digit in the given base. (In bases above 10, the
letter \c 'A' in either upper or lower case represents 10, \c 'B'
represents 11, and so forth, with \c 'Z' representing 35.)

If \c endptr is not NULL, strtoul() stores the address of the first
invalid character in \c *endptr. If there were no digits at all,
however, strtoul() stores the original value of \c nptr in \c
*endptr. (Thus, if \c *nptr is not \c '\0' but \c **endptr is \c '\0'
on return, the entire string was valid.)

The strtoul() function return either the result

Hey there again. So I tried to compile it for you. It looks like your problem is the line

#include "WConstants.h"

in MotorControl.h.
I don't understand why you have it there in the first place, but when I remove it, the sketch compiles.
Also, use

#include "MotorControl.h"

in the sketch file, not #include <...> as you have there. Hope it helps

It's probably the usual problem with libraries developed for version 0011 and broken by a change in version 0012. A Google of the forums should give you a fix. Or try an upgrade to version 0013.

--Phil.

I just had the same problem.

after moving
#include "WProgram.h"

from my .h file to .cpp file everything started to work.
However the tutorial here told me to put it in the .h file.

Regards,
Patrick

Hey there again.