Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile JAERO on MacOS #44

Open
afiskon opened this issue Dec 25, 2019 · 17 comments
Open

How to compile JAERO on MacOS #44

afiskon opened this issue Dec 25, 2019 · 17 comments

Comments

@afiskon
Copy link

afiskon commented Dec 25, 2019

I managed to build JAERO on MacOS. There were a few problems in a process, that I would like do describe here.

Here is how I did it.

  1. Download QT and QTCreator (open source versions): https://www.qt.io/download-qt-installer This will take a while.
  2. Download the source code of latest JAERO release https://github.com/jontio/JAERO/releases Personally I used https://github.com/jontio/JAERO/archive/v1.0.4.11.zip
  3. Extract the archive
  4. Edit JAERO.pro file, around line 38 add:
INCLUDEPATH += ../libacars-1.1.0/src
LIBS += -L/usr/local/lib

Also remove the following files from SOURCES list to avoid "duplicate symbol" errors:

../libacars-1.1.0/src/examples/decode_arinc.c \
../libacars-1.1.0/src/examples/adsc_get_position.c \
../libacars-1.1.0/src/examples/cpdlc_get_position.c \
../libacars-1.1.0/src/examples/media_advisory.c \

Finally, comment this line because you don't have this directory (it's outside of the archive):

# LIBACARS_PATH =$$PWD/../../libacars
  1. libcorrect should be installed, otherwise linker will not find it:
cd ../libcorrect
mkdir build
cd build
cmake .. -Wno-dev
make && make install
cd ../../JAERO
  1. libvorbis can be installed using Homebrew:
brew install libvorbis
  1. Run:
/Users/eax/Qt//5.12.6/clang_64/bin/qmake
make all
  1. Move JAERO.app to Applications

jaero screenshot

The application starts and seems to work, although I don't have an antenna yet to properly test it. The most difficult and time consuming part was to download QTCreator. If anyone is looking for a MacOS build: https://afiskon.ru/s/JAERO-1.0.4.11-MacOS-x64-build-by-afiskon.zip

@jontio
Copy link
Owner

jontio commented Dec 26, 2019

Thanks for that, I'm sure there will be others that will find this helpful. I thought it should work on a Mac but haven't got a Mac to test on. It's nice to see it running on a Mac.

@afiskon
Copy link
Author

afiskon commented May 8, 2020

Turned out there is also a slight difficulty if you want to use libaeroambe to decode voice. The library should be compiled according to README but before executing qmake libaeroambe.pro should be modified like this:

win32: LIBS += -L$$MBELIB_PATH/build/ -llibmbe.dll
linux: LIBS += -lmbe
# Add this line:
macos: LIBS += -L/usr/local/lib -lmbe

After compiling the library place it to the application folder under aeroambe.so name:

cp release/libaeroambe.dylib /Applications/JAERO.app/Contents/MacOS/aeroambe.so

Now the problem is that on MacOS applications are executed not from their path in /Applications directory, thus JAERO will not find aeroambe.so in current directory unless it's executed like this:

cd /Applications/JAERO.app/Contents/MacOS
./JAERO

In this case "Can't find or load all the libraries necessary for aeroambe. You will not get audio." message disappears.

@jontio
Copy link
Owner

jontio commented May 18, 2020

Ah I see. A solution might be getting the path of the JAERO executable add adding that to what is searched for. Currently what is looked for is...

QLibrary library("aeroambe.dll");
if(!library.load())library.setFileName("aeroambe.so");
if(!library.load())
{
    aeroambe_object_error_str="Can't find or load all the libraries necessary for aeroambe. You will not get audio.";//library.errorString() is a usless description and can be missleading, not using
    ambe=new QObject;
    ambe->setObjectName("NULL");
}

So maybe...

QLibrary library("aeroambe.dll");
if(!library.load())library.setFileName("aeroambe.so");
if(!library.load())library.setFileName(QDir::currentPath()+"/aeroambe.dll");
if(!library.load())library.setFileName(QDir::currentPath()+"/aeroambe.so");
if(!library.load())
{
    aeroambe_object_error_str="Can't find or load all the libraries necessary for aeroambe. You will not get audio.";//library.errorString() is a usless description and can be missleading, not using
    ambe=new QObject;
    ambe->setObjectName("NULL");
}

