tibi38
Posts: 42
Joined: Sat Nov 10, 2012 8:46 am
Location: Europe
Contact: Website

how to use OpenVG with C++

Wed Jan 09, 2013 12:12 pm

Hi,
I tried to use OpenVG in a C++-Programm.
I had setup the OpenVG correct (rebuild.sh works fine and I could start also the compiled demos like world_font.bin).
By linking my programm I add the libs and the path.
But it brings me every time the error: undefined reference to `gx_graphics_init(char const*)'

Then I tried to setup the environment with the graphics.o (there is gx_graphics_init located), but the result is the same.

Any solution or ideas?
Admin of http://bed-and-breakfast-ungarn.de

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: how to use OpenVG with C++

Wed Jan 09, 2013 12:36 pm

Clearly it is not linking in the graphics.o correctly... Maybe start with a copy of the hello_font makefile and make sure the 'include ../Makefile.include' points to correct directory (for example replace with 'include /opt/vc/src/hello_pi/Makefile.include').
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

tibi38
Posts: 42
Joined: Sat Nov 10, 2012 8:46 am
Location: Europe
Contact: Website

Re: how to use OpenVG with C++

Wed Jan 09, 2013 1:43 pm

Dear rst,
i'm now a little bit farther and can compile and link a small sample.
(I use extern "C" to include the header files, after that I could link the files)
But now I got only an assert at s==0

Code: Select all

   GRAPHICS_RESOURCE_HANDLE img;
   uint32_t width, height;
   int LAYER=1;
   bcm_host_init();
   int s,t,u;
   char const fontPfad[] = ".";

   s = gx_graphics_init(".");
   assert(s == 0);

   t = graphics_get_display_size(0, &width, &height);
   assert(t == 0);
how can I check, that the bcm_host_init was proper called?
Admin of http://bed-and-breakfast-ungarn.de

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: how to use OpenVG with C++

Wed Jan 09, 2013 2:04 pm

Ah, the notorious C vs C++ name mangling issue... I have only been coding in C, so did not come to think of that. For me the examples and my derivatives have 'just worked' so far...

Someone mentioned somewhere on this forum that return values of some VC functions have changed in the latest releases - maybe it's that ...and actually if you look at the graphics.c, the comment for graphics_get_display_size says 'returns >=0 if it succeeded', so maybe try 'assert(s >= 0)'?
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

tibi38
Posts: 42
Joined: Sat Nov 10, 2012 8:46 am
Location: Europe
Contact: Website

Re: how to use OpenVG with C++

Wed Jan 09, 2013 3:07 pm

hi rst,
I found the root cause: The missing ttf-file in the directory ;-)
Admin of http://bed-and-breakfast-ungarn.de

tibi38
Posts: 42
Joined: Sat Nov 10, 2012 8:46 am
Location: Europe
Contact: Website

Re: how to use OpenVG with C++

Thu Jan 10, 2013 6:27 am

Now, it is linkable. But it shows nothing.
So I start with a workaround: I use C in a service for the presentation layer and a c++-program for the rest. Means, I give up to mix a C and a C++ here
Admin of http://bed-and-breakfast-ungarn.de

caioporto
Posts: 1
Joined: Wed Jun 26, 2013 12:23 am

Re: how to use OpenVG with C++

Wed Jun 26, 2013 12:24 am

tibi38 ,

Can you show your solution for the undefined reference?

Thank you!

dhoyos
Posts: 2
Joined: Mon Jul 08, 2013 3:58 pm

Re: how to use OpenVG with C++

Mon Jul 08, 2013 4:03 pm

Hi,

Could you provide a little more insight into how were you able to use C++ and OpenVG? I'm having the same problem...

maxan
Posts: 4
Joined: Fri Feb 15, 2013 3:37 pm

Re: how to use OpenVG with C++

Tue Jul 09, 2013 9:14 pm

Using OpenVG should be no different than mixing C and C++... The C++ FAQ has a nice section on how to do it...

Here's a link to the relevant section (http://www.parashift.com/c++-faq/cpp-calls-c.html). The rest of the section is probably worthy of a read as well.

Return to “OpenVG”