Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Honored Contributor I
1,197 Views

Compiling C using mraa on Edison

Jump to solution

The iotdk-ide-win SDK(Eclipse) works great on my Windows machine to compile, upload and run programs on my Edison. And of course, I can run the compiled executable directly on the Edison from its command line, too.

But I am not able to compile C programs using mraa references directly on the Edison. I get this error:

/tmp/ccqxH6Mw.o: In function `main':

 

analog_input.c:(.text+0x18): undefined reference to `mraa_aio_init'

 

analog_input.c:(.text+0x28): undefined reference to `mraa_aio_read'

 

collect2: error: ld returned 1 exit status

I would have expected the compiler to error on the # include "mraa.h" line if that was the problem.

I can compile other C programs on the Edison using gcc.

Any help?


Accepted Solutions
Highlighted
Honored Contributor I
7 Views

Re: Compiling C using mraa on Edison

Jump to solution

It is linker not compiler giving the error. Please make sure you add -lmraa to the options to let the linker know what library to link with.

View solution in original post

2 Replies
Highlighted
Honored Contributor I
8 Views

Re: Compiling C using mraa on Edison

Jump to solution

It is linker not compiler giving the error. Please make sure you add -lmraa to the options to let the linker know what library to link with.

View solution in original post

Highlighted
Honored Contributor I
7 Views

Re: Compiling C using mraa on Edison

Jump to solution

Thanks Alexander. That was my problem. Here is an example for other rookies like me:

gcc -g analog_input.c -o analog_input -lmraa