Software Archive
Read-only legacy content
17061 Discussions

Compiling C using mraa on Edison

toadaze
Beginner
954 Views

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?

 

 

0 Kudos
1 Solution
Alexander_K_Intel
954 Views

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

0 Kudos
2 Replies
Alexander_K_Intel
955 Views

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.

0 Kudos
toadaze
Beginner
954 Views

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

gcc -g analog_input.c -o analog_input -lmraa

 

0 Kudos
Reply