Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Cross-compilation with MXE

2 posters

Go down  Message [Page 1 of 1]

1Cross-compilation with MXE Empty Cross-compilation with MXE Fri Nov 12, 2021 1:20 pm

feri



I would like to try to compile for windows with Mxe.
Just install Qtbase or is Qt5 necessary?
Do I have to compile the sources or can I install the binaries,
because i tried with binaries but i can't get it to work.
I found this procedure with sources to be correct:

1) git clone -b stable https://github.com/mxe/mxe.git

2) apt-get install \
   autoconf \
   automake \
   autopoint \
   bash \
   bison \
   bzip2 \
   flex \
   g ++ \
   g ++ - multilib \
   gettext \
   git \
   gperf \
   intltool \
   libc6-dev-i386 \
   libgdk-pixbuf2.0-dev \
   libltdl-dev \
   libssl-dev \
   libtool-bin \
   libxml-parser-perl \
   lzip \
   make \
   openssl \
   p7zip-full \
   patch \
   perl \
   python \
   ruby \
   sed \
   unzip \
   wget \
   xz-utils

3) cd mxe && make MXE_TARGETS = x86_64-w64-mingw32.shared MXE_PLUGIN_DIRS = plugins / gcc10 qt5

4) export PATH=/usr/bin:$PATH

5)  / usr / i686-pc-mingw32 / qt / bin / qmake && make (To compile from the terminal)

Configure Qt Creator
Qt Creator is a fully-featured IDE for developing Qt applications. If you choose, you can build a Windows executable from
within Qt Creator simply by calling your cross-compiled qmake tool instead of the default qmake tool.
Open the Build Settings panel for your project and add a new Release configuration. Under Build Steps, remove the
qmake step and replace it with a Custom Process Step. Add the following parameters:
• Command: Path to the qmake tool generated by MXE ( /usr/i686-w64-mingw32.static/qt5/bin
/ qmake)
• Arguments: Path to your project's main file (% {CurrentProject: FilePath})
• Working directory: Where to place the executable (I use% {buildDir})
Make sure to change the Build directory and rename the configuration to something meaningful. Now, press Ctrl-B to try
building your project. Congratulations, you can now build Windows applications in Linux!

Greetings

2Cross-compilation with MXE Empty Re: Cross-compilation with MXE Fri Nov 12, 2021 4:18 pm

arcachofo

arcachofo

You need Qt5

Packages to install before compiling MXE depend on your distro.

How I do to compile MXE (never tried precompiled):
1- Clone git repo.
2- Install packages.
3- cd mxe && make MXE_TARGETS = x86_64-w64-mingw32.shared qt5

To compile simulide:
1- Open terminal in build directory, for example build_XX, then run:
2- export PATH=/path/to/mxe/usr/bin:$PATH
3- x86_64-w64-mingw32.shared-qmake-qt5
4- make

3Cross-compilation with MXE Empty Re: Cross-compilation with MXE Tue Dec 21, 2021 9:51 pm

feri



I tried to compile for Windows, it created the dir "build", "build \ objects", "build \ moc" with inside the files but the dir "release"
remained empty.
I got the following error:

build / objects / read_elf.o ../src/simavr/sim/read_elf.c
../src/simavr/sim/read_elf.c:27:20: fatal error: libelf.h: No such file or directory
compilation terminated.

When I installed Qt5 I also installed:
1) qt-unified-linux-x64-4.0.1-1-online.run (Qt 5.15.2)
2) sudo apt-get update
3) sudo apt-get install libqt5script5
4) sudo apt-get install qtscript5-dev
5) sudo apt-get install libelf-dev
6) sudo apt-get install gcc-avr
7) sudo apt-get install avr-libc
8] sudo apt install libqt5serialport5-dev
9) sudo apt-get install -y libqt5svg5-dev

If you can help me thank you.
Hello

4Cross-compilation with MXE Empty Re: Cross-compilation with MXE Tue Dec 21, 2021 11:46 pm

arcachofo

arcachofo

You installed libelf for your system.

The missing libelf is to compile simulide with mxe.
So you need libelf in mxe (the windows version).
If it is not there, you need to dowload and compile libelf with mxe and get libelf.a.

Then you need to link to libelf in SimulIDE.pro.
Currently it is configured for my setup:
libelf.a is in deps/ folder.
deps/lielf/ contains libelf source code (including headers)


Maybe this can be useful:
https://simulide.forumotion.com/t88-compiling-simulide-under-windows#503

5Cross-compilation with MXE Empty Re: Cross-compilation with MXE Wed Dec 22, 2021 12:50 am

arcachofo

arcachofo

I'm thinking about this issue...

