[zeromq-dev] Cross compiling for STM32MPU - ARM

Venkat Krishna venkat.krishna at intimetec.com
Fri Nov 10 04:55:34 CET 2023


Hi Francesco,

Thanks much for your reply, I went through the automake docs and figured that I was only missing the --build option. After that it worked fine.

I've a question that is not related to zmq itself but cross-compiling the pyzmq library. I apologize if it's not the right place to ask but if there's anything that someone could help me with, that would be really appreciated.

Actually, the requirement here is, there are two apps, one in C and one in Python that runs in the STM32 ARM-cortexa7 board and they have to communicate with each other. For the C app to use libzmq, I was able to cross compile and it's working fine on the board. When I'm trying to cross compile pyzmq, I'm facing quite a lot of issues.
 This is one of them - https://stackoverflow.com/questions/77420874/cross-compiling-pyzmq-fails-because-the-setup-picks-up-the-x86-compiler-automati?noredirect=1#comment136505142_77420874 But this was fixed by my colleague @Mohanashree U.<mailto:mohanashree.u at intimetec.com> We did a lot of changes in the environment to fix this but now we lost the track of changes and we are not able to cross-compile the library again.

But when we were able to compile and did a pip install .​ from the built folder, we took the .whl file, copied it to our board and installed it there, the import zmq statement was failing saying cython is not compiled.

If anyone has compiled the pyzmq for an 32bit ARM processor before, kindly share your knowledge. I appreciate your consideration and the time!

Thanks,
Venkat


________________________________
From: Francesco <francesco.montorsi at gmail.com>
Sent: Tuesday, October 31, 2023 5:36 PM
To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
Cc: Venkat Krishna <venkat.krishna at intimetec.com>
Subject: Re: [zeromq-dev] Cross compiling for STM32MPU - ARM

Hi Venkat, I suggest you read the page: https: //www. gnu. org/software/automake/manual/html_node/Cross_002dCompilation. html which describes how to do a cross-compiler build of a project using Automake in general (e. g. you're missing the --build

Hi Venkat,

