CMake Error: Target "EventTest" links to target "PkgConfig::libzstd" but the target was not found.

763 views
Skip to first unread message

sa wang

unread,
Jun 4, 2023, 11:33:54 PM6/4/23
to davis-users
Hi, I'm using Ubuntu 22.04 with CMake 3.22 and dv-processing v1.7.8, but as I compile an easy C++ project with CMake using dv-processing, a problem is raised.
Here is my CMakeLists.txt:

```
cmake_minimum_required(VERSION 3.22)

project(EventTest)

find_package(dv-processing REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} dv::processing)
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBZSTD_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${LIBZSTD_LIBRARIES})
```

and main.cpp which is pretty short:

```
#include <iostream>
#include <dv-processing/core/core.hpp>
#include <dv-processing/core/utils.hpp>

using namespace std;

int main(){
    cout << "OK" << endl;
}
```

**However, CMake shows the error:**

CMake Warning at /usr/share/cmake-3.22/Modules/FindBoost.cmake:1369 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:1492 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:2102 (_Boost_MISSING_DEPENDENCIES)
  /usr/lib/x86_64-linux-gnu/cmake/dv-processing/dv-processing-config.cmake:29 (FIND_PACKAGE)
  CMakeLists.txt:5 (find_package)


CMake Warning (dev) at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (dv-processing).  This can
  lead to problems in calling code that expects `find_package` result
  variables (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:99 (find_package_handle_standard_args)
  /usr/lib/x86_64-linux-gnu/cmake/dv-processing/dv-processing-config.cmake:54 (INCLUDE)
  CMakeLists.txt:5 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Project name is: EventTest
-- Project version is:
-- Build type is: Release
-- Compiler is Clang: FALSE
-- Compiler is GCC: TRUE
-- Compiler is IntelCC: FALSE
-- Compiler is MS VisualC: FALSE
-- OS is Unix: TRUE
-- OS is Linux: TRUE
-- OS is MacOS: FALSE
-- OS is Windows: FALSE
-- System is big-endian: 0
-- Thread support is PThreads: TRUE
-- Thread support is Win32 Threads: FALSE
-- Thread support libraries:
-- Current C flags are:
-- Current CXX flags are:
-- Final install bindir is: /usr/local/bin
-- Final install libdir is: /usr/local/lib
-- Final install includedir is: /usr/local/include
-- Configuring done
CMake Error at CMakeLists.txt:11 (add_executable):
  Target "EventTest" links to target "PkgConfig::libzstd" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?


-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

I have tried to add find_package(PkgConfig) or libzstd but error occurs again. Besides, this CMakeList file works before, but after several days (maybe some new installations) it occurs this error until now.

Best wishes.

Shaoan

Pierre Giraud

unread,
Jun 5, 2023, 5:37:36 AM6/5/23
to davis-users, sa wang
Hi Shaoan,

Your error seems to come from trying to link "libzstd" and not dv-processing. Please remove it from CMakeLists.txt and try again.

Best Regards,

--

Pierre Giraud
Software Engineer

iniVation AG



From: 'sa wang' via davis-users <davis...@googlegroups.com>
Sent: Monday, 5 June 2023 05:33
To: davis-users <davis...@googlegroups.com>
Subject: [davis-users] CMake Error: Target "EventTest" links to target "PkgConfig::libzstd" but the target was not found.
 
--
You received this message because you are subscribed to the Google Groups "davis-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/davis-users/cccb90e9-5ee8-41a4-b136-1a61bca1187dn%40googlegroups.com.

sa wang

unread,
Jun 5, 2023, 7:19:24 AM6/5/23
to davis-users
Thank you for your prompt response, and I apologize for my lack of accuracy in my previous description. In fact, the original CMakeLists file does not contain anything about the libzstd library: the

cmake_minimum_required(VERSION 3.22)
project(EventTest)
find_package(dv-processing REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED)
# debug on
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} dv::processing)
However, the same error is encountered when compiling:
CMake Error at CMakeLists.txt:11 (add_executable):
  Target "EventTest" links to target "PkgConfig::libzstd" but the target was  not found.  Perhaps a find_package() call is missing for an IMPORTED  target, or an ALIAS target is missing?

I think it may be that the CMakeLists in the dv-processing library uses PkgConfig to make a connection to the libzstd library, but I still get an error when I make a connection to it in the CMakeLists in this project (I think I have connected to libzstd properly). Maybe there are some ways to avoid this problem?
Thanks again for your kind reply.

Best Regards,
Shaoan Wang

Luca Longinotti

unread,
Jun 5, 2023, 8:26:08 AM6/5/23
to davis...@googlegroups.com
Yes, dv-processing uses liblz4 and libzstd, so its CMake file searches for and includes them.
Do you have libzstd-dev installed? That's the package that contains the libzstd PkgConfig file, I just checked on an Ubuntu 22.04 install.

-- 
Luca Longinotti (llongi)

Head of Embedded Platforms
iniVation AG - https://inivation.com/
Zurich, Switzerland
Office: +41 44 500 32 14

sa wang

unread,
Jun 5, 2023, 8:34:58 AM6/5/23
to davis-users
I have already installed libzstd-dev. 
Here I ran this command:
$ dpkg -L libzstd-dev

It shows:
/.
/usr
/usr/include
/usr/include/zdict.h
/usr/include/zstd.h
/usr/include/zstd_errors.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libzstd.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libzstd.pc
/usr/share
/usr/share/doc
/usr/share/doc/libzstd-dev
/usr/share/doc/libzstd-dev/README.Debian
/usr/share/doc/libzstd-dev/copyright
/usr/share/doc/libzstd-dev/examples
/usr/share/doc/libzstd-dev/examples/Makefile
/usr/share/doc/libzstd-dev/examples/README.md
/usr/share/doc/libzstd-dev/examples/common.h
/usr/share/doc/libzstd-dev/examples/dictionary_compression.c
/usr/share/doc/libzstd-dev/examples/dictionary_decompression.c
/usr/share/doc/libzstd-dev/examples/multiple_simple_compression.c
/usr/share/doc/libzstd-dev/examples/multiple_streaming_compression.c
/usr/share/doc/libzstd-dev/examples/simple_compression.c
/usr/share/doc/libzstd-dev/examples/simple_decompression.c
/usr/share/doc/libzstd-dev/examples/streaming_compression.c
/usr/share/doc/libzstd-dev/examples/streaming_compression_thread_pool.c
/usr/share/doc/libzstd-dev/examples/streaming_decompression.c
/usr/share/doc/libzstd-dev/examples/streaming_memory_usage.c
/usr/lib/x86_64-linux-gnu/libzstd.so
/usr/share/doc/libzstd-dev/changelog.Debian.gz

Besides, when I add 
pkg_check_modules(ZSTD REQUIRED IMPORTED_TARGET libzstd)
to my CMakeLists file, it shows:
[cmake] -- Checking for module 'libzstd'
[cmake] -- Found libzstd, version 1.4.8
which seems like CMake has found this library. However it still report the error that:
CMake Error at CMakeLists.txt:13 (add_executable):
  Target "EventTest" links to target "PkgConfig::libzstd" but the target was  not found.  Perhaps a find_package() call is missing for an IMPORTED  target, or an ALIAS target is missing?

I feel hard to find the real problem.

Best Regards,
Shaoan

sa wang

unread,
Jun 6, 2023, 4:12:11 AM6/6/23
to davis-users
I have uninstalled packages such as dv-processing and pkg-config and reinstalled dv-processing following the tutorial. However, the CMake result is still the same. BTW, the examples provided in dv-processing (e.g. real-time feature tracking) can be used normally with Python.

CMake Error at CMakeLists.txt:13 (add_executable):
  Target "EventTest" links to target "PkgConfig::libzstd" but the target was  not found.  Perhaps a find_package() call is missing for an IMPORTED  target, or an ALIAS target is missing?

Luca Longinotti

unread,
Jun 7, 2023, 12:35:07 PM6/7/23
to davis...@googlegroups.com
The libzstd is clearly installed and its pkg-config file available:
/usr/lib/x86_64-linux-gnu/pkgconfig/libzstd.pc
We also use Ubuntu 22.04 here and cannot reproduce this failure.
Is it possible you have something else installed that is interfering? Some other repository other than the default Ubuntu ones and ours?
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages