Closed sergiobd007 closed 5 years ago
Thank you for the additions. Do you have a makefile for compiling? Probably you could add it to the project.
I had to restructure the files quite a bit, and I don't know if I maintained compatibility with eclipse. Are you able to test that? I will also change the README, but I think it's better to first know if it will work. I based my work on this fork.
Thank you for the effort. I just tried to compile it with
make
But I get this error:
from ...../temp/ArduinoOnPc/src/cores/arduino/Stream.cpp:25: /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
Therefore it is necessary to add this to the makeNativeArduino.mk:
CFLAGS += -std=c++11
Afterwards there are some other errors in Print.cpp
I solved this earlier in the FastLed-Fork: https://github.com/ChrisMicro/ArduinoOnPc/tree/FastLed
Does your version compile without error on your computer?
It does indeed compile without errors, and when I add the flag you said it gives me this warning (it compiles ok, though):
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C
This is my gcc version:
$ g++ --version
g++ (GCC) 8.2.1 20181127
Afterwards there are some other errors in Print.cpp
Can you show me the errors so I can investigate them?
Strange, it seems really to be a compiler problem:
/home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp: In member function ‘size_t Print::printFloat(double, uint8_t)’: /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:255:19: error: ‘isnan’ was not declared in this scope if (isnan(number)) return print("nan"); ^ /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:255:19: note: suggested alternative: In file included from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Arduino.h:15:0, from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:27: /usr/include/c++/5/cmath:641:5: note: ‘std::isnan’ isnan(_Tp __x) ^ /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:256:19: error: ‘isinf’ was not declared in this scope if (isinf(number)) return print("inf"); ^ /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:256:19: note: suggested alternative: In file included from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Arduino.h:15:0, from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:27: /usr/include/c++/5/cmath:621:5: note: ‘std::isinf’ isinf(_Tp __x) ^ At global scope: cc1plus: warning: unrecognized command line option ‘-Wno-class-memaccess’ ../../makeNativeArduino.mk:73: die Regel für Ziel „build//home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.o“ scheiterte make: *** [build//home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.o] Fehler 1
My Compiler: g++ --version g++ (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
In the last line in https://gcc.gnu.org/projects/cxx-status.html it says:
This mode is the default in GCC versions prior to 6.1; it can be explicitly selected with the -std=c++98 command-line flag, or -std=gnu++98 to enable GNU extensions as well.
So it makes sense that it gives you an error if the code uses features from c++11 standard. Do you have gcc updated?
It does indeed compile without errors, and when I add the flag you said it gives me this warning (it compiles ok, though):
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C
And about this it seems like the cause is that you added the option -std=c++11
as a CFLAG, not a CXXFLAG, and it doesn't make sense to use a c++ standard to compile c. Does it compile ok if you use that option in CXXFLAGS? You may also need to add -std=c11
as a CFLAG if the code uses features from that version. (But then we couldn't use this line: CXXFLAGS += $(CFLAGS)
)
Thank you, you are right. It hast do be CXXFLAGS += -std=c++11
Do you have gcc updated?
I try not to update gcc because if other people want to compile the repository they will face the same issues when using Ubuntu16.4. So it is better to make the Makefile pullet proof for all systems.
Now I have still the Printf-Errors:
_/home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp: In member function ‘size_t Print::printFloat(double, uint8_t)’: /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:255:19: error: ‘isnan’ was not declared in this scope if (isnan(number)) return print("nan"); ^ /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:255:19: note: suggested alternative: In file included from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Arduino.h:15:0, from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:27: /usr/include/c++/5/cmath:641:5: note: ‘std::isnan’ isnan(_Tp __x) ^ /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:256:19: error: ‘isinf’ was not declared in this scope if (isinf(number)) return print("inf"); ^ /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:256:19: note: suggested alternative: In file included from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Arduino.h:15:0, from /home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.cpp:27: /usr/include/c++/5/cmath:621:5: note: ‘std::isinf’ isinf(_Tp _x) ^ At global scope: cc1plus: warning: unrecognized command line option ‘-Wno-class-memaccess’ ../../makeNativeArduino.mk:73: die Regel für Ziel „build//home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.o“ scheiterte make: *** [build//home/christoph/temp/ArduinoOnPc/src/cores/arduino/Print.o] Fehler 1
Here is my dirty hack of Print.cpp
I try not to update gcc because if other people want to compile the repository they will face the same issues when using Ubuntu16.4.
I meant the last version in the official repositories.
I think it may have to do with not using GNU extensions with the option -std=c++11
. Does it work with the Makefile I have just uploaded?
Does it work with the Makefile I have just uploaded?
If we ignore the errors in Print.cpp, yes. I wonder why you don't have these. I thing it hast something to do with different paths or namespaces. If you want, you can add your changed README.md , I will merge and change the Print.cpp , so that it compiles on my system.
Here the errors:
/home/christoph/temp/v1/ArduinoOnPc/src/system/depreciated/posixWrapper.c: In function ‘create_gc’: /home/christoph/temp/v1/ArduinoOnPc/src/system/depreciated/posixWrapper.c:84:9: warning: ordered comparison of pointer with integer zero [-Wextra] if (gc < 0) ^ /home/christoph/temp/v1/ArduinoOnPc/src/system/XWindow.cpp: In member function ‘_XGC XWindow::create_gc(Display, Window, int)’: /home/christoph/temp/v1/ArduinoOnPc/src/system/XWindow.cpp:73:11: warning: ordered comparison of pointer with integer zero [-Wextra] if (gc < 0) ^ At global scope: cc1plus: warning: unrecognized command line option ‘-Wno-class-memaccess’ /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Print.cpp: In member function ‘size_t Print::printFloat(double, uint8_t)’: /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Print.cpp:255:19: error: ‘isnan’ was not declared in this scope if (isnan(number)) return print("nan"); ^ /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Print.cpp:255:19: note: suggested alternative: In file included from /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Arduino.h:15:0, from /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Print.cpp:27: /usr/include/c++/5/cmath:641:5: note: ‘std::isnan’ isnan(_Tp __x) ^ /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Print.cpp:256:19: error: ‘isinf’ was not declared in this scope if (isinf(number)) return print("inf"); ^ /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Print.cpp:256:19: note: suggested alternative: In file included from /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Arduino.h:15:0, from /home/christoph/temp/v1/ArduinoOnPc/src/cores/arduino/Print.cpp:27: /usr/include/c++/5/cmath:621:5: note: ‘std::isinf’ isinf(_Tp __x) ^ At global scope:
Can you try to add -lm to CFLAGS to see if that fixes it for you? Now that I think about it, it shouldn't work without that option. Do you want to maintain compatibility with eclipse? I don't know if it works now.
Edit: I already added the option in the last commit.
isnan and isinf are still giving the errors "was not declared in this scope"
It should be fixed now. I switched it to the cmath
library.
Do you want to maintain compatibility with eclipse? I don't know if it works now.
Great work .. now it compiles. There is only one warning left, when I compile "cellArt"
/home/christoph/temp/v1/ArduinoOnPc/src/system/depreciated/posixWrapper.c: In function ‘create_gc’: /home/christoph/temp/v1/ArduinoOnPc/src/system/depreciated/posixWrapper.c:84:9: warning: ordered comparison of pointer with integer zero [-Wextra] if (gc < 0) ^ /home/christoph/temp/v1/ArduinoOnPc/src/system/XWindow.cpp: In member function ‘_XGC XWindow::create_gc(Display, Window, int)’: /home/christoph/temp/v1/ArduinoOnPc/src/system/XWindow.cpp:73:11: warning: ordered comparison of pointer with integer zero [-Wextra] if (gc < 0)
Do you want to maintain compatibility with eclipse? I don't know if it works now.
I think, the eclipse compatibility can be skipped. The last time I tried to compile it on Eclipse it did not work because the Eclipse version changed. So it's probably better to only focus on the make-file.
I can merge your pull request now if you are happy with that.
I think it's ready to be merged.
It gives me this warning when compiling 'cellArt', though:
/home/mike/Documents/ArduinoOnPc/libraries/Adafruit_GFX/glcdfont.c:18:28: warning: ‘font’ defined but not used [-Wunused-const-variable=]
static const unsigned char font[] PROGMEM = {
It should be safe to delete, but it may be necessary to implement something else, I didn't have time now to investigate any further.
Now it looks really good. I will merge it. Thank you :-)
There were only stub methods for input handling, so I added them. I'm no expert in this field and I didn't tested the changes with eclipse as I don't use it, so it would be necessary to test them in that environment.