I´ve bought and successfully run pololu3pi robot.
I tried examples and also my own code using C-based libs given in libpololu-avr, which I successfully installed into my AVRStudio 4.0.
Also I found out, that C+±based libs are given(using OOP C++, which I prefer), but if I include these libs, compiler exits with on line including Class::StaticMethod(); with message …/cpp.c:14: error: expected expression before ‘:’ token
This err I explain by unsupported c++ lang.
Compiler also can´t compile code:
int Print(); // Nonstatic member.
static int CountOf(); // Static member.
with message …/cpp.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘Base’ which points on OOP unsupport.
I don´t know how to set/fix it up, just to compile also c++OOP code, if possible of course. But why are c++ libs included if they aren´t supported by AVRStudio??
Thanks for any help/explanation.
You have to tell AVR Studio to use the avr-g++ compiler if you want to do C++, not avr-gcc. What compiler is it using currently? (Look at the build output window at the bottom to see which compiler it is invoking.) If you just copied C++ code in to a C project, it will not work.
of course, compiler is the point, thanks and sorry for my newbie questions
I´m using gcc, which compiles only C. The question is, how to set up the g++compiler to compile my code well(understandably) for the pololu (or maybe no compiler set up is required, just the change of path from gcc to g++)
I´m really new to this,so please apologize my stupid questions.
Can’t say for sure (I don’t use that IDE) but often the build directives flow from the filename. If you rename your file from cpp.c to cpp.cc, magic might start happening.
I believe Lertulo is right; I just made an AVR Studio project with a source file called “test.cpp” and AVR Studio compiled it with avr-g++ automatically. I did not have to change any configuration options. “test.cc” worked as well, but not “test.c”, with the contents of the file exactly the same (a valid C++ program) in all cases.
So you should only have to rename your source file(s) to use an extension that is recognized by the AVR toolchain to mean a C++ source file.
i trust both of you´re right, but it doesn´t work on my computer.
I tried simply rename my *.c file to *.cpp but error was throwen (unable to change sufix in AVRStudio, and it doesn´t compile when sufix changed in file-manager).
so I created new project, without the “Create initial file” checked and created my own one *.cpp by myself (including main() ). Than, I imported it into source files in AVRStudio and in building proccess the error was occured.
make: *** No rule to make target `firstCpp.o', needed by `firstCpp.elf'. Stop.
I also tried to create new file in AVRStudio, but I was allowed to create just *.c or *.s files.
Running AVRStudio 4.15
I´m little bit confused, because your answers and advises are simple and clear, so I´m not sure if I misunderstood them at all,or if there´s some another problem.
Thanks for your answers,
I am not sure why you are getting that error. I am running AVR Studio 4.18, so you might want to try updating to that version and see if the error still shows up. Also, what version of WinAVR do you have installed?
well, i downloaded newest version of AVRStudio and everything is ok
to whom it may concern:
I create new project without initial file and then right click on source files (on the left) and add a newfile, sufixed by *.cpp
thanks a lot guys
I’m glad you got it working with the version upgrade. Thanks for letting us know.