Search code examples
c++qtcmakeqt5qt-creator

Qt5 [make -snap] doesn't compile properly: The process "/usr/bin/snap" exited with code 1


I copied/paste a Qt5 project folder from a computer to another computer. They are both Ubuntu 18.04.

Same version of Qt5 and same libraries/dependencies. On the new computer, I have CMake 3.10.2, but I don't remember the verion of CMake I had on the former one. (Probably CMake 3.8).

As soon as I open Qt5 and open the folder containing the CMakeLists.txt file, and click on it, I get the following result from the output:

08:02:22: Running steps for project newcam-proc...     
08:02:22: Persisting CMake state...  
08:02:22: Starting: "/usr/bin/snap" --build . --target all error: unknown flag `build' 
08:02:22: The process "/usr/bin/snap" exited with code 1. 
Error while building/deploying project myProject (kit: Desktop Qt 5.12.5 GCC 64bit) 
The kit Desktop Qt 5.12.5 GCC 64bit has configuration issues which might be the root cause for this problem. When executing step "CMake Build" 
08:02:22: Elapsed time: 00:00.

And below the General Message I get:

Project ERROR: You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.
Could not read qmake configuration file /home/emanuele/Qt/5.12.5/android_armv7/mkspecs/android-clang/qmake.conf.
Project ERROR: You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.
Could not read qmake configuration file /home/emanuele/Qt/5.12.5/android_x86/mkspecs/android-clang/qmake.conf.
Running /usr/bin/snap /home/emanuele/Desktop/myProject -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++ -DCMAKE_C_COMPILER:STRING=/usr/bin/gcc -DCMAKE_PREFIX_PATH:STRING=/home/emanuele/Qt/5.12.5/gcc_64 -DQT_QMAKE_EXECUTABLE:STRING=/home/emanuele/Qt/5.12.5/gcc_64/bin/qmake in /tmp/QtCreator-vlHbHY/qtc-cmake-LvUefYdh.
error: unknown command "/home/emanuele/Desktop/myProject", see 'snap help'.
CMake process exited with exit code 1.

I never had to use Android NDK on my previous project, nor I had to install it. And I am not sure why on the new machine is showing this message.

In addition it seems that is trying to use snap instead of the usual make.

I am not sure about what is happening and why.

What I tried so far:

1) The only thing that came to my mind was to try to create a small example application and see if it runs, it actually runs properly and gives no error as shown below:

08:16:00: Running steps for project untitled...
08:16:00: Configuration unchanged, skipping qmake step.
08:16:00: Starting: "/usr/bin/make" -j8
make: Nothing to be done for 'first'.
08:16:00: The process "/usr/bin/make" exited normally.
08:16:00: Elapsed time: 00:00.

It seems that the project that I copied/paste uses snap and if I create a new project, like a Qt Widget application, it actually uses make, exiting correctly in the output.


Solution

  • The flags --build . --target all are flags you typically see passed to the cmake executable, not the snap executable. This hints that your CMake environment is not configured correctly in the IDE on your new machine. I suggest following the QtCreator CMake setup instructions here to help get it configured:

    To specify paths to CMake executables:

    1. Select Tools > Options > Kits > CMake > Add.
    2. In the Name field, specify a name for the tool.
    3. In the Path field, specify the path to the CMake executable.
    4. Select the Auto-create build directories check box to automatically create build directories for CMake projects.
    5. Select Apply to save your changes.