https://doc.qt.io/qt-5/qdir.html#currentPath says QDir::currentPath() returns the path that the program is in if QDir::setCurrent() is not called. You might have to add #include <QDir>

I'll add that to the next release if that works for you.

@Vinz87
Copy link

Vinz87 commented Sep 13, 2020

@afiskon tried the linked compiled app, but crashed at startup on macOS High Sierra. Is there a minimum version of macOS required?

@afiskon
Copy link
Author

afiskon commented Sep 15, 2020

@Vinz87 I'm afraid I have little experience of developing for MacOS.... My best guess is that it requires some libraries that were not included to .app

@mahtin
Copy link

mahtin commented May 1, 2021

I would add an edit to step 5 libcorrect should be installed, otherwise linker will not find it: above as a download is needed for this to work on a Mac.

$ git clone git@github.com:quiet/libcorrect.git
Cloning into 'libcorrect'...
...
$ cd libcorrect/
$ mkdir build && cd build && cmake .. && make && make install
...
-- Configuring done
...
[ 73%] Built target correct
...
-- Installing: /usr/local/lib/libcorrect.dylib
...
$ 

Then all is good!

@jontio
Copy link
Owner

jontio commented May 1, 2021

I don't have access to a Mac so can't test things out. GitHub has something called GitHub actions that allow building for Mac on their servers (macOS Big Sur 11.0 and macOS Catalina 10.15 are currently being used) , you tell it how to build the thing and it will build it for you. It would be nice if someone who has a Mac could put together a build script for GitHub actions to add Mac OS. Here is the current Linux one https://github.com/jontio/JAERO/blob/master/ci-linux-build.sh which could be used for a guide as to how to make one suitable for Mac. I'm not sure how many commands are the same on Mac and Linux but I would think quite a few of them would be the same so someone with a Mac should be able to relatively easily modify for Mac OS.

@lawendel
Copy link

I followed the instructions but qmake fails when qmqtt module is not found. I thought it might be a variation with respect to 1.0.4.11 built in 2019 and tried it. But that fails due to an audio function whose syntax must have changed when qt5 became qt6 (which I have). I’ll try to install the qmqtt module, but I don’t know what to do with the function. Can I ask for this MacOS how-to to be updated to the new QT reality? It’s beyond my overall skills. Thanks!

@mahtin
Copy link

mahtin commented Sep 25, 2022

I'll comment one thing you mentioned; however, it's not your core issue.

... changed when qt5 became qt6 ...

Go back and install qt5 (and uninstall qt6) if you can and try again. I've had so many issues with various open source projects that won't easily compile with qt6.

As I said, that may not be your core issue. Good luck!

@lawendel
Copy link

Thank you mahtin, that's what I intended to do as well. With qt5 qmake all went as far as:

warning: directory not found for option '-L/Users/lawendel/JAERO/JAERO-1.0.4.11/JAERO/../../libacars/build/src/libacars'
ld: library not found for -lacars
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [JAERO.app/Contents/MacOS/JAERO] Error 1

"-lacars" reference is something I've already seen while compiling (successfully) dumpvdl2 or acarsdec. In JAERO.pro, it is referenced in:

#in windows use the dynamic lib rather than the static one even when stattically compiling
win32 {
LIBS += -lacars.dll
} else {
LIBS += -lacars
}

I simply tried to comment it out, but after this make all stopped at

ArincParse::try_acars_apps(ACARSItem&, la_msg_dir) in arincparse.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [JAERO.app/Contents/MacOS/JAERO] Error 1

so I suspect I won't go anywhere near my building goals on a M1 machine with no significant help

Any suggestion or positive build stories?

Andy

@lawendel
Copy link

If I may add something, having perused jontio link to a bash script for generating a Linux binary, maybe only a similar approach for MacOS on M1 would do. He suggests it shouldn't be difficult to adapt it to MacOS terminal commands, but it's far beyond my capacity.

https://github.com/jontio/JAERO/blob/master/ci-linux-build.sh

For instance I suppose one could go through every dependency installed with "apt-get" and build or brew each one, but than there would be problems with linking.

Sending over an SOS...

Andy

@mahtin
Copy link

mahtin commented Sep 26, 2022

@lawendel - my thoughts ...

my building goals on a M1 machine

OH! I missed the M1 part of this. Yeah - that changes things; but sometimes not in a bad way. I still keep an Intel Mac just because some thing still only work on that platform. But I think you're ok. Read on.

