Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to setup arm-linux-gnuabihf cross-compile ?
How to setup arm-linux-gnuabihf cross-compile ? [message #1784545] Thu, 29 March 2018 08:07 Go to next message
Niels Huggins is currently offline Niels HugginsFriend
Messages: 3
Registered: March 2018
Junior Member
Hello,

I am trying to run cross-compile with arm-linux-gnuabihf for my developementboard with an armv7 (cortex-a9) with arm-ds-5 which is based on the eclipse enviroment. First im trying to run a simple "Helloworld" to validate the settings, but i have run into problems i somehow cannot overcome.

What i have done so far is to generate a linux with buildroot with a gdbserver to run on my board. Gdb-multiarch is installed on the host. The arm-linux-gnueabihf is installed on the host. I have compiled a Helloworld with the toolchain and was able to cross-compile with it on the board via commandline, so there shouldnt be any problem with these programs.
The ssh connection is setup as well and i am able to connect to the board properly.
Eclipse knows there is a arm-linux-gnueabihf and i can choose the toolchain inside eclipse (i used add_toolchain and select_default_toolchain to do this).
I created a new empty executable Project and added a sorce file for a Helloworld program (the same i used for command line test):

#include <stdio.h>

int main()
{
printf("Hello");

return 0;
}

The debug configurations for a c/c++ remote application point to the project and the executable hello file. The build configuration is set to Debug.
GDB debugger is set to gdb-multiarch ant the commant file is .gdbinit. Other settings are default.

So the first error i have is that the project doesnt get build correctly.
When running:

arm-linux.gnueabihf-gcc -o "Hello" ./hello.o

I get an error:

./hello.o: file not recognized: File format not recognized
collect2: error : ld returned 1 exit status
make: *** [Hello] Error 1

So when i run debug i will be asked if i want to proceed anyway and if i want to switch in debug view. In debug view i get a window which states "No source available for "__libc_csu_init() at 0x840c"" but I AM ABLE TO DEBUG in assembler.
I would like to debug directly from my sourcefile like normal people do, but i dont know how to accomplish that.

I am using ubuntu 14.04 64-bit the arm processor is 32-bit maybe there is some problem.
I would like to use eclipse under Windows, too, but i dont know how to setup mingw correctly (i think i need mingw).

So i basicly have 3 Problems in short:

1.) ERROR: ./hello.o: file not recognized: File format not recognized

2.) ERROR: No source available for "__libc_csu_init() at 0x840c

3.) Setting up MinGW for eclipse on win10

Any hints or solutions are highly appreciated. If anything is unclear give me a chance to be more specific. Although i belive i postet my thread in the correct location, please relocate this threat if i am mistaking.
Re: How to setup arm-linux-gnuabihf cross-compile ? [message #1784647 is a reply to message #1784545] Sun, 01 April 2018 02:54 Go to previous messageGo to next message
Seth Nowlin is currently offline Seth NowlinFriend
Messages: 30
Registered: October 2017
Location: Louisiana
Member
Hello,

I thought we needed to use minGW or Cygwin on Win 10. I found some interesting articles for building online on their CDT site. Personally, I have used Cygwin on Windows 10 w/ Eclipse Oxygen.

Seth

P.S. You can find more info. about what building is all about at https://help.eclipse.org/oxygen/index.jsp and then go to Tasks and Building Projects.
Re: How to setup arm-linux-gnuabihf cross-compile ? [message #1784648 is a reply to message #1784647] Sun, 01 April 2018 02:58 Go to previous messageGo to next message
Seth Nowlin is currently offline Seth NowlinFriend
Messages: 30
Registered: October 2017
Location: Louisiana
Member
Hello Again,

I know things get complicated. I tried to cross-compile w/ crosstools-ng on Ubuntu 16.04 and I have been unsuccessful so far. Are you following along in a book right now?

Seth

P.S. I was using a VMware workstation to attempt this idea but I am going to try again on an Ubuntu Desktop Distro next. I am cutting out the middle man.
Re: How to setup arm-linux-gnuabihf cross-compile ? [message #1784650 is a reply to message #1784648] Sun, 01 April 2018 06:39 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Read all of: https://help.eclipse.org/oxygen/topic/org.eclipse.cdt.doc.user/concepts/cdt_o_home.htm?cp=13


Install MinGW: https://sourceforge.net/projects/mingw/files/
They have an installer: https://sourceforge.net/projects/mingw/files/Installer/
Read all of the readme files.

The W64 vetsion: https://sourceforge.net/projects/mingw-w64/files/

MinGW support: https://sourceforge.net/projects/mingw/support?source=navbar
MinGW64 support: https://sourceforge.net/projects/mingw-w64/support?source=navbar

The ARM toolchain requires an extension.
This forum is for plain vanilla CDT issues.
While some ARM toolchain questions can be answered here,
in general, please direct them to the toolchain support forums (from links below).


Installing the GNU ARM Toolchain: https://gnu-mcu-eclipse.github.io/toolchain/arm/install/
Downloads: https://gnu-mcu-eclipse.github.io/downloads/
Follow the links there.

----

    o)File format not recognized
    You don't have an executable.
    Your build failed during the link step.

    ./hello.o: file not recognized: File format not recognized
    collect2: error : ld returned 1 exit status
    make: *** [Hello] Error 1


    The first line is the actual error.
    The second line says the linker stopped because of the error.
    The third line is from make and says the linker recipe returned an error during the creation of "Hello".

    How was hello.c (hello.cpp ?) compiled?
    It doesn't appear to be in the object format expected.
    Did you compile it with GCC instead of arm-linux.gnueabihf-gcc ?

    o) No source available for "__libc_csu_init() at 0x840c
    The debugger is stopping during the startup code.
    This comes with the builtin libraries.
    Most of these libraries don't come with source code.
    Your build failed during the link process so I'm surprised you have anything at all.

    o) MinGW supplies a compiler and linker that produces code which will run under Windows.
    It is highly unlikely such code will execute on your target machine.


