- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Very simple C++ code in Eclipse (windows) won't compile. This is the code, and the compiler's output is right after it.
HELP!
#include <unistd.h>
#include <iostream>
#include "servo.h"
#include <signal.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
upm::Servo *servo = new upm::Servo();
servo->setAngle(180);
servo->setAngle(90);
servo->setAngle(0);
servo->setAngle(90);
servo->setAngle(180);
std::cout << "Exiting application." << std::endl;
delete servo;
return 0;
}
Output:
Info: Internal Builder is used for build
i586-poky-linux-g++ "-IC:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux/usr/include/upm" "-IC:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux/usr/include/mraa" -O0 -g3 -Wall -c -fmessage-length=0 "--sysroot=C:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux" -m32 -march=i586 -c -ffunction-sections -fdata-sections -o "src\\test.o" "..\\src\\test.cpp"
..\src\test.cpp: In function 'int main(int, char**)':
..\src\test.cpp:9:37: error: no matching function for call to 'upm::Servo::Servo()'
upm::Servo *servo = new upm::Servo();
^
..\src\test.cpp:9:37: note: candidates are:
In file included from ..\src\test.cpp:3:0:
C:\Users\mmendes\Desktop\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux/usr/include/upm/servo.h:54:9: note: upm::Servo::Servo(int)
Servo (int pin);
^
C:\Users\mmendes\Desktop\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux/usr/include/upm/servo.h:54:9: note: candidate expects 1 argument, 0 provided
C:\Users\mmendes\Desktop\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux/usr/include/upm/servo.h:47:7: note: upm::Servo::Servo(const upm::Servo&)
class Servo {
^
C:\Users\mmendes\Desktop\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux/usr/include/upm/servo.h:47:7: note: candidate expects 1 argument, 0 provided
- Tags:
- Internet of Things
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you using the new Intel® IoT Developer Kit v1.0 ?
What is the version of mraa and upm libraries? Latest versions are
root@edison:/tmp# opkg info libmraa0
Package: libmraa0
Version: 0.6.1
root@edison:/tmp# opkg info upm
Package: upm
Version: 0.1.9
If you are not using the latest, upgrade by using these commands
echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf
opkg update
opkg upgrade
For the LCD code above you need to link the lcd library while compiling. Right-click on project and select properties and check if you can see the respective library added under Cross G++ linker.
If not add the libraries to the linker. For LCD upm-i2clcd, servo upm-servo ...
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dont you need a pin number in your setup of the Servo object?
From servo.h class Servo { public: /** * Instantiates a servo object * * @param pin servo pin number */ Servo (int pin);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried that first. Here's the output if I change
upm::Servo *servo = new upm::Servo();
to
upm::Servo *servo = new upm::Servo(5);
Info: Internal Builder is used for build
i586-poky-linux-g++ "--sysroot=C:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux" -lmraa -o Servo "src\\Servo.o"
src\Servo.o: In function `main':
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\Servo\Debug/..\src/Servo.cpp:9: undefined reference to `upm::Servo::Servo(int)'
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\Servo\Debug/..\src/Servo.cpp:11: undefined reference to `upm::Servo::setAngle(int)'
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\Servo\Debug/..\src/Servo.cpp:12: undefined reference to `upm::Servo::setAngle(int)'
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\Servo\Debug/..\src/Servo.cpp:13: undefined reference to `upm::Servo::setAngle(int)'
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\Servo\Debug/..\src/Servo.cpp:14: undefined reference to `upm::Servo::setAngle(int)'
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\Servo\Debug/..\src/Servo.cpp:15: undefined reference to `upm::Servo::setAngle(int)'
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\Servo\Debug/..\src/Servo.cpp:19: undefined reference to `upm::Servo::~Servo()'
collect2.exe: error: ld returned 1 exit status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This really sucks. This LCD one does not work either.
#include "lcm1602.h"
#include <unistd.h>
int main (int argc, char **argv)
{
upm::Lcm1602* lcd = new upm::Lcm1602(6, 0x27);
lcd->setCursor(0, 0);
lcd->write("Hello World!");
lcd->close();
return 0;
}
Same type of output
Info: Internal Builder is used for build
i586-poky-linux-g++ "-IC:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux/usr/include/upm" "-IC:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux/usr/include/mraa" -O0 -g3 -Wall -c -fmessage-length=0 "--sysroot=C:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux" -m32 -march=i586 -c -ffunction-sections -fdata-sections -o "src\\LCD.o" "..\\src\\LCD.cpp"
i586-poky-linux-g++ "--sysroot=C:\\Users\\mmendes\\Desktop\\iotdk-ide-win\\devkit-x86\\sysroots\\i586-poky-linux" -lmraa -o LCD "src\\LCD.o"
src\LCD.o: In function `main':
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\LCD\Debug/..\src/LCD.cpp:6: undefined reference to `upm::Lcm1602::Lcm1602(int, int)'
C:\Users\mmendes\Desktop\iotdk-ide-win\workspace\LCD\Debug/..\src/LCD.cpp:9: undefined reference to `upm::I2CLcd::close()'
collect2.exe: error: ld returned 1 exit status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I can now see the problem.
First issue is that you definately need the pin argument for Servo - having this in means the code will compile... which leads to........
The actual error appears to be coming from the linker - and whilst I see it is linking in mraa it does not appear to be linking in the servo code.
I am in my office at the moment so cannot check but it is one of the project properties in eclipse - you just need to add the library to be linked in
Stan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I mention the servo code what I should have said was the library that contains the servo (or lcd or whatever) code - I am not sure if it is libupm or a separate library libservo - but it should be easy enough to find.
Stan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you using the new Intel® IoT Developer Kit v1.0 ?
What is the version of mraa and upm libraries? Latest versions are
root@edison:/tmp# opkg info libmraa0
Package: libmraa0
Version: 0.6.1
root@edison:/tmp# opkg info upm
Package: upm
Version: 0.1.9
If you are not using the latest, upgrade by using these commands
echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf
opkg update
opkg upgrade
For the LCD code above you need to link the lcd library while compiling. Right-click on project and select properties and check if you can see the respective library added under Cross G++ linker.
If not add the libraries to the linker. For LCD upm-i2clcd, servo upm-servo ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks everybody! The issue was the missing libraries in the linker's configuration.
EDIT: Never mind the stuff below. It was not working because there was an issue with our wireless network. Once that was fixed it worked like a charm.
But I see that my libraries are an older version and in need of being updated. But I get errors when I attempt to upgrade them.
root@memjr7301:~#ls /etc/opkg -al drwxr-xr-x 2 root root 4096 Mar 25 02:12 . drwxr-xr-x 42 root root 4096 Mar 18 02:35 .. -rw-r--r-- 1 root root 94 Dec 9 17:30 arch.conf -rw-r--r-- 1 root root 0 Dec 9 17:30 base-feeds.conf -rw-r--r-- 1 root root 58 Jan 29 10:32 iotkit.conf -rw-r--r-- 1 root root 60 Mar 25 02:11 mraa-upm.conf -rw-r--r-- 1 root root 791 Dec 9 17:30 opkg.conf root@memjr7301:~# root@memjr7301:~# cat /etc/opkg/iotkit.conf src iotkit http://iotdk.intel.com/repos/1.1/intelgalactic root@memjr7301:~# root@memjr7301:~# cat /etc/opkg/mraa-upm.conf src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic root@memjr7301:~# cat /etc/opkg/opkg.conf # Must have one or more source entries of the form: # # src <src-name> <source-url> # # and one or more destination entries of the form: # # dest <dest-name> <target-path> # # where <src-name> and <dest-names> are identifiers that # should match [a-zA-Z0-9._-]+, <source-url> should be a # URL that points to a directory containing a Familiar # Packages file, and <target-path> should be a directory # that exists on the target system. # Proxy Support #option http_proxy http://proxy.tld:3128 #option ftp_proxy http://proxy.tld:3128 #option proxy_username <username> #option proxy_password <password> # Enable GPGME signature # option check_signature 1 # Offline mode (for use in constructing flash images offline) #option offline_root target dest root / lists_dir ext /var/lib/opkg root@memjr7301:~# root@memjr7301:~# opkg info opkg info libmraa0 Package: opkg Version: 1:0.2.1-r0 Depends: opkg-config-base, update-alternatives-opkg, libopkg1 (>= 0.2.1), run-postinsts, libc6 (>= 2.19) Replaces: opkg-nogpg Status: install user installed Architecture: core2-32 Installed-Time: 1422624041 Collected errors: * parse_from_stream_nomalloc: Missing new line character at end of file! * parse_from_stream_nomalloc: Missing new line character at end of file! root@memjr7301:~# root@memjr7301:~# opkg info upm Package: upm Version: 0.1.8-r0 Depends: libgcc1 (>= 4.8.2), libpython2.7-1.0 (>= 2.7.3), libstdc++6 (>= 4.8.2), python-core, libc6 (>= 2.19), libmraa0 (>= 0.5.2) Status: install ok installed Architecture: core2-32 Installed-Time: 1422624048 Collected errors: * parse_from_stream_nomalloc: Missing new line character at end of file! * parse_from_stream_nomalloc: Missing new line character at end of file! root@memjr7301:~# root@memjr7301:~# opkg update Downloading http://iotdk.intel.com/repos/1.1/intelgalactic/Packages. Downloading http://iotdk.intel.com/repos/1.1/intelgalactic/Packages. Collected errors: * parse_from_stream_nomalloc: Missing new line character at end of file! * parse_from_stream_nomalloc: Missing new line character at end of file! * opkg_download: Failed to download http://iotdk.intel.com/repos/1.1/intelgalactic/Packages, wget returned 4. * opkg_download: Failed to download http://iotdk.intel.com/repos/1.1/intelgalactic/Packages, wget returned 4. root@memjr7301:~# opkg upgrade Collected errors: * parse_from_stream_nomalloc: Missing new line character at end of file! * parse_from_stream_nomalloc: Missing new line character at end of file! root@memjr7301:~#
![](/skins/images/D2683F18326913BBA0436CB7114DD569/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page