mraa icon indicating copy to clipboard operation
mraa copied to clipboard

Compiler swap messes up includes

Open Erikvv opened this issue 6 years ago • 2 comments

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 avatar Jun 30 '19 19:06 Erikvv

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

Erikvv avatar Jun 30 '19 19:06 Erikvv

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

tingleby avatar Jul 01 '19 22:07 tingleby