11 years, 1 month ago.

Importing a second library into a program

Hi,

The code listed below is from the SMTPClient_HelloWorld. It works perfectly. However, I now wish to add SD card functionality to this program, so I imported the SDFileSystem into the program (SMTPClient_HelloWorld). When I try to compile (without adding one single line of code extra, I keep on getting the errror message: "cannot open source input file "mbed_debug.h": No such file or directory" in file "SDFileSystemSDFileSystem.cpp", Line: 116, Col: 23. I have tried a number of different ways to import the SD library and keep on getting the same error.

Any help would be greatly appreciated. Thanks.

  1. include "mbed.h"
  2. include "EthernetNetIf.h"
  3. include "NTPClient.h"
  4. include "SMTPClient.h" #include "SDFileSystem.h"
  1. define HOSTNAME "mbedSE"

server is domain name eg. mail.authsmtp.com port is smtp port eg. 25 or 23 domain must be acceptable to server (but often is not strictly enforced since does not affect FROM address)

  1. define SERVER "xxxx"
  2. define PORT 25
  3. define USER "xxxxx"
  4. define PASSWORD "xxxx"
  5. define DOMAIN "mailnull.com"
  6. define FROM_ADDRESS "xxxxx"
  7. define TO_ADDRESS "xxxx"

EthernetNetIf eth(HOSTNAME); DigitalOut led1(LED1, "led1");

int main() {

EthernetErr ethErr; int count = 0; do { printf("Setting up %d...\n", ++count); ethErr = eth.setup(); if (ethErr) printf("Timeout\n", ethErr); } while (ethErr != ETH_OK);

printf("Connected OK\n"); const char* hwAddr = eth.getHwAddr(); printf("HW address : %02x:%02x:%02x:%02x:%02x:%02x\n", hwAddr[0], hwAddr[1], hwAddr[2], hwAddr[3], hwAddr[4], hwAddr[5]);

IpAddr ethIp = eth.getIp(); printf("IP address : %d.%d.%d.%d\n", ethIp[0], ethIp[1], ethIp[2], ethIp[3]);

NTPClient ntp; printf("NTP setTime...\n"); Host server(IpAddr(), 123, "pool.ntp.org"); printf("Result : %d\n", ntp.setTime(server));

time_t ctTime = time(NULL); printf("\nTime is now (UTC): %d %s\n", ctTime, ctime(&ctTime));

Host host(IpAddr(), PORT, SERVER); SMTPClient smtp(host, DOMAIN, USER, PASSWORD, SMTP_AUTH_PLAIN);

EmailMessage msg; msg.setFrom(FROM_ADDRESS); msg.addTo(TO_ADDRESS);

msg.printf("This is an email from mbed to you\n"); msg.printf(".\r\n");

printf("Send result %d\n", smtp.send(&msg)); printf("Last response | %s", smtp.getLastResponse().c_str());

Timer tm; tm.start();

while (true) { if (tm.read() > 0.5) { led1 = !led1; tm.start(); } } }

Hi Mike, best thing to do is link to the program or library you are having trouble with.

posted by Dan Ros 16 Mar 2013

2 Answers

mike egan
poster
11 years, 1 month ago.

Thanks a lot Tim, I appreciate it.

Mike

Accepted Answer
11 years, 1 month ago.

Hey Mike,

You need to update your mbed library. The newer versions of the mbed library have debug.h included. Right click on the mbed library in your program folder and click update.

Tim

Hi Tim,

Thanks for the suggestion, however, the mbed library is up to date. I have since tried a number of times to import the program given on the link: http://mbed.org/cookbook/SD-Card-File-System into a new file. it compiles and runs no problem. Next step import the library from the link: http://mbed.org/cookbook/SMTPClient into the program. With no change in the code whatsoever, the program will cause compile errors. I would appreciate it if any one has come across this before or can tell me what I am doing wrong.

Thanks

posted by mike egan 17 Mar 2013

Hey Mike,

I looked into it a little more. First off, the right click and update procedure does not seem to work. That example is currently on build 29. To get it to update you have to click on mbed in the example folder and go to the right hand side of the window and hit update. This will update it to revision 61 and allow SDFileSystem to compile. However, if you do that you will break the NetServices library. That TCP/IP library is deprecated and no longer supported.

http://mbed.org/handbook/Ethernet-Interface

This is the new supported library. You will have to modify the hello world example to use this.

I also tried to see if you could use an older revision of the mbed library, however none of the old revisions that support the SDFileSystem library also support the deprecated NetServices library.

Tim

posted by Tim Zuercher 17 Mar 2013

Mike,

Sorry for the double comment. You can also check out

http://mbed.org/users/sunifu/code/SimpleSMTPClient_HelloWorld/

This is a SMTP client example that is updated to work with the new libraries. I just tried to compile it with SDFileSystem and both of them work.

Tim

posted by Tim Zuercher 17 Mar 2013