How to build library mixing .c and .cpp source files
hi
i made following code tests:
a library class .h file:
a library class .cpp file:
and other include files test.h test.c test2.h test2.cpp respectively:
test.h
test.c
test2.h
test2.cpp
well, when compile these codes message arduino compiler:
jtag/jtag.cpp.o: in function `jtagclass::mult(int)':
/usr/share/arduino/libraries/jtag/jtag.cpp:26: undefined reference `sum(int)'
collect2: ld returned 1 exit status
how fix problem, mix c c++ codes?
thanks
i made following code tests:
a library class .h file:
code: [select]
#ifndef jtag_h
#define jtag_h
#include "test.h"
#include "test2.h"
class jtagclass{
public:
static int soma(int x);
static int soma2(int x);
static int mult(int x);
};
extern jtagclass jtag;
#endif
a library class .cpp file:
quote
#include "jtag.h"
int jtagclass::soma(int x){
return x+x;
}
int jtagclass::soma2(int x){
return sum(x);
}
int jtagclass::mult(int x){
return x*x;
}
and other include files test.h test.c test2.h test2.cpp respectively:
test.h
quote
static int sum(int x);
test.c
quote
#include "test.h"
extern int sum(int x){
return x+x;
}
test2.h
quote
#ifndef zamber_h
#define zamber_h
class zamber{
public :
int zam(int x);
};
#endif
test2.cpp
quote
#include "test2.h"
int zamber::zam(int x){
return x*x;
}
well, when compile these codes message arduino compiler:
jtag/jtag.cpp.o: in function `jtagclass::mult(int)':
/usr/share/arduino/libraries/jtag/jtag.cpp:26: undefined reference `sum(int)'
collect2: ld returned 1 exit status
how fix problem, mix c c++ codes?
thanks
Arduino Forum > Using Arduino > Programming Questions > How to build library mixing .c and .cpp source files
arduino
Comments
Post a Comment