Jump to content

uGFX - Linux - g++


Adam M

Recommended Posts

Hello!

 

Thanks for the effort you have put into uGFX! It has made setting up a UI from scratch MUCH simpler! 

CPU - armv7

OS - Ubuntu 16.04

On to the issue at hand - I would like to use the g++ compiler to build uGFX so that I can link in my own C++ source. I have my own Makefile that builds uGFX under gcc without issue, and I have linked in my own C code at this point. However, I now need C++ for some higher-level functionality code that we have. When I shift the compiler over to g++ I get a set of errors from within uGFX.

Here is one set as an example:

ui/resources/ugfx/src/gdisp/gdisp.c: In function ‘void gdispGControl(GDisplay*, unsigned int, void*)’:
ui/resources/ugfx/src/gdisp/gdisp.c:2877:29: error: invalid cast from type ‘void*’ to type ‘orientation_t {aka orientation}’
     switch ((orientation_t) value) {
                             ^
ui/resources/ugfx/src/gdisp/gdisp.c: In function ‘bool mf_drawline_callback(mf_str, uint16_t, void*)’:
ui/resources/ugfx/src/gdisp/gdisp.c:3352:105: error: cannot convert ‘justify_t {aka justify}’ to ‘mf_align_t’ for argument ‘4’ to ‘void mf_render_aligned(const mf_font_s*, int16_t, int16_t, mf_align_t, mf_str, uint16_t, mf_character_callback_t, void*)’
     mf_render_aligned(GD->t.font, GD->t.wrapx, GD->t.wrapy, GD->t.lrj, line, count, drawcharglyph, state);
                                                                                                         ^
ui/resources/ugfx/src/gdisp/gdisp.c: In function ‘bool mf_fillline_callback(mf_str, uint16_t, void*)’:
ui/resources/ugfx/src/gdisp/gdisp.c:3359:105: error: cannot convert ‘justify_t {aka justify}’ to ‘mf_align_t’ for argument ‘4’ to ‘void mf_render_aligned(const mf_font_s*, int16_t, int16_t, mf_align_t, mf_str, uint16_t, mf_character_callback_t, void*)’
     mf_render_aligned(GD->t.font, GD->t.wrapx, GD->t.wrapy, GD->t.lrj, line, count, fillcharglyph, state);
                                                                                                         ^

 

I was getting ready to barrel into the source and get it running under g++ - but I thought I better ask if that effort has already been done - or if I'm missing something simple.

Is uGFX already setup to work under g++?

I should add - I am using uGFX v2.8

Edited by Adam M
Link to comment
Share on other sites

You are mixing up compiling and linking.

uGFX must be compiled with gcc as it is written in C. It will quite happily link with C++ and the header file ugfx.h is fully C++ compatible.

If you are using make this is really simple...

.c files get compiled with gcc

.c++ files get compiled with g++

Link with g++

 

While C and C++ are similar languages they are not totally the same.

Link to comment
Share on other sites

Thanks for the reply inmarket. Just finished building our make system from the ground up - and didn't consider switching compilers and then linking with g++. I modified our makefile to build uGFX with gcc and our own source with g++, then linked with g++ as you suggested and everything is up and running now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...