Makefile isn't working for cross compiling - linux

I'm trying to cross compile to an arm development board. The makefile is invoking the native (x86) compiler, but passing it options that only make sense to an ARM compiler. I have the beginning of my make file as:
ARCH = arm
CC = arm-Linux-gnueabi-gcc
The error I keep getting is: arm-linux-gnueabi-gcc error unrecognized command line option '-m64'

Related

cross-compile error while loading shared library

I have run gcc cross compiler from ubuntu(x86) to arm. this cross compiler works fine on ubuntu 14, and not I try in on ubuntu 18.
I tried to compile simple program
#include <stdio.h>
void main() {
printf("h\n");
}
gcc test.c -o test
When I compile it with gcc (to x86) all works fine, but when I compile it with cross compiler arm gcc I got error ...arm-buildroot-linux-uclibcgnueabu/4.*.*/cc1 : error while loading shared libraries: libmpfr.so.4 cannot open shared object file: No such file or directory
When I serach I can findlibmpfr.so.4 in the cross compiler path under /usr/lib
So even arm-gcc test.c -o test -L "<path_to_compiler>/usr/lib" got same error . and even export LD_LIBRARY_PATH=<path_to_compiler>/usr/lib didn't help

CMake Target Link Library G++ Flags conflict with OSX Clang

I am trying to write a single CMakeLists.txt file for C++ compilation on Linux with G++ and on OSX with Clang.
I want to use the Target Library flags -Wl,--start-group and -Wl,--end-group with G++, but these give an error when linking with Clang: ld: unknown option: --start-group
The only results I can find choose to just delete these flags on Mac copies, but that doesn't allow easy project migration from linux to OSX. I tried to make these statements CMAKE conditions, but those are treated as literal libraries which are not found:
eg: $<IF($<NOT:APPLE>)> -Wl,--start-group $<ENDIF($<NOT:APPLE>)>
produces: c++: error: $<IF: No such file or directory
Is there a way to conditionally edit in the CMAKE TARGET_LINK_LIBRARIES field?
I'd try this:
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(START_GROUP "-Wl,--start-group")
set(END_GROUP "-Wl,--end-group")
else()
set(START_GROUP "")
set(END_GROUP "")
endif()
Then just replace those options with ${START_GROUP} and ${END_GROUP}, and they will only be used with the GNU compiler.
Don't switch based on platform if it's really the compiler that matters. Otherwise, Clang users on Linux won't be able to build your project.

Unable to cross compiling linux kernel on eclipse

I am trying to compile Linux on Eclipse. I am compiling for x86 only but want to use my tool chain. I created a project as "File -> C Project -> Linux gcc" and gave the location of my Linux kernel. I right clicked on "Project -> Properties -> C/C++ build -> Settings" and changed GCC C compiler and linker and include path to my toolchain.
On C/C++ build, I replaced make with below command
make ARCH=x86 CC=/home/poky/build/tmp/sysroots/i686-linux/usr/bin/corei7-64-poky-linux/x86_64-poky-linux-
Now when I try to build, I am getting below error
make ARCH=x86 CC=/home/poky/build/tmp/sysroots/i686-linux/usr
/bin/corei7-64-poky-linux/x86_64-poky-linux- all
Building file: ../virt/kvm/arm/arch_timer.c
Invoking: GCC C Compiler
/home/poky/build/tmp/sysroots/i686-linux/usr/bin/corei7-64-
poky-linux/x86_64-poky-linux-gcc -I/home/poky/build/tmp/sysroots
/i686-linux/usr/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"virt/kvm/arm/arch_timer.d" -MT"virt/kvm/arm/arch_timer.d" -o "virt/kvm/arm/arch_timer.o" "../virt/kvm/arm/arch_timer.c"
../virt/kvm/arm/arch_timer.c:19:23: fatal error: linux/cpu.h: No such file or directory
#include <linux/cpu.h>
^
compilation terminated.
make: *** [virt/kvm/arm/arch_timer.o] Error 1
How can I cross compile Linux kernel on Eclipse? I want to use my own toolchain.
Your compiling works as it should but it seems that you haven't yet added all necessary include paths.
As the error msg already mentions, the compiler can't find linux/cpu.h
You can add additional include paths at: Project->Properties->C/C++ General-> Paths and Symbols

GCC keeps saying -mfpu=neon is an unrecognoized command

I am compiling code to run on an arm neon and the make files have the following command line included.
-mcpu=cortex-a9 -march=armv7 -mfpu=neon -DARM_NEON
The details of GCC version are as follows:
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
However when I try to compile, gcc keeps throwing the following error:
gcc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
gcc: error: unrecognized command line option '-mfpu=neon'
I am pretty sure that the code could be compiled previously. Though a long time ago. Could it be changes in version of GCC? or is it do with 32 bit and 64 bit compilers?
I was trying to cross compile for an arm processor on my intel x86_64 Ubuntu machine. I needed to add the configuration for the host in the makefiles and use arm-linux-gnueabihf-gcc instead of gcc.

Gcc compile hello.c for c6x

I compiled hello.c program for c6x architecture:
gcc-4.8 -o hello -march='c64x' hello.c
But It got an error: error: bad value (c64x) for -march= switch
Seem gcc can't recognize c64x architecture!
I am using Ubuntu 12.04 LTS & gcc-4.8 version.
Thank you!
-march=name
This specifies the name of the target architecture.
But in your case target is TI (c64x) board i.e its arm architecture. to compile your program for arm architecture you need cross-compiler. But you trying to compile on x86gcc native-compiler with option -march which is different from target target. i.e "gcc" is a native compiler. In your case it appears you are not working on an ARM host, thus "gcc" will not compile for ARM on x86.
so download the cross-compiler tool chain and then compile your program with your options.
cross compiler for ubuntu is here
http://www.filewatcher.com/m/gcc-c6x-linux-gnu-4.7.1-0.1.20120606.fc18.1.i686.rpm.10801432-0.html

Resources