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

macOS build #135

Open
tomascern opened this issue Oct 8, 2020 · 16 comments
Open

macOS build #135

tomascern opened this issue Oct 8, 2020 · 16 comments
Assignees

Comments

@tomascern
Copy link

Hello, I have problem building the AirspaceConverter on my Mac (macOS Catalina 10.15.6). I think I have all the dependencies installed. Here is the error:

Building everything for macOS ...
Building AirspaceConverter shared library and CLI executable ...
Compiling: src/SeeYou.cpp
Compiling: src/OpenAIP.cpp
src/SeeYou.cpp:368:39: error: loop variable 'pair' has type 'const std::pair<int, Waypoint *> &' but is initialized with type 'std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<int, Waypoint *>, std::__1::__tree_node<std::__1::__value_type<int, Waypoint *>, void *> *, long> >::value_type' (aka 'pair<const int, Waypoint *>') resulting in a copy [-Werror,-Wrange-loop-analysis]
        for (const std::pair<int,Waypoint*>& pair : waypoints) {
                                             ^
src/SeeYou.cpp:368:7: note: use non-reference type 'std::pair<int, Waypoint *>' to keep the copy or type 'const std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<int, Waypoint *>, std::__1::__tree_node<std::__1::__value_type<int, Waypoint *>, void *> *, long> >::value_type &' (aka 'const pair<const int, Waypoint *> &') to prevent copying
        for (const std::pair<int,Waypoint*>& pair : waypoints) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/SeeYou.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: Failed to compile shared library and CLI executable.

Could you please help me?

@alus-
Copy link
Member

alus- commented Oct 9, 2020

Hi, thank you for reporting this problem.
I don't have anymore a mac so I did not realized about it. Apparently this occurs while compiling with clang.
Therefore I'm also unable to check if a possible solution would actually work.
Anyway I would try to replace:
for (const std::pair<int,Waypoint*>& pair : waypoints) {
with:
for (const auto& pair : waypoints) {
Let me know if works.

@tomascern
Copy link
Author

I changed it as suggested and made some additional changes, but I am still unable to build the tool. Now I have this error:

Building everything for macOS ...
Building AirspaceConverter shared library and CLI executable ...
make: Nothing to be done for `all'.
Building AirspaceConverter Qt GUI ...
Could not find mkspecs for your QMAKESPEC(macx-clang) after trying:
	/usr/local/etc/qt4/mkspecs
Error processing project file: ../AirspaceConverterQt/AirspaceConverterQt.pro
ERROR: Failed to run qmake.

Qt4 should be installed just fine, I am using it for some own projects.

@alus-
Copy link
Member

alus- commented Oct 9, 2020

Thank you for trying.
So now were you able to compile at least the CLI?
What other changes you made? Again using auto?

It seems that it is unable to find qmake or some other Qt tools .
I assume that you followed the instruction in the readme for compiling on Mac...
If you just type qmake what happens?
The build script is expecting to be able to call qmake...

I would search on some Qt forum about this problem...

@alus-
Copy link
Member

alus- commented Oct 9, 2020

The other thing you can try is to open the Qt project:
AirspaceConverterQt/AirspaceConverterQt.pro
with QtCreator and to try to compile it from there.

@tomascern
Copy link
Author

qmake works, when I write qmake, it prints its help. CLI is compiled , but not working:

dyld: Library not loaded: /usr/local/lib/libairspaceconverter.dylib
  Referenced from: /Users/tomascerny/Downloads/AirspaceConverter/Release/./airspaceconverter
  Reason: image not found

Unfortunately I am not able to build it with QtCreator, I have problem with configuration of the project ("No suitable kits found").

@efa
Copy link
Collaborator

efa commented Oct 9, 2020

about CLI not working, seems related to the linker does not find something.
We recently changed a linker parameter to let find shared object in executable directory, maybe it work on Linux but not on MacOS.
Just to be sure, please try reverting the change, in Makefile remove:
'-Wl,-rpath,$$ORIGIN'
from LFLAGS line:
LFLAGS = -lzip -lboost_system -lboost_filesystem '-Wl,-rpath,$$ORIGIN'
then
$ make clean
$ make

@alus-
Copy link
Member

alus- commented Oct 9, 2020

For building on macOS the script macOS/makeApp.sh (which it will have anyway to be adapted with the right location of Qt libraries on your machine) it is attempting put and link all the required libraries in the app bundle.
It can be that the changes introduced recently have broken this.
It is a matter of using otool to find where the executable is looking for the library and fix it to the right location with install_name_tool.
If I would have a Mac available I would be happy to fix this.

@alus-
Copy link
Member

alus- commented Oct 9, 2020

"No suitable kit found" in QtCreator it could mean that the Qt development environment it is not completely installed.
OK qmake seems there but mkspecs seems missing.

@tomascern
Copy link
Author

about CLI not working, seems related to the linker does not find something.
We recently changed a linker parameter to let find shared object in executable directory, maybe it work on Linux but not on MacOS.
Just to be sure, please try reverting the change, in Makefile remove:
'-Wl,-rpath,$$ORIGIN'
from LFLAGS line:
LFLAGS = -lzip -lboost_system -lboost_filesystem '-Wl,-rpath,$$ORIGIN'
then
$ make clean
$ make

I tried it, but I have the same result. It is looking for the dylib in wrong location.

Tomas-MacBook-Pro-2:Release tomascerny$ ./airspaceconverter 
dyld: Library not loaded: /usr/local/lib/libairspaceconverter.dylib
  Referenced from: /Users/tomascerny/Downloads/AirspaceConverter/Release/./airspaceconverter
  Reason: image not found
Abort trap: 6
Tomas-MacBook-Pro-2:Release tomascerny$ ls
Airfield.o			OpenAir.o
Airspace.o			Polish.o
AirspaceConverter.o		RasterMap.o
CSV.o				SeeYou.o
Geometry.o			Waypoint.o
KML.o				airspaceconverter
OpenAIP.o			libairspaceconverter.dylib

@tomascern
Copy link
Author

"No suitable kit found" in QtCreator it could mean that the Qt development environment it is not completely installed.
OK qmake seems there but mkspecs seems missing.

Actually, folder /usr/local/etc/qt4/mkspecs exists, but macx-clang is in /usr/local/etc/qt4/mkspecs/unsupported

@efa
Copy link
Collaborator

efa commented Oct 10, 2020

dyld: Library not loaded: /usr/local/lib/libairspaceconverter.dylib
Referenced from: /Users/tomascerny/Downloads/AirspaceConverter/Release/./airspaceconverter

seems MacOS linker look for *.dylib only in "/usr/local/lib".
Please try to install the fresh binary and shared object with:
$ make install
then the CLI should work

@alus-
Copy link
Member

alus- commented Oct 11, 2020

Yes exactly, I was about to say exactly the same, if you just run make install from the root of the project you should be able to have at least the CLI installed on your system so then usable simply calling airspaceconverter.

If, instead, you want to run AirspaceConverter from a specific folder together with the library you have to tell him that he can find the library in the same folder and not in /usr/local/lib/. It should be something like this using install_name_tool:
install_name_tool -change /usr/local/lib/libairspaceconverter.dylib @executable_path/libairspaceconverter.dylib ./airspaceconverter

Regarding all the Qt stuff and tools, sorry but, without the availability of a Mac I'm unable to help you at the moment. I remember that I had all the Qt stuff installed in my home so the various scripts in /macOS are looking for Qt libraries there...

@tomascern
Copy link
Author

Thank you, at least CLI now works.

@efa
Copy link
Collaborator

efa commented Jan 2, 2021

Could not find mkspecs for your QMAKESPEC(macx-clang) after trying:
/usr/local/etc/qt4/mkspecs

QT4 has not the target 'macx-clang', only QT5 has it.

$ ls -l /usr/share/qt4/mkspecs | grep macx-clang
$ ls -l /usr/lib/x86_64-linux-gnu/qt5/mkspecs | grep macx-clang
drwxr-xr-x  2 root root  4096 set 26 14:44 macx-clang

I saw that on my Linux system, but I think this is the trouble.

With QT4 only, the target that may work can be:
darwin-g++
macx-g++
macx-llvm
macx-xcode

Note: I can (cross)compile 0.3.7 code with clang without the errors in SeeYou.cpp

@alus- alus- added this to the 0.3.8 milestone Jan 17, 2021
@efa
Copy link
Collaborator

efa commented Feb 16, 2021

just before build, try:
$ export QT_SELECT=qt4 # switch to QT4
OR
$ export QT_SELECT=qt5 # switch to QT5
and report if you still get error with QT4 or QT5
See also: #143

@efa
Copy link
Collaborator

efa commented Mar 6, 2021

please note that I just cross-built the version 0.3.7 for macOS on Linux.
The DMG package is on download page:
https://www.alus.it/AirspaceConverter/download.php
while Makefiles and build stripts are merged in current sources, see:
#147

@alus- alus- modified the milestones: 0.3.8, 0.3.9 Apr 20, 2021
@alus- alus- removed this from the 0.3.9 milestone Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants