mavlink / qgroundcontrol

Cross-platform ground control station for drones (Android, iOS, Mac OS, Linux, Windows)
http://qgroundcontrol.io
3.29k stars 3.62k forks source link

Xcode Build Guide #9846

Open soufi opened 3 years ago

soufi commented 3 years ago

Hello,

I'm trying to build the project with Xcode on Big Sur and Mojave and just couldn't succeed. In fact, I am able to generate the xcode project using the make xcode command, which is working great. Only problem is that I can't build the project on xcode. the build targets were generated automatically (by selecting, Automatically create schemes when prompted when imported the project) by xcode, and I'm using ALL_BUILD target. I'm not even sure if that's how I should be doing, I'm really just following my instinct here.... and here's some of the problems i'm facing right now :

On Big Sur I have the following :

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:33:5: Use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:33:25: Too few arguments to function call, expected 2, have 0

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:50:19: Use of undeclared identifier '__builtin_ia32_vec_init_v2si'

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:67:12: Use of undeclared identifier '__builtin_ia32_vec_ext_v2si'

...

And on Mojave here's what I have:

Apple Mach-O Linker (ld) Error Group

: "MockConfiguration::staticMetaObject", referenced from:
: "MockConfiguration::MockConfiguration(MockConfiguration*)", referenced from:
: "MockConfiguration::MockConfiguration(QString const&)", referenced from:
: "MockConfiguration::MockConfiguration(QString const&)", referenced from:
: "MockLink::staticMetaObject", referenced from:
: "MockLink::startGenericMockLink(bool, MockConfiguration::FailureMode_t)", referenced from:
: "MockLink::startAPMArduSubMockLink(bool, MockConfiguration::FailureMode_t)", referenced from:
: "MockLink::startAPMArduSubMockLink(bool, MockConfiguration::FailureMode_t)", referenced from:
....
: "MockLink::~MockLink()", referenced from:

: Linker command failed with exit code 1 (use -v to see invocation)

I couldn't find any guide for xcode builds, It's been weeks that I'm trying to investigate this but I can't seem to find any solution, so I hope to find some support here.

Thank you in advance.

louisrm commented 3 years ago

Hi! Here are two resources I found helpful: https://dev.qgroundcontrol.com/master/en/getting_started/ https://doc.qt.io/qt-5/ios.html

This is the basic process:

soufi commented 3 years ago

Hi @louisrm ! Thank you so much for your prompt response, and apologies for not getting back to you sooner.

I'm very new to Qt, so apologies in advance if I make some wtf/rtfm mistakes.

I followed your instructions, I can already tell that I wasn't using the qmake from Qt. I couldn't find Qt v5.12.6 available on Qt servers so I had to compile it myself. The generated folder didn't contain any iOS folder. Instead, I used the following in shadow compile mode:

/usr/local/Qt-5.12.6/bin/qmake ../qgroundcontrol.pro CONFIG+=WarningsAdErrorsOn

and it generated the following files in my build folder :

Makefile                 qmake_qmake_qm_files.qrc

Then I executed a simple make command in the build project which triggers a compilation of the project. I have a qgroundcontrol.app file in build folder (which is only executable from the machine that generated it, can't use it from other computers ...), and no xcode project was generated....sadly

I'm not sure how to get the iOS folder inside my Qt folder ? Is that the main reason i'm not having the outcome I should ? can't find anything about it in the qt-ios documentation.

What am I missing ?

Best,

soufi commented 3 years ago

I used the following command, and it's generating the .xcodeproj file now :

qmake -spec macx-xcode ../qgroundcontrol.pro CONFIG+=WarningsAsErrorsOn

But now I have the following issue when I build the xcode project:

Ld Debug/QGroundControl.app/Contents/MacOS/QGroundControl normal x86_64
    cd /Users/ec2-user/Documents/qgroundcontrol/build
    export MACOSX_DEPLOYMENT_TARGET=10.7
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -L/Users/ec2-user/Documents/qgroundcontrol/build/Debug -L/Users/ec2-user/Documents/qgroundcontrol/libs/Frameworks -L/Library/Frameworks -L/usr/local/Qt-5.12.6/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks -F/Users/ec2-user/Documents/qgroundcontrol/build/Debug -F/usr/local/Qt-5.12.6/lib -F/Users/ec2-user/Documents/qgroundcontrol/libs/Frameworks -F/Library/Frameworks -filelist /Users/ec2-user/Documents/qgroundcontrol/build/.xcode/QGroundControl.build/Debug/QGroundControl.build/Objects-normal/x86_64/QGroundControl.LinkFileList -mmacosx-version-min=10.7 -Xlinker -object_path_lto -Xlinker /Users/ec2-user/Documents/qgroundcontrol/build/.xcode/QGroundControl.build/Debug/QGroundControl.build/Objects-normal/x86_64/QGroundControl_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -stdlib=libc++ -headerpad_max_install_names -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,/usr/local/Qt-5.12.6/lib -F/usr/local/Qt-5.12.6/lib -lz -F/Users/ec2-user/Documents/qgroundcontrol/libs/Frameworks -F/Library/Frameworks -framework SDL2 -framework GStreamer -framework QtLocation -framework QtPositioningQuick -framework QtQuickControls2 -framework QtQuickWidgets -framework QtQuick -framework QtOpenGL -framework QtSvg -framework QtCharts -framework QtWidgets -framework QtMultimedia -framework QtGui -framework QtConcurrent -framework QtPositioning -framework QtQml -framework QtNetwork -framework QtSql -framework QtXml -framework QtTextToSpeech -framework QtSerialPort -framework QtTest -framework Security -framework Foundation -framework ApplicationServices -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL -Xlinker -dependency_info -Xlinker /Users/ec2-user/Documents/qgroundcontrol/build/.xcode/QGroundControl.build/Debug/QGroundControl.build/Objects-normal/x86_64/QGroundControl_dependency_info.dat -o /Users/ec2-user/Documents/qgroundcontrol/build/Debug/QGroundControl.app/Contents/MacOS/QGroundControl

ld: file not found: @rpath/lib/libgstnet-1.0.0.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)```

EDIT I resolved that problem by using the following to the command

qmake -spec macx-xcode ../qgroundcontrol.pro CONFIG+=WarningsAsErrorsOn LIBS+=-L/Library/Frameworks/GStreamer.framework/Libraries

Now i'm able to build the app and it works the machine. But I can't use it elsewhere because if I do, it crashes with the following :

Dyld Error Message:
  dyld: Using shared cache: 0C9EB0DE-F5CE-3AFC-8F08-0C6DB1E7FC44
Library not loaded: /Library/Frameworks/GStreamer.framework/Versions/1.0/lib/GStreamer
  Referenced from: /Users/USER/*/QGroundControl.app/Contents/MacOS/QGroundControl
  Reason: image not found