0

It's my first Atmel Studio project. I've set up the IDE and made it work with example code provided with new project.

Now I'm trying to run a simple code using PCF8574:

#include <Arduino.h>
#include <Wire.h>
#include <PCF8574.h>

/* Constants */
const int static SERIAL_SPEED = 57600;

/* Functions */
void setup();
void loop();

/* Variables */
PCF8574 expander = PCF8574();

void setup() {
    Serial.begin(57600);
    expander.begin(0x20);
}

void loop() {
    expander.digitalWrite(1, HIGH);
    delay(1000);
    expander.digitalWrite(1, LOW);
    delay(1000);
}

but I keep getting these errors:

undefined reference to 'PCF8574::begin(unsigned char)'  
undefined reference to 'PCF8574::digitalWrite(unsigned char, unsigned char)'
undefined reference to 'PCF8574::PCF8574()'

I've added PCF8574 to compiler directory (Properties > Toolchain > AVR C++ Compiler > Directories) and I'm sure that compiler 'sees' the .h file - otherwise it would throw 'No such file or directory' error.

PCF8574 library code: http://nettigo.pl/attachments/196

The same code (copied and pasted) compiled on ArduinoIDE works just fine so I gues it's something wrong with compiler/linker settings.

Has anyone encountered similar problem? I don't know what else do I save to setup in IDE to make it work fine.

  • The plugin doesn't use the atmel tool chain settings. Are you getting a compile or intellisense errors? Have you left the optional ide "location>sketch book folder" path empty? Switch on "Tools>Visual Micro>Verbose", then Build Clean, then Build. The output should show where it is looking for the PCF8574.h/cpp – Visual Micro Aug 16 '15 at 21:05
  • Is there a reason why this should not be closed as a duplicate of [What is an undefined reference/unresolved symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) This covers the reasons why you get the sort of error you're getting. – Jonathan Leffler Aug 16 '15 at 22:16
  • @JonathanLeffler: Although the root cause is the same, that question doesn't explain how to resolve the issue within Atmel Studio with the Visual Micro plugin. – Ignacio Vazquez-Abrams Aug 17 '15 at 05:19

0 Answers0