Indeed nobody uses the functionality provided by libelf.
This is only used to load elf files and remote debug with gdb.
And it causes some headhaches and confusion.

So I removed this dependency in Rev 262.

Update to Rev 262 and you don't need libelf.

6Cross-compilation with MXE Empty Re: Cross-compilation with MXE Thu Dec 23, 2021 8:05 pm

feri



Well one less problem.
I still managed to get "libelf" to work, but now I get this error:

lrelease: could not exec '/usr/lib/qt5/bin/lrelease': No such file or directory
make[1]: *** [Makefile.Release runLrelease] Errore 1
make[1]: *** Attesa per i processi non terminati....
mv: impossibile eseguire stat di '../resources/translations/*.qm': File o directory non esistente

In my Ubuntu "/usr/lib /qt5/bin/lrelease" is located in "/usr/bin/ lrelease" path entered in the Path.
The code that generates this problem should be this line:

runLrelease.commands = lrelease ../resources/translations/*.ts;

I don't know how to make him change the path "/usr/lib/qt5/bin/" to "/usr/bin/".
Greetings

7Cross-compilation with MXE Empty Re: Cross-compilation with MXE Thu Dec 23, 2021 8:26 pm

arcachofo

arcachofo

lrelease: could not exec '/usr/lib/qt5/bin/lrelease': No such file or directory
make[1]: *** [Makefile.Release runLrelease] Errore 1
make[1]: *** Attesa per i processi non terminati....
mv: impossibile eseguire stat di '../resources/translations/*.qm': File o directory non esistente
This is compiling with mxe?
As I understand it should use mxe lrelease.. isn't it?

8Cross-compilation with MXE Empty Re: Cross-compilation with MXE Thu Dec 23, 2021 9:06 pm

feri



I have one in mxe here:

/home/feri/mxe/usr/i686-w64-mingw32.static/qt5/bin/lrelease

I copy /home/feri/mxe/usr/i686-w64-mingw32.static/qt5/bin/*.* to
/usr/lib/qt5/bin/ ?
Greetings

9Cross-compilation with MXE Empty Re: Cross-compilation with MXE Thu Dec 23, 2021 10:15 pm

arcachofo

arcachofo

I copy /home/feri/mxe/usr/i686-w64-mingw32.static/qt5/bin/*.* to
/usr/lib/qt5/bin/ ?
No.
Anything in mxe/usr/i686-w64-mingw32.static/ is for windows.
Dont move nothing out of there.

This should work without doing fancy things.

Not sure what is the problem. So let's start from the begining...
How are you compiling? explained step by step.

10Cross-compilation with MXE Empty Re: Cross-compilation with MXE Thu Dec 23, 2021 10:44 pm

feri



cd /build_XX

/home/feri/mxe/usr/i686-w64-mingw32.static/qt5/bin/qmake SimulIDE_Build.pro

make -j8

Greetings

11Cross-compilation with MXE Empty Re: Cross-compilation with MXE Thu Dec 23, 2021 11:38 pm

arcachofo

arcachofo

You are missing some steps:

To compile simulide:
1- Open terminal in build directory, for example build_XX, then run:
2- export PATH=/path/to/mxe/usr/bin:$PATH
3- x86_64-w64-mingw32.shared-qmake-qt5
4- make

EDIT In your case:

cd build_XX

export PATH=/home/feri/mxe/usr/bin:$PATH

i686-w64-mingw32.static-qmake-qt5

make -j8


EDIT2:
cd /build_XX is not correct in my opinion

12Cross-compilation with MXE Empty Re: Cross-compilation with MXE Fri Dec 24, 2021 8:09 pm

feri



It worked Cool
I modified "SimulIDE.pro"
replaced "lrelease ../resources/translations/*.ts" with
"/home/feri/mxe/usr/i686-w64-mingw32.static/qt5/bin/lrelease ../resources/translations/*.ts"
in my case.
Greetings

arcachofo likes this post

13Cross-compilation with MXE Empty Re: Cross-compilation with MXE Sat Dec 25, 2021 7:33 am

arcachofo

arcachofo

Nice you got it to work.

I'm thinking to switch to static build and I'm curious.
What size is the executable?

14Cross-compilation with MXE Empty Re: Cross-compilation with MXE Sat Dec 25, 2021 10:43 am

feri



simulide.exe 29.8 MB
It also seems faster than the Linux version, I run it in a virtual machine.
Greetings and Merry Christmas santa

15Cross-compilation with MXE Empty Re: Cross-compilation with MXE Sat Dec 25, 2021 9:00 pm

arcachofo

arcachofo

It also seems faster than the Linux version, I run it in a virtual machine.
You are probably compiling Linux version in debug mode.
It is much much slower than release version.

Release version is optimized for speed and debug version has 0 optimizations.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum