Neural net library include problem

Hi guys, I’m doing a porting of my neural net libraries.
I have some stupid problem of include dependencies which I can’t solve.
Basically a class called NeuronBP is described in 2 files
NeuronBP.h
NeuronBP.cpp
placed in
libpololu-avr/src/Ico
I modified the makefile to produce the .o file and is working.
Now because NeuronBP.h is using the LCD screen i would like to include the orangutanlcd so I tried something like.
NeuronBP.h

#ifndef NeuronBP_h_
#define NeuronBP_h_

// =====================================================================================
// System Includes
// =====================================================================================


#include <math.h>

#ifndef OrangutanLCD_h
#include <pololu/OrangutanLCD.h>
#endif

// =====================================================================================
// =====================================================================================
class NeuronBP
{
.......... code here
}

#endif

And in NeuronBP.cpp

// =====================================================================================
// Includes
// =====================================================================================

#include "NeuronBP.h"

// =====================================================================================
// defines and consts
// =====================================================================================
#include "../OrangutanLCD/OrangutanLCD.h"

#define max(a,b) (((a) > (b)) ? (a) : (b))

code here...

I tried different variations but I’m still getting this error:

In the zip there’s the code I’m trying to compile if somebody wants to have fun.
:unamused:
libpololu-avr-neural.zip (247 KB)

Hello,
You are programming in C++, so you need to use the C++ version of the functions. Instead of print(), use OrangutanLCD::print(), and so on. In the library documentation, the C++ functions are colored green. That should help you…but it is also a bit confusing that you are including two different copies of OrangutanLCD.h from two different places. There’s no need, as far as I can tell, for NeuronBP.h to include OrangutanLCD.h, since none of the code in NeuronBP.h depends on OrangutanLCD.h being included. NeuronBP.cpp should (and does) include OrangutanLCD.h, but it should be including it from the system include directory (with ) instead of a local directory (with “quotes”).

Anyway, I hope that helps you get it working - please let us know if you have more questions!
-Paul

O yes you are right.
Oky now it compiled and installed properly.

And install:

Now I’m trying to use test it with this code:

#include <pololu/NeuronBP.h>
int main()
{


	//NeuronBP *bptest=new NeuronBP();


	return 0;
}

and the makefile is:

CFLAGS=-g -Wall -mcall-prologues -mmcu=atmega168 -Os
CC=avr-gcc
CPP=avr-g++
OBJ2HEX=avr-objcopy 
LDFLAGS=-Wl,-gc-sections -lpololu

PORT=/dev/ttyUSB0
AVRDUDE=avrdude
TARGET=test
OBJECT_FILES=test.o

all: $(TARGET).hex

clean:
	rm -f *.o *.hex *.obj *.hex

%.hex: %.obj
	$(OBJ2HEX) -R .eeprom -O ihex $< $@

test.o: test.cpp

%.obj: $(OBJECT_FILES)
	$(CPP) $(CFLAGS) $(OBJECT_FILES) $(LDFLAGS) -o $@

program: $(TARGET).hex
	$(AVRDUDE) -p m168 -c avrisp2 -P $(PORT) -U flash:w:$(TARGET).hex

but when I try to compile:

I don’t know why but when I do make it’s still using the g++ of the intel arch instead of the aver one!
Any clues? :blush:

P.S.
also trying:

doesn’t help

O finally i managed to compile it and use the library in the arduino environment.

Nevertheless using the traditional makefiles still gives me the trouble of the incorrect compiler (g++ instead of avr-g++).

Hello,

I looked up the Implicit Varible documentation for GNU make to figure out what was wrong. I think that instead of

CPP=avr-g++

you need to use

CXX=avr-g++

CPP is for the C preprocessor, not the C++ compiler.

Does that help?
-Paul

Yes you are right with this configuration:

CFLAGS=-g -Wall -mcall-prologues -mmcu=atmega168 -Os
CPP=/usr/bin/avr-g++
CXX=/usr/bin/avr-g++
CC=/usr/bin/avr-gcc
OBJ2HEX=avr-objcopy 
LDFLAGS=-Wl,-gc-sections -lpololu

PORT=/dev/ttyUSB0
AVRDUDE=avrdude
TARGET=test
OBJECT_FILES=test.o

all: $(TARGET).hex

clean:
	rm -f *.o *.hex *.obj *.hex

%.hex: %.obj
	$(OBJ2HEX) -R .eeprom -O ihex $< $@

test.o: test.cpp

%.obj: $(OBJECT_FILES)
	$(CXX) $(CFLAGS) $(OBJECT_FILES) $(LDFLAGS) -o $@

program: $(TARGET).hex
	$(AVRDUDE) -p m168 -c avrisp2 -P $(PORT) -U flash:w:$(TARGET).hex

is being compiled but let me try to debug it before saying victory. :mrgreen: