vcpkg installing of opencv failed with error : ninja: build stopped: subcommand failed

190 Views Asked by At

I have a project that works properly in Windows but when trying to use it in Linux (Ubnto 22.04) I am getting an error.

The environment is Ubunto 2204, CMake and VCPKG (all of them were downloaded and installed in Jan 2024, so I assume they are the latest version.

The cmakelist.txt is:

cmake_minimum_required (VERSION 3.20)
if (DEFINED ENV{VCPKG_ROOT})
    File(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT)
    message(STATUS ${VCPKG_ROOT})
    if(WIN32)
        set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
        set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "")
    else(WIN32)
        set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "" FORCE)
        set(VCPKG_TARGET_TRIPLET "x64-linux" CACHE STRING "")
    endif(WIN32)
    set(VCPKG_AVALIABLE TRUE)
else (DEFINED ENV{VCPKG_ROOT})
    message(WARNING "VCPKG_ROOT is not defined, OpenCV will not be used.")
    set(VCPKG_AVALIABLE FALSE)
endif()
project (test)
if (MSVC)
    add_definitions (-D_USE_MATH_DEFINES)
    add_definitions(/MP)
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ot /openmp" )
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
    
endif()

set(CXX_STANDARD 20)
enable_language(C)
enable_language(CXX)

if(VCPKG_AVALIABLE)
    set(OpenCV_STATIC, ON)
    FIND_PACKAGE(OpenCV REQUIRED)
    add_definitions (-D_USE_OPENCV)
endif(VCPKG_AVALIABLE)

add_executable(test main.cpp})
target_include_directories(test PUBLIC  ${OpenCV_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(test ${OpenCV_LIBS})

and vcpkg.json is:

{
    "dependencies": [
    {
        "name": "opencv"
    }
   ]
}

when I build the application using the following code:

#!/bin/bash
cmake -B./build -S./
cd build
make

I am getting this error:

ninja: build stopped: subcommand failed.

how can I fix it?

Edit 1

content of vcpkg-manifest-install.log:

Detecting compiler hash for triplet x64-linux...
The following packages will be built and installed:
  * flatbuffers:[email protected]#1
  * gtk3:[email protected]#1
    opencv[core,default-features]:[email protected]#1
  * opencv4[core,default-features,dnn,gtk,jpeg,png,quirc,tiff,webp]:[email protected]#15
  * protobuf:[email protected]#1
  * vcpkg-get-python-packages:x64-linux@2024-01-02
Additional packages (*) will be modified to complete this operation.
Restored 0 package(s) from /home/mans/.cache/vcpkg/archives in 25.4 us. Use --debug to see more details.
Installing 1/6 gtk3:[email protected]#1...
Building gtk3:[email protected]#1...
-- Using cached GNOME-gtk-3.24.38.tar.gz.
-- Cleaning sources at /home/mans/local/vcpkg/buildtrees/gtk3/src/3.24.38-f430748213.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source /home/mans/local/vcpkg/downloads/GNOME-gtk-3.24.38.tar.gz
-- Applying patch 0001-build.patch
-- Applying patch cairo-cpp-linkage.patch
-- Using source at /home/mans/local/vcpkg/buildtrees/gtk3/src/3.24.38-f430748213.clean
-- Getting CMake variables for x64-linux-dbg
-- Getting CMake variables for x64-linux-rel
-- Configuring x64-linux-dbg
-- Configuring x64-linux-dbg done
-- Configuring x64-linux-rel
-- Configuring x64-linux-rel done
-- Package x64-linux-dbg
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:112 (message):
    Command failed: /home/mans/local/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja install -v
    Working Directory: /home/mans/local/vcpkg/buildtrees/gtk3/x64-linux-dbg
    Error code: 1
    See logs for more information:
      /home/mans/local/vcpkg/buildtrees/gtk3/package-x64-linux-dbg-out.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_install_meson.cmake:33 (vcpkg_execute_required_process)
  ports/gtk3/portfile.cmake:79 (vcpkg_install_meson)
  scripts/ports.cmake:170 (include)


error: building gtk3:x64-linux failed with: BUILD_FAILED
Elapsed time to handle gtk3:x64-linux: 11 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+gtk3
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[gtk3]+Build+error+on+x64-linux&body=Copy+issue+body+from+%2Fhome%2Fmans%2FMyData%2FBitBucket%2Ftest%2Fvcpkg%2Fbuild%2Fvcpkg_installed%2Fvcpkg%2Fissue_body.md

and content of package-x64-linux-dbg-out.log

[1/906] /home/mans/MyData/BitBucket/test/vcpkg/build/vcpkg_installed/x64-linux/tools/glib/glib-compile-resources gdk/gdk.gresource.xml --sourcedir ../src/3.24.38-f430748213.clean/gdk/. --sourcedir ../src/3.24.38-f430748213.clean/gdk --c-name _gdk --internal --generate --target gdk/gdkresources.c --manual-register --dependency-file gdk/gdkresources.c.d

multipress.so.p/gtkimcontextmultipress.c.o -c ../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.c
../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.c: In function ‘on_timeout’:
../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.c:204:3: warning: ‘gdk_threads_enter’ is deprecated [-Wdeprecated-declarations]
  204 |   gdk_threads_enter ();
      |   ^~~~~~~~~~~~~~~~~
In file included from ../src/3.24.38-f430748213.clean/gdk/gdk.h:61,
                 from ../src/3.24.38-f430748213.clean/gtk/gtk.h:30,
                 from ../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.h:20,
                 from ../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.c:20:
../src/3.24.38-f430748213.clean/gdk/gdkthreads.h:46:10: note: declared here
   46 | void     gdk_threads_enter                    (void);
      |          ^~~~~~~~~~~~~~~~~
../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.c:214:3: warning: ‘gdk_threads_leave’ is deprecated [-Wdeprecated-declarations]
  214 |   gdk_threads_leave ();
      |   ^~~~~~~~~~~~~~~~~
In file included from ../src/3.24.38-f430748213.clean/gdk/gdk.h:61,
                 from ../src/3.24.38-f430748213.clean/gtk/gtk.h:30,
                 from ../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.h:20,
                 from ../src/3.24.38-f430748213.clean/modules/input/gtkimcontextmultipress.c:20:
../src/3.24.38-f430748213.clean/gdk/gdkthreads.h:48:10: note: declared here
   48 | void     gdk_threads_leave                    (void);
      |          ^~~~~~~~~~~~~~~~~

[312/906] /usr/bin/python3 /home/mans/MyData/BitBucket/test/vcpkg/build/vcpkg_installed/x64-

Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=empty-body -Werror=write-strings -MD -MQ gdk/libgdk-3.a.p/gdkwindow.c.o -MF gdk/libgdk-3.a.p/gdkwindow.c.o.d -o gdk/libgdk-3.a.p/gdkwindow.c.o -c ../src/3.24.38-f430748213.clean/gdk/gdkwindow.c
ninja: build stopped: subcommand failed.
0

There are 0 best solutions below