cross compiling a file to run on a linux platform
Hi Guys, I have a single board computer that I am using for a university project, which runs linux and currently has this installed. However the PC I am using for writing software is running windows and I am trying to write a simple program, something as trivial as "hello world" that can be written in windows and then compiled and transferred to the linux platform to be executed. However to be honest I don't have a clue how to do this. If anyone could offer any assistance on how to do this it would be greatly appreciated. Thanks
Tom |
If you have enough hard drive space, install a VM program (I use Sunś Virtual Box here). Install a Linux distribution (perhaps the same one used at school) in the VM program. Make sure to install all appropriate development packages. Write your software using the Linux installation in the VM. Windows is not affected, and you can check that your software works correctly in the environment for which it was intended.
HTH, |
Hi,
Welcome to LQ! To make things easier I would use a 'VM' (virtual machine). Get VMware, VirtualBox or whatever VM to use on the M$ based system to host a GNU/Linux. That way you could run, compile or whatever on the M$ host the Client GNU/Linux application. This way you could build on the GNU/Linux then move the build too your embed. :hattip: The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links! |
You basically can't use windows to make binaries for linux. It could work for some apps. Almost all command line apps have a chance but any gui's get out of the question unless the using a cross platform building like maybe qt.
It is as above you have to run in linux to have any hope of success. |
Quote:
If so a ANSI or OSI C program can be transferred as source and compiled there. In the case of "Hello World" it could even be build and verified on the Windows machine but the binary is worthless on a Linux machine. The OS and and the hardware are the two important properties (and in some cases the libraries also) in determining if an executable built on machine 'A' will be able to be run on machine 'B' (or if it needs to be build again for machine 'B'). Best to portability is to learn the standard language and code in it rather than using all of the non-standard stuff that many comanies add into their version of a language (to lock you into their build-chain and maybe even OS). |
Hi,
Quote:
Quote:
Do you think people at M$ are sitting at a 'PC' to compile the kernel? NO! As long as the libraries, compilers and development support the desired arch then there is no reason that a build could not be built on a host for a build for another machine. Sure the embed must support the kernel you are building. Heck, I was cross-compiling on a Z80 for a 8088 many years ago. With modern hardware the use of 'VM' can save the $$ for multi-platform development. This has opened to the masses the ability to utilize embeds without purchasing the IDE for the embed. Fortunately most embeds available to the populace are x86 based for the reason of software, hardware affordability. Sure there are other archs but most x86 entry systems are affordable, modifiable to the use of environments other than the manufactures. A lot the embeds manufactures use this too their advantage. Sure, a lot of major manufactures would not utilize this method but would use the tools from embed systems to develop for their hardware. Companies like Ford, GE or the like would most likely utilize Intel's embed and IDE for the desired development embed. But, Joe's Garage Shop, could use a GNU/Linux OS as a client via a 'VM' on a M$ host to develop for a embed. If the controller is exotic then one would be locked in to the manufactures tool-chain/IDE. :hattip: |
Quote:
the processor being used is the atmel AT91SAM9260 ARM core, should it be ok cross compiling from windows to this platform? |
Hi,
Nice little board. What's the single unit price? Quote:
What application do you have in mind? :hattip: EDIT: BTW, look at 'ARM architecture'. |
Hi, thanks for the quick response, I'm not too sure on the single unit price to be honest, because our university department ordered a small batch so that each project group could use one and this came straight out of our the department budget, sorry.
So with regards to your post above, yes I have the first step done. Currently I have a null modem cable connected to the device, which is linked to my windows pc. I can get the device to boot up as it has the linux kernel and u boot already installed. I can also access the file system and navigate around the system using ls, cd commands etc. (these are about the only commands I know!) So basically this is where I get stuck... If I was doing this with a windows application and say a microchip PIC then I would write my c file, download the microchip compiler which would convert my c file to a hex file then program this to the device. I assume this is a similar process as to what I need to do here, but due to my non-existant linux knowledge I don't know where to go. If I wrote a basic c file in a text editor and saved it as .c file, I then cross compile it? How do I then transfer this to the device and in which location would I put it in order for it to run once the device boots up? |
Hi,
I was just curious about the single unit price. Most of the units are in the $40-$80 range. It's great the department has the project budget to cover the cost(s). While I was still at the University years ago, my budgets for senior projects was rather limited until we got sponsors for the projects. Another time & story. As for the SBC you can still work on a bench machine and transport the programs to the embed. It sounds like you have a PC terminal linked to the embed system. Your SBC has Ethernet so why not use that? You could 'ssh' to the embed and work. You could 'scp' any data or information. The compile sessions would be a lot faster on a desktop PC rather than the embed. :hattip: |
Hi -
To add my $0.02 - 1. As some people noted, you *can* cross-compile for the ARM on Windows. That's what the Windows CE SDK does. You can also cross-compile for ARM/Linux on Windows. But I wouldn't. 2. Your best bet is to cross-compile on a PC/Linux for your ARM/Linux. One way is to install Linux on a PC. More convenient for you would be to install Linux on a *virtual PC* (like VMWare or VBox), then run your "Virtual Machine" (VM) under Windows. Personally, I prefer VMWare. But VBox should be completely satisfactory, too. Both are available for Windows, both are free. VMWare Server and VMWare Player are both free downloads: http://www.vmware.com 3. You don't even have to install Linux on the VM yourself - there are lots of free downloadable images ("Virtual Appliances") you can get. For example: http://www.thoughtpolice.co.uk/ 4. Your next big problem after deciding on a development OS (again, I recommend Linux, running under a VM) is setting up your cross-compiler tool chain for ARM/Linux. It looks like Glomation already has everything you need available as free downloads on their web site: http://www.glomationinc.com/support.html 5. The final step is learning how to actually USE the toolchain. Two books I'd heartily recommend: get either or both of them: Building Embedded Systems (O'Reilly): http://www.amazon.com/Building-Embed...dp/0596529686/ Embedded Systems Primer (Hallinhan): http://www.amazon.com/Embedded-Linux...dp/0131679848/ 'Hope that helps .. PSM |
hi, I know people have suggested installing a linux distribution, but a lot of the time I am using university computers and cannot do this and so at the minute I am using windows. I have made some progress with this. I am using cygwin and a cross compiler toolchain from GNUARM called GCC 4.1. I have installed this and can compile my .c file into a .out file. I am then transferring the file with a USB stick. However when i come to run the file with the command ./a.out I get the following message...
/mnt/usb/ # ./a.out Illegal instruction I think this could be due to the compiler not compiling correctly or being the wrong one, but am not completely sure. If anyone could help with this then that would be great. |
Quote:
Try the google search: http://www.google.com/linux?complete...in&btnG=Search For links related to the ARM cross compiler tool chain. It takes more than a compiler to develop on a machine and deploy on another type of machine. |
All times are GMT -5. The time now is 10:51 AM. |