Page 1 of 1

Compile Error

Posted: Sat Oct 19, 2013 12:11 am
by romdude75
So I copied and pasted the demo and when I go to compile I keep getting VG/openvg.h: No such file or directory.. I am new to compiling stuff in Linux so if I can get a quick walk through, that would be great as it is probably something easy that I am not doing.

Thanks!

Re: Compile Error

Posted: Sat Oct 19, 2013 8:51 am
by DeeJay
romdude75 wrote:So I copied and pasted the demo
To give people a fighting chance of recreating your problem and helping, would you care to share the details of where you found that demo?

[See the links at the foot of this message for hints on how to get help effectively.]

Re: Compile Error

Posted: Sat Oct 19, 2013 6:37 pm
by romdude75
Haha, yeah my bad. You would think that I would have done that. Sorry!

Here is the code that I have saved as hw.c:

Code: Select all

// first OpenVG program
// Anthony Starks (ajstarks@gmail.com)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "fontinfo.h"
#include "shapes.h"

int main() {
    int width, height;
    char s[3];

    init(&width, &height);                  // Graphics initialization

    Start(width, height);                   // Start the picture
    Background(0, 0, 0);                    // Black background
    Fill(44, 77, 232, 1);                   // Big blue marble
    Circle(width / 2, 0, width);            // The "world"
    Fill(255, 255, 255, 1);                 // White text
    TextMid(width / 2, height / 2, "hello, world", SerifTypeface, width / 10);  // Greetings 
    End();                                  // End the picture

    fgets(s, 2, stdin);                     // look at the pic, end with [RETURN]
    finish();                               // Graphics cleanup
    exit(0);
}
When I try to compile with either of the following command lines, it will error out with:

Code: Select all

/tmp/cco5gLn6.o: In function `main':
hw.c:(.text+0x24): undefined reference to `init'
hw.c:(.text+0x38): undefined reference to `Start'
hw.c:(.text+0x48): undefined reference to `Background'
hw.c:(.text+0x5c): undefined reference to `Fill'
hw.c:(.text+0x90): undefined reference to `Circle'
hw.c:(.text+0xa4): undefined reference to `Fill'
hw.c:(.text+0x124): undefined reference to `TextMid'
hw.c:(.text+0x128): undefined reference to `End'
hw.c:(.text+0x148): undefined reference to `finish'
collect2: ld returned 1 exit status
I've tried:

Code: Select all

gcc -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -L/opt/vc/lib -lGLESv2 hw.c -o hw
and

Code: Select all

cc -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -o hw hw.c  -L/opt/vc/lib -lGLESv2
with the same results. I am running Raspbian, the version before 2013-09-25 but I did do a rpi-update yesterday.

Any help would be greatly appreciated since I am trying to code a UI that will run from the command line and this looks like it will work nicely if I can get it to compile. Thanks again!

Re: Compile Error

Posted: Sat Oct 19, 2013 6:52 pm
by AndyD
You need to download ajstarks libraries from github. The build instructions are here.

Re: Compile Error

Posted: Sat Oct 19, 2013 7:09 pm
by romdude75
Thanks AndyD, that fixed it right up. I did notice that when I went to my original file to compile my original example that I still got the errors, but if I compiled from that client folder it worked correctly. How should I be adding that folder so that I can compile from other others?