eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.37k stars 614 forks source link

Compiler swap messes up includes #970

Open Erikvv opened 5 years ago

Erikvv commented 5 years ago

I'm probably doing something wrong but I don't know how to proceed. Would like a pointer if anyone knows.

I can compile the library. But now I want to cross-compile to ARMv8.

When i change the build command from

cmake ..

to

cmake .. -DCMAKE_C_COMPILER="aarch64-linux-gnu-gcc"

The compiler command changes from

/usr/bin/cc 
    -Dmraa_EXPORTS 
    -I/home/erik/projects/dragonboard-sensors/vendor/mraa/api 
    -I/home/erik/projects/dragonboard-sensors/vendor/mraa/api/mraa 
    -I/home/erik/projects/dragonboard-sensors/vendor/mraa/include 
    -I/usr/include/json-c  
    -Wall 
    -Werror=main 
    -Wformat 
    -Wmain 
    -Wuninitialized 
    -Winit-self 
    -Werror=implicit 
    -Werror=missing-parameter-type 
    -DONEWIRE=1 
    -DX86PLAT=1 
    -DJSONPLAT=1 
    -fPIC   
    -std=gnu99 
    -o CMakeFiles/mraa.dir/mraa.c.o   
    -c /home/erik/projects/dragonboard-sensors/vendor/mraa/src/mraa.c

to

/usr/bin/aarch64-linux-gnu-gcc 
    -Dmraa_EXPORTS 
    -I/usr/include
    -I/home/erik/projects/dragonboard-sensors/vendor/mraa/api 
    -I/home/erik/projects/dragonboard-sensors/vendor/mraa/api/mraa 
    -I/home/erik/projects/dragonboard-sensors/vendor/mraa/include 
    -I/usr/include/json-c  
    -Wall 
    -Werror=main 
     -Wformat 
    -Wmain 
    -Wuninitialized 
    -Winit-self 
    -Werror=implicit 
    -Werror=missing-parameter-type 
    -DONEWIRE=1 
    -DX86PLAT=1 
    -DJSONPLAT=1 
    -fPIC   
    -std=gnu99 
    -o CMakeFiles/mraa.dir/mraa.c.o   
    -c /home/erik/projects/dragonboard-sensors/vendor/mraa/src/mraa.c

The added -I/usr/include will cause the wrong headers to be included and compilation will fail.

Erikvv commented 5 years ago

This is fixed when I remove line https://github.com/intel-iot-devkit/mraa/blob/0a12c5a0177f9fa8e7c4c564e70a65c4a0bb81af/CMakeLists.txt#L143

tingleby commented 5 years ago

When cross compiling, you might need to specify a cmake toolchain file.