NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Cross-Compile Eclipse Makefile Project

What are the possibilities to cross-compile a makefile project in Windows Eclipse to an RT Linux Target?

I have a Linux Embedded-C SDK came with example source files and makefiles that I would like to compile and run on a NI-9068. I have the NI's preconfigured Eclipse Luna installed and there is no problem writing software and building project with the internal builder (CDT), but I am struggling to configure the project to use an external make file for building.

I have created a very simple HelloWorld project consists a source file and a make file:

HelloWorld.c:

#include <stdio.h>

#include <stdlib.h>

int main(void) {

puts("Hello World");

return EXIT_SUCCESS;

}

Makefile:

all: HelloWorld.c

arm-nilrt-linux-gnueabi-gcc -O0 -g3 -Wall -c -fmessage-length=0 -mfpu=vfpv3 -mfloat-abi=softfp -v -o HelloWorldApp HelloWorld.c

To use the Makefile I had to select GNU Make Builder/Cross GCC, selected external builder and unticked the "Generate Makefiles Automatically". I configured it to use C:\MinGW\msys\1.0\bin\make.exe and C:\MinGW\bin\mingw32-make.exe, but none of them worked. Eclipse built the project without any error, but it does not run on the target:

"-bash: ./HelloWorldApp: cannot execute binary file"

Maybe I shoud use a different builder?

I am quite lost at this point as I am very new in building projects. I would appreciate if someone could point me to the right direction.

Thank you

Balazs

0 Kudos
Message 1 of 7
(4,935 Views)

The issue seems to be that your build or run configuration is attempting to run the resulting Linux binary (meant for running on your controller) on your Windows development machine

0 Kudos
Message 2 of 7
(4,492 Views)

Thank you for your reply.

That might be the issue, but I don't know how to target the controller in the build process. I am not sure if I am using the right builder, because it is the same MinGW builder that I used to compile for windows. Does it matter which builder is used even if I am using it with the NI's gcc compiler? Or the builder should be target specific as well? Where can I get the correct one?

0 Kudos
Message 3 of 7
(4,492 Views)

From what I recall(I don't often use Eclipse), you need to make sure that your Run and Debug configurations are set to be the "remote" flavors of those operations, as this will allow setting the target to execute on (using the targets defined in the Remote Explorer). There are plenty of excellent guides out there covering this topic, including the one put tighter by NI (http://www.ni.com/tutorial/14625/en/)

0 Kudos
Message 4 of 7
(4,492 Views)

Actually, I used that tutorial to compile and run my project in Eclipse, but that is all about using the internal builder, which generates makefiles automatically. That worked perfectly fine.

Mine question is how to build a project if I want to use my own makefile, instead of using the automatically generated one by Eclipse?

I know how to do that with other builder/compiler configuration, but I don't know how to do it with NI's gcc tools.

I am researching this topic for days now, and I have not find any guide on this.

0 Kudos
Message 5 of 7
(4,492 Views)

What I was suggesting was to use the guide for settings *other* than using the internal builder. Specifically the parts about running a program or debugging a program on the target.

0 Kudos
Message 6 of 7
(4,492 Views)

Correct me if I understand you correcly: you have compiled your code with cross compiler and then tried to run on host machine?

I just miss usage of scp or other tool to transfer compiled binary to the target.

As far as I remember, Eclipse has such option (to transfer bin) in Remote C/C++ perspective.

0 Kudos
Message 7 of 7
(4,492 Views)