I suggest you read the page: https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html<https://urldefense.com/v3/__https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html__;!!EF_awOfeuQ!LfEDBVsCApDO-40VPeC_rOkp8eN5mey_3YylGf7vHJaUEiw4a19GYLyXQUsQdJF01U8IaJFc8BPiPPH8qKZtMRM7QqTbme9P$>
which describes how to do a cross-compiler build of a project using Automake in general (e.g. you're missing the --build option).
It seems that all the compiler errors you're having are not related at all to libzmq.

My suggestion is for you as exercise/test to first cross-compile a simple helloworld application that uses automake (you can follow automake tutorials on the web to create such simple app).
Once you get that cross-compiled, you can try cross compiling libzmq

HTH,
Francesco



Il giorno mar 31 ott 2023 alle ore 08:37 Edwin van den Oetelaar <edwin at oetelaar.com<mailto:edwin at oetelaar.com>> ha scritto:
ChatGPT4 suggest using --with-sysroot and using the correct -I flags for pointing to the correct include directories eg:

./configure --host=arm-linux-gnueabihf --with-sysroot=/path/to/arm/sysroot

This is not a specific issue with zeromq but skills about using the tools of the trade.

Good luck,
Edwin



On Tue, 31 Oct 2023 at 04:32, Venkat Krishna via zeromq-dev <zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>> wrote:
Hi,

I'm trying to cross compile the libzmq for my arm stm32 unit and I'm facing some issues. I'm a noob so I don't know if I'm missing something. Any help is greatly appreciated!

I'm using Ubuntu 22.04 as my host, and I installed the `gcc-arm-linux-gnueabi, gcc-arm-linux-gnueabihf, g++-arm-linux-gnueabi, g++-arm-linux-gnueabihf packages and also the STM's sdk that comes with a set of cross compilers.

Here's what I've tried:

  1.  » ./configure --host=arm-none-linux-gnueabi CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-g++​
     *   When I run `make check after this, I get the following errors.
Making check in doc
make[1]: Entering directory '/home/venkatkrishna/Documents/libzmq/doc'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/home/venkatkrishna/Documents/libzmq/doc'
make[1]: Entering directory '/home/venkatkrishna/Documents/libzmq'
  CXX      src/libzmq_la-address.lo
In file included from /usr/arm-linux-gnueabihf/include/stdio.h:430,
                 from src/../include/zmq.h:32,
                 from src/precompiled.hpp:30,
                 from src/address.cpp:3:
/usr/include/x86_64-linux-gnu/bits/floatn.h:74:70: error: unknown machine mode ‘__TC__’
   74 | typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
      |                                                                      ^
/usr/include/x86_64-linux-gnu/bits/floatn.h:86:9: error: ‘__float128’ does not name a type; did you mean ‘__cfloat128’?
   86 | typedef __float128 _Float128;
      |         ^~~~~~~~~~
      |         __cfloat128
In file included from /usr/arm-linux-gnueabihf/include/c++/11/cwchar:44,
                 from /usr/arm-linux-gnueabihf/include/c++/11/bits/postypes.h:40,
                 from /usr/arm-linux-gnueabihf/include/c++/11/bits/char_traits.h:40,
                 from /usr/arm-linux-gnueabihf/include/c++/11/string:40,
                 from src/address.hpp:8,
                 from src/address.cpp:5:
/usr/arm-linux-gnueabihf/include/wchar.h:407:8: error: ‘_Float128’ does not name a type; did you mean ‘_Float32x’?
  407 | extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
/usr/arm-linux-gnueabihf/include/wchar.h:524:8: error: ‘_Float128’ does not name a type; did you mean ‘_Float32x’?
  524 | extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
In file included from /usr/arm-linux-gnueabihf/include/c++/11/cstdlib:75,
                 from /usr/arm-linux-gnueabihf/include/c++/11/ext/string_conversions.h:41,
                 from /usr/arm-linux-gnueabihf/include/c++/11/bits/basic_string.h:6608,
                 from /usr/arm-linux-gnueabihf/include/c++/11/string:55,
                 from src/address.hpp:8,
                 from src/address.cpp:5:
/usr/arm-linux-gnueabihf/include/stdlib.h:153:8: error: ‘_Float128’ does not name a type; did you mean ‘_Float32x’?
  153 | extern _Float128 strtof128 (const char *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
/usr/arm-linux-gnueabihf/include/stdlib.h:246:25: error: ‘_Float128’ has not been declared
  246 |                         _Float128 __f)
      |                         ^~~~~~~~~
/usr/arm-linux-gnueabihf/include/stdlib.h:331:8: error: ‘_Float128’ does not name a type; did you mean ‘_Float32x’?
  331 | extern _Float128 strtof128_l (const char *__restrict __nptr,
      |        ^~~~~~~~~
      |        _Float32x
make[1]: *** [Makefile:5481: src/libzmq_la-address.lo] Error 1
make[1]: Leaving directory '/home/venkatkrishna/Documents/libzmq'
make: *** [Makefile:8436: check-recursive] Error 1
  2.

I don't understand why it would pick the x86's include.

2. And then I read a thread on cross compiling for ARM for iPhone and it gave me an idea to use the STM's sdk compilers.
     *
a. I ran again the ./configure with the following flags - compilers and sysroot pointing to the STM sdk
./configure --host=arm-ostl-linux-gnueabi
CC=/home/venkatkrishna/Documents/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi arm-ostl-linux-gnueabi-gcc
CXX=/home/venkatkrishna/Documents/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++
CFLAGS="-O --sysroot /home/venkatkrishna/Documents/STM/sdk/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi"
CXXFLAGS="-O --sysroot /home/venkatkrishna/Documents/STM/sdk/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi"
LD=/home/venkatkrishna/Documents/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-ld
LDFLAGS="--sysroot /home/venkatkrishna/Documents/STM/sdk/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi"
AR=/home/venkatkrishna/Documents/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-ar
AS=/home/venkatkrishna/Documents/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-as
STRIP=/home/venkatkrishna/Documents/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-strip
RANLIB=/home/venkatkrishna/Documents/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-ranlib

b. When I run make check, I get an error saying the compiler doesn't work.
c. I tried using the compiler to compile a normal file and it fails with the message below.
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find crt1.o: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find crti.o: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find crtbegin.o: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find -lgcc: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find -lgcc_s: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find -lc: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find -lgcc: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find -lgcc_s: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find crtend.o: No such file or directory
/STM/sdk/sysroots/x86_64-ostl_sdk-linux/usr/libexec/arm-ostl-linux-gnueabi/gcc/arm-ostl-linux-gnueabi/12.2.0/ld: cannot find crtn.o: No such file or directory

         Again, I don't understand this because under my sdk usr folder there are two folders lib and libexec. The lib folder contains these object files but the ld is complaining          that it can't find.

Any help is greatly appreciated.

________________________________
This message and any attachments are confidential and intended solely for the addressees. Any unauthorized use or disclosure, either whole or partial, is prohibited. E-mails are susceptible to alteration. InTimeTec shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>
https://lists.zeromq.org/mailman/listinfo/zeromq-dev<https://urldefense.com/v3/__https://lists.zeromq.org/mailman/listinfo/zeromq-dev__;!!EF_awOfeuQ!LfEDBVsCApDO-40VPeC_rOkp8eN5mey_3YylGf7vHJaUEiw4a19GYLyXQUsQdJF01U8IaJFc8BPiPPH8qKZtMRM7Qq3qpfLs$>
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>
https://lists.zeromq.org/mailman/listinfo/zeromq-dev<https://urldefense.com/v3/__https://lists.zeromq.org/mailman/listinfo/zeromq-dev__;!!EF_awOfeuQ!LfEDBVsCApDO-40VPeC_rOkp8eN5mey_3YylGf7vHJaUEiw4a19GYLyXQUsQdJF01U8IaJFc8BPiPPH8qKZtMRM7Qq3qpfLs$>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20231110/0441be83/attachment.htm>


More information about the zeromq-dev mailing list