When it comes to paths, brew installs are in a different place on an M1 arch vs Intel arch. On the M1 it's /opt/homebrew/{bin,lib,etc} and on Intel it's the more boring /usr/local/{bin,lib,etc}. This is outlined in Homebrew/brew#9177 and simple means you may need to add /opt/homebrew where you see /usr/local in various files (Makefile's etc). Don't remove /usr/local, just add /opt/homebrew before it on what : separated or -L list you have. I'll admit, I did my JAERO work on Intel box, but I guess I should try on this M1 and share your pain.

ld: library not found for -lacars

Wait a second - that library is within the JAERO build. So that's not the fully the issue above. Do you see the error:

warning: directory not found for option '-L/Users/lawendel/JAERO/JAERO-1.0.4.11/JAERO/../../libacars/build/src/libacars'

undoing the -L path, you'll see ...

/Users/lawendel
        JAERO
                JAERO-1.0.4.11
                        JAERO
                libacars
                        build
                                src
                                        libacars

So I'm guessing that you didn't build the libacars portion yet. Or you installed it in a different directory. Either way, make sure that when you are building JAERO that your relative path is ../../libacars to where you installed libacars. If you didn't install it yet,, then that's needed. See https://github.com/szpajder/libacars

... having perused jontio link to a bash script for generating a Linux binary, maybe only a similar approach for MacOS on M1 would do ...

It's not that hard, both MacOS and Linux share the same bash syntax and the command difference is outlined in my MacOS build commands response above.

Hope that helps.

@lawendel
Copy link

That sounds extremely helpful, thanks a lot! Before trying to follow your hint let me confirm libacars (libacars-2, actually) was installed, indeed following szpajders guidelines, in order to build Tomasz's decoder for Acars.

@mahtin
Copy link

mahtin commented Sep 26, 2022

Yes - I'm sure you did download it and install it .. but was it built and installed within the right place? The -L flag (which is shown in your build error listing) says that it's not quite correct. See my directory/folder free above.

@lawendel
Copy link

I'm deeply ashamed of my lack of Unix literacy... I do find both libacars.h and libacars.pc.in in this path:

/Users/lawendel/JAERO/JAERO-1.0.4.11/libacars-1.1.0/src/libacars

As per Tomasz directions, a "libacars" folder containing libacars.h was installed - during build - in this path /usr/local/include/libacars-2

Now it looks like I'm even more confused than the make command!

@mahtin
Copy link

mahtin commented Sep 26, 2022

I think if you do this, you will get a good setup. You placed/build libacars in the wrong folder.

cd /Users/lawendel/JAERO
mv JAERO-1.0.4.11/libacars-1.1.0 libacars

Then go back into the JAERO build folder and try again.

I could be wrong; however, I think this may work.

@lawendel
Copy link

I'm so grateful for your kind help, I see your rationale nut unfortunately your suggestion did not work, the compiler is still warning about not being able to locate libacars. I thought again about all this situation, prompted by your observation on my successful (Iso I believed) attempt to build szpajder's libacars for his acars-decoder. My current failures to make of JAERO a fully fledged app, makes me reflect that qmake is complaining about a source code, not a binary! It still doesn't explain why it cannot find a source in a location which seems quite obvious to me, but it prompted me to search for the .dylib files that a supposedly successful build would have placed somewhere. And indeed there they was, both in the folder in which I had git cloned szpajder's code in my home directory:

~/libacars/build/libacars

and in /usr/local/lib

I can list libacars-2.dylib and libacars-2.2.dylib.

Only at that point I realized that szpajder's notes on building libacars for MacOS in the readme.md file were originally yours!

In szpajder/libacars#11 you warned about the need to brew-install cmake while avoing a final Linux command to install the compiled libraries. Szpajder on the other hand acknowledged that he was going to update the readme.md accordingly.

So far so good, as I mentioned above, this tells me I'd better to check if acarsdec (which seems to be working nicely) is indeed making good use of libacars. But doesn't explains why libacars sources included in JAERO are not properly recognized.

Unless... One more thing I've just realized is that szpajder profile in GitHub hosts as a project a personal fork of jontio JAERO. This fork, according to szpajder "switches to more generic libacars API, drop ARINC622-specific calls".

Now my final question for you is the following: what if I substitute this fork for jontio original 1.0.4.11 source, while keeping to follow afiskon guidelines and his mods for JAERO.pro project file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants