Unable to compile QGC 4.2.6 with Qt 5.15.2 on Windows for Android
-
I am attempting to develop an application for both the Windows and Android platforms. The Windows build is functioning correctly; however, when I attempt to build it for Android, I encounter the following error:
"/usr/bin/sh: line 1: C:UsersChris.LAppDataLocalAndroidSdkndk23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory"
I have use following dependencies
SDK: 12.0
NDK: 23.1.7779620 (r23b)
JDK: 21
QGCS: 4.2.6 / 4.2.8
Qt: 5.15.2
Configuration: Android Multi ABI
Compilers: Android Clang (C, arm, NDK 23.1.7779620) and Android Clang (C++, arm, NDK 23.1.7779620)
Platform Linker Flag: -target arm-linux-androideabi
Build Device: Desktop
ABIs: armeabi-v7a08:18:51: Starting: “C:\Users\Chris.L\AppData\Local\Android\Sdk\ndk\23.1.7779620\prebuilt\windows-x86_64\bin\make.exe” -j4
rcc D:/Projects/AewaGCS4.2.8/qgroundcontrol/qgroundcontrol.qrc
/usr/bin/sh: line 1: C:UsersChris.LAppDataLocalAndroidSdkndk23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory
rcc D:/Projects/AewaGCS4.2.8/qgroundcontrol/qgcresources.qrc
make: *** [Makefile:2413: armeabi-v7a/qrc_qgroundcontrol.obj] Error 127
make: *** Waiting for unfinished jobs…
/usr/bin/sh: line 1: C:UsersChris.LAppDataLocalAndroidSdkndk23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory
make: *** [Makefile:2504: armeabi-v7a/qrc_qgcresources.obj] Error 127
08:18:52: The process “C:\Users\Chris.L\AppData\Local\Android\Sdk\ndk\23.1.7779620\prebuilt\windows-x86_64\bin\make.exe” exited with code 2.
Error while building/deploying project qgroundcontrol (kit: Android Qt 5.15.2 Clang Multi-Abi)
When executing step “Make”
08:18:52: Elapsed time: 00:13. -
@Chris_Adam said in Unable to compile QGC 4.2.6 with Qt 5.15.2 on Windows for Android:
"/usr/bin/sh: line 1: C:UsersChris.LAppDataLocalAndroidSdkndk23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory"
Just by reading the error message:
The path is lacking a backslash after "C:". Most probably another one after "Users". Browse to yourclang++
executable and specify the correct path. -
@Axel-Spoerl Hello, thank you for your response. I have cloned the QGroundControl 4.2.6 version code and meticulously followed the instructions outlined in the QGC documentation. Utilizing Qt 5.15.2, I ensured that all necessary dependencies, including the SDK, JDK, and NDK, were properly installed. Upon opening the .pro file, I selected the QT Android Multi ABI configuration as instructed. However, during the compilation process of QGC, I encountered the following error:
/usr/bin/sh: line 1: C:UsersChris.LAppDataLocalAndroidSdkndk23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory
It appears that there is a path-related issue, despite not manually setting any paths. Upon inspection, the NDK and SDK paths within the configured kits appear to be correct, and there are no errors present within the kit configurations. It is puzzling why the path is not recognizing the slash. I suspect this could be attributed to a configuration discrepancy between Qt and Android. Your assistance in resolving this matter would be greatly appreciated.
-
Well we've upgraded to latest version of QT Creator 12.* (away from version 10 Community Edition) and of course QT Creator broke all of our settings we are unable to debug and (of course) there are crazy things going on like our friend above is having.
but with a different file:
"/usr/bin/sh: line 1: C:UsersDellAppDataLocalAndroidSdkndk22.1.7171670/toolchains/llvm/prebuilt/windows-x86_64/bin/llvm-objcopy: No such file or directory"Since our commercial license does not offer support you help would be appreciated.
All our QT settings looking good just like the fella's above.
It is also important to notice that now it seems QT Creator forces upon us LLDB instead of GDB and we've been unable to debug but that's a separate issue (isn't it).
Why do we say forcing? Well because after the update process completed all of our settings were GONE and that's what we've found. Everything gone. Including Android package deployment settings. Everything. Thanks Qt.
-
now it's not funny...
reinstalled QT 12, wiped everything out including registry entries , reinstalled everything including android sdk and ndk..and still same error...
@Axel-Spoerl any idea how to enforce proper path? In UI all looks good.
Tried enforcing through an explicit "NDK_DIR = C:\Users\Dell\AppData\Local\Android\Sdk\ndk\22.1.7171670"
entry in PRO file, still no luck
-
just wanted to point out that the error :"/usr/bin/sh: line 1: C:UsersChris.LAppDataLocalAndroidSdkndk23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory"
as according to my investigation, - it's not about clang++.exe missing at all.
It's about a file provided to clang++ and in my case the other utility missing!
Also, the the path is ALRIGHT.
It's just the concatenation mechanism involved during ERROR REPORTING IS BROKEN and not doing proper delimiting. Do not worry about that.
In my case QT Creator 12 messed up all the setting during upgrade including ABI/multi-ABI settings thus the error I was given because the armeabi-v7a was simply never built (because compiler changed, and of course Creator does not support multi-ABI builds in debug mode which nobody ever talks about) let newcomers pay for commercial support.
It's scary how QT for many many years has never managed to come up with solid integration between build components. I get it that there are multiple androids and stuff but we are talking basic deployment / build pipeline for two major mobile operating systems.
Now, I've been using QT for many years and it doesn't look good that me being a professional with decades in software development (bla bla bla) had an entire day wasted because of a software update.
Nothing like this ever happened to me during aby environment and I remember first days of Borland compilers (bla bla bla).
I know there have been many attempts of making QT Creator auto-configure the environment etc. alright.
But today? QT Creator 12. I've been trying to switch to GDB debugger like 4 times, and QT Creator reverting my setting each and every time. I had no idea why. It was reverting. I clicked ok opened up the view again -my settings were GONE. Just like that GDB in place. No files missing.
It happened well to many times while developing on Windows+ QT creator that all the sudden the environment got broken, settings went estray.
Now I have my project compile just fine, no breakpoints are ever hit. Just like that Nobody knows why. Reinstalled QT Creator wiped out everything everything was perfecto with Creator 10 community edition.
-
@CodesInChaoss I'm using Qt 5.13.2 in Windows and this project used to compile fine in the past. Something changed since then and I'm now getting this same error:
/usr/bin/sh: C:android-ndk-r20b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directoryIn Qt, Tools > Options > Devices > Android tab > Android NDK location it has:
C:\android-ndk-r20bI wanted to see if it was a an error parsing issue in Qt so I tried compiling the project outside of Qt. This is what I found.
My first attempt:
C:\Qt\Qt5.13.2\5.13.2\android_arm64_v8a\bin\qmake.exe
Project ERROR: You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.
Could not read qmake configuration file C:/Qt/Qt5.13.2/5.13.2/android_arm64_v8a/mkspecs/android-clang/qmake.conf.
Error processing project file: C:\code\ui_PUT1431\el_trackerui\el_gui_qtqc2\el_gui_qtqc2.proSo then I set the ANDROID_NDK_ROOT as follows (to match what's in Qt):
set ANDROID_NDK_ROOT=C:\android-ndk-r20bNow running qmake works fine and builds a Makefile.
I then try to make, but get the exact same error as Qt reports:
C:\android-ndk-r20b\prebuilt\windows-x86_64\bin\make
compiling file.cpp
/usr/bin/sh: C:android-ndk-r20b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory
make: *** [websocketclientwrapper.obj] Error 127So I open the qmake generated Makefile and see this line:
CXX = @echo compiling $< && C:\android-ndk-r20b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++Note the C:\ is Windows backslash while the rest in the path are Unix forward slashes.
So I next tried the following:
set ANDROID_NDK_ROOT=C:/android-ndk-r20b
C:\Qt\Qt5.13.2\5.13.2\android_arm64_v8a\bin\qmake.exeNow the Makefile has this line and all path separators are consistently Unix style:
CXX = @echo compiling $< && C:/android-ndk-r20b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++now make works:
C:\android-ndk-r20b\prebuilt\windows-x86_64\bin\makeHowever, I go back to Qt Creator and try to set Android NDK location to C:/android-ndk-r20b. It seems to work but whenever I open the Options to verify Qt reverts it back to C:\ on me. Needless to say, I still can't compile in Qt Creator because of this C:\ issue in the NDK path.
So long story short, where I am currently, is that I can build the project outside of Qt Creator but I can't build it inside Qt Creator. I'm wasting time trying to get Qt Creator to accept C:/ in the NDK path but nothing is working. I'm trying to modify the Makefile that Qt Creator generates but Qt is reverting it back whenever I try to build the project in Qt.
I wonder if there's a qmake option to force it to use a certain path separator when generating paths in the Makefile.
-
@devin_qt
I am jumping in here, knowing nothing about "QGC" but lots about path characters and Linux shell quoting :)The problem is that (Linux)
sh
deals with\
s as an "escape" character. And sadly you say you have trouble getting it changed over to/
. Are either of the following possible for you:- Change the
sh
script file to put, say,"..."
characters around where it uses theC:\android-ndk...
command?\
s are literal inside double-quoted strings, so"C:\android..."
should work. - If you are really lucky, Creator might accept a doubled backslash, try
C:\\android-ndk...
. Theoretically that will work both as a native path and as a string interpreted bysh
. - The
C:android...
path you are getting is relative to the current directory. It would actually work OK if the current directory onC:
were\
! I don't suppose as a workaround it is possible for you to make the current directory be\
when you invoke the script? Probably not, but just a thought.
Otherwise you will have to wait for someone who knows whether/how this is supposed to work under Windows or can be fixed.
- Change the
-
@JonB it's a clever idea but unfortunately doesn't work with Qt Creator.
I tried setting Android NDK location to C:\android-ndk-r20b... but then there are errors in Qt Creator immediately:
- Android NDK directory structure is incorrect
- Android NDK installed into a path without spaces.
For fun, I tried the following and it works. I can compile in Qt Creator now but it's such a roundabout way to hack this.
- Projects > Android for arm64-v8a (Clang Qt 5.13.2 for Android ARM64-v8a) > Build
- under Build Steps click on Add Build Step drop down to get an option Process Custom Step
- click on Custom Process Step
- on the top right corner of the new step (only when the mouse hovers over the step) there's a little upwards pointing arrow, click on it until it is under the qmake step but before the make step
- in the Command field: python
- in the Arguments field: full path to a Python script that I'll copy below
Basically, it does the following:
- run qmake as usual, which will generate a Makefile with faulty NDK path
- run a custom Python script to change C:\android-ndk-r20b to C:/android-ndk-r20b in the Makefile
- run make as usual
My first attempt was to replace all \ with / in the Makefile but it failed, so I modified the script to only replace the \ with / in the NDK path (as you'll see in the script below).
In Linux there's probably a much simpler way to do this with just a sed command but I'm in Windows and don't feel like spending any more time on this issue. However, also in Linux, this likely wouldn't be an issue to begin with as everything likely already uses /.
I can now compile the project in Qt Creator 5.13.2.
Here's the Python script I'm using, note that it's just a copy/paste/modify from the first search result I found as I'm not strong in Python. Also, this requires that Python is installed and found your PATH (i.e. in Command Prompt, run "python --version" if it doesn't work, then this approach won't work for you). If you modify your PATH you'll need to restart Qt Creator.
Also, the path to my python script is currently absolute, i.e. C:\full_path_to_script\fixup.py. I didn't spend any time trying to add it to the project and use a proper relative path/environment variable for the script.
Here is the Python script I used:
import re def case_insensitive_search_and_replace(file_path, search_word, replace_word): with open(file_path, 'r') as file: file_contents = file.read() pattern = re.compile(re.escape(search_word), re.IGNORECASE) updated_contents = pattern.sub(replace_word, file_contents) with open(file_path, 'w') as file: file.write(updated_contents) # Example usage # Note: This is the full absolute path to the Makefile that is auto-generated by qmake: file_path = r'C:\code\project_path\build-project_path-Android_for_arm64_v8a_Clang_Qt_5_13_2_for_Android_ARM64_v8a-Debug\Makefile' # you'll need to change this to match your NDK path search_word = 'C:\\android-ndk-r20b' replace_word = 'C:/android-ndk-r20b' case_insensitive_search_and_replace(file_path, search_word, replace_word)