Undefined reference when compiling the PS2X_example from Bill porter

Good evening,

I am trying to run the PS2X_example sketch using my wireless PS2 lynxmotion controller ( PS2 kit) together with my arduino UNO.

I followed the instructions i found on arduino.cc with regards to downloading zip files and installing libraries, and i went onto github to get the PS2X_lib from Bill porter. Once unzipped, the Arduino-PS2X-Master folder is added automatically to my library folder. I checked that it was where it was supposed to be, and yes it is with all the other libraries i have already downloaded.

My setup is simple : Arduino UNO powered and nothing else. I just want to compile the PS2X_example sketch and see if i have any error messages before doing anything else.

To my surprise i have multiple error message, but they are all of the same flavour, i.e. “undefined reference” as you can read below.

_Arduino: 1.8.7 (Mac OS X), Board: "Arduino/Genuino Uno"_

_/var/folders/g5/4wf76ps914j5sc59dw_rv66c0000gn/T//ccrTM0vO.ltrans0.ltrans.o: In function `setup':_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:44: undefined reference to `PS2X::config_gamepad(unsigned char, unsigned char, unsigned char, unsigned char, bool, bool)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:73: undefined reference to `PS2X::readType()'_
_/var/folders/g5/4wf76ps914j5sc59dw_rv66c0000gn/T//ccrTM0vO.ltrans0.ltrans.o: In function `loop':_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:100: undefined reference to `PS2X::read_gamepad()'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:102: undefined reference to `PS2X::ButtonPressed(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:104: undefined reference to `PS2X::ButtonPressed(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:106: undefined reference to `PS2X::ButtonPressed(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:108: undefined reference to `PS2X::ButtonPressed(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:110: undefined reference to `PS2X::ButtonPressed(unsigned int)'_
_/var/folders/g5/4wf76ps914j5sc59dw_rv66c0000gn/T//ccrTM0vO.ltrans0.ltrans.o:/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:113: more undefined references to `PS2X::ButtonPressed(unsigned int)' follow_
_/var/folders/g5/4wf76ps914j5sc59dw_rv66c0000gn/T//ccrTM0vO.ltrans0.ltrans.o: In function `loop':_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:116: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:118: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:121: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:123: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:126: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:132: undefined reference to `PS2X::read_gamepad(bool, unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:134: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:136: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:139: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:141: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:143: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:145: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:147: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:149: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:151: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:153: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:156: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:157: undefined reference to `PS2X::NewButtonState()'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:158: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:160: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:162: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:164: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:166: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:170: undefined reference to `PS2X::ButtonPressed(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:172: undefined reference to `PS2X::NewButtonState(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:174: undefined reference to `PS2X::ButtonReleased(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:177: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:177: undefined reference to `PS2X::Button(unsigned int)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:179: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:181: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:183: undefined reference to `PS2X::Analog(unsigned char)'_
_/Users/berthelot/Documents/Arduino/libraries/Arduino-PS2X-master/PS2X_lib/examples/PS2X_Example/PS2X_Example.ino:185: undefined reference to `PS2X::Analog(unsigned char)'_
_collect2: error: ld returned 1 exit status_
_exit status 1_
_Error compiling for board Arduino/Genuino Uno._

_This report would have more information with_
_"Show verbose output during compilation"_
_option enabled in File -> Preferences._

I have looked at the PS2X_lib.h file and i can see that config_gamepad(), ButtonPressed(), Button(), read_gamepad(), Analog(), NewButtonState() and ButtonReleased() are declared in the class PS2X section of the code.

I have uninstalled everything and restored everything, but still the same problem. I have also ran the example that were provided to others who have add problem setting up their controller, and i get exactly the same results.

Has anyone come accross such strange message?

Thanks for your insight,
Ralphy

Solved!!! i had to move the PS2_lib folder out of the Arduino-PS2X-master folder and go from there.

onto a new phase now

ralphy

Happy to hear you resolved on your own. The original Bill Porter Page for anyone else interested:
http://www.billporter.info/2010/06/05/playstation-2-controller-arduino-library-v1-0/