Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Cross-compiling Paho C libraries

Hello Ian and All,

I was just looking into cross-compiling the C libraries for an ARM/Linux target. It looks like it could work pretty easily, but the problem is that the Makefile is forcing the CC variable to "gcc" in all instances. What we want is to be able to use a cross-compiling variant, like "arm-linux-gcc", "arm-none-linux-gnueabi-gcc", or similar, as the user desires.

What looks to be simple and easy it to introduce a CROSS_COMPILE Make variable, which would normally resolve to an empty string for a host build, but could be set on the command line to specify a GCC prefix. In the Makefile, just assign all of the tools that are used to respect the prefix, like:
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
LD = $(CROSS_COMPILE)ld
 I would then, probably also want to direct the output to a specific location for this build. Maybe use the prefix to name a specific build directory. Something like:
ifndef blddir
  blddir = build/$(CROSS_COMPILE)output
endif
And then the library can be cross-compiled with:
$ make CROSS_COMPILE=arm-linux-
I tried this and it works nicely, but I was also cross-compiling from a Linux host. I assume that we would also need to set the target OS. Can that already be done by setting the TARGET_PLATFORM variable as well?

Thanks,
Frank



Back to the top