Your problems appear to have begun during the compile step.
Your Eclipse project may be misconfigured.
Try making the same project for your host machine.
If it builds and runs then compare it to your ARM project.






[Updated on: Sun, 01 April 2018 13:01]

Report message to a moderator

Re: How to setup arm-linux-gnuabihf cross-compile ? [message #1784715 is a reply to message #1784650] Tue, 03 April 2018 07:34 Go to previous messageGo to next message
Niels Huggins is currently offline Niels HugginsFriend
Messages: 3
Registered: March 2018
Junior Member
First of all thanks for the replies i will work them through and give an update what has changed.

@Seth: No i dont have a book. Right now i am trying anything on the internet to accomplish this task. Unsuccessfull so far. I will read your link as soon as possible thanks.

@David: Thanks for the hint to the right forum.

Eclipse has not build an executable for me that is probably right. I have at some stage manually compiled with arm-linux-gnuabi-gcc from command line, that is how i got my executable.

I will read your links thank you. I will try to build hello for my host maschine and report

Re: How to setup arm-linux-gnuabihf cross-compile ? [message #1784750 is a reply to message #1784545] Tue, 03 April 2018 14:13 Go to previous messageGo to next message
Niels Huggins is currently offline Niels HugginsFriend
Messages: 3
Registered: March 2018
Junior Member
So i managed to setup the same project for the host machine and it works. Somehow some libs where included wrong so i had to delete these wrong libs. After that the Helloworld runs normally for the host.

The errors for the target machine remain the same but the changes i made were global so this is somehow a dead end.
Re: How to setup arm-linux-gnuabihf cross-compile ? [message #1784774 is a reply to message #1784750] Tue, 03 April 2018 22:32 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The only thing that needed to be different between the projects was the toolchain used.
AFAIK there is no global toolchain although there is a default one.
What do you mean by "global changes"?

Without specific info on what you actually have done, I don't think you'll get a resolution here.

UPDATE:

I installed the ARM toolchain from the links above.
I installed the ARM Plugin GNU MCU from the Marketplace.

I was able to compile and link a sample HelloWorld C++ ARM project without problems.
I don't have any ARM target hardware so I can't run it.

You might want to try a re-install (after an uninstall if necessary)
I suggest you get the ARM toolchain from
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
How to install: https://gnu-mcu-eclipse.github.io/toolchain/arm/install/

And install the Eclipse ARM plugin from the marketplace.
As suggested here: https://gnu-mcu-eclipse.github.io/downloads/




[Updated on: Wed, 04 April 2018 02:58]

Report message to a moderator

Previous Topic:can anyone good with eclipse look at my console error? There was no error before and no error in com
Next Topic:LIBPATH issue with GTK+ on AIX
Goto Forum:
  


Current Time: Thu Apr 25 00:46:59 GMT 2024

Powered by FUDForum. Page generated in 0.03009 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top