# IMPORTED\_LOCATION not set for imported target "opencv\_core".

**URL:** <https://discourse.cmake.org/t/imported-location-not-set-for-imported-target-opencv-core/9162>\
**Category:** Code\
**Tags:** os:linux\
**Created:** [October 9, 2023, 11:46pm UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target-opencv-core/9162 "2023-10-09T23:46:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tspdx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tspdx/32/3901_2.png) [@tspdx](https://discourse.cmake.org/u/tspdx)\
**Post date:** [October 9, 2023, 11:46pm UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target-opencv-core/9162/1 "2023-10-09T23:46:57Z")

</div>

I’m cross-compiling a Linux library for ARM using [dockcross](https://github.com/dockcross/dockcross) and linking to OpenCV. OpenCV builds and installs successfully, but configuring my library gives me errors like this:

```auto
CMake Error in build/_deps/mylib-src/CMakeLists.txt:
      IMPORTED_LOCATION not set for imported target "opencv_core"

```

I’m finding the OpenCV package like this:

` find_package( OpenCV REQUIRED )`

And linking like this:

` target_link_libraries( ${PROJECT_NAME} ${OpenCV_LIBS})`

I didn’t find the [documentation](https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_LOCATION.html) for IMPORTED\_LOCATION very helpful. What does this error mean, and how do I fix it?

---

<div class="post-metadata">

**Author:** ![tspdx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tspdx/32/3901_2.png) [@tspdx](https://discourse.cmake.org/u/tspdx)\
**Post date:** [October 10, 2023, 4:45am UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target-opencv-core/9162/2 "2023-10-10T04:45:45Z")

</div>

This worked:

`set_target_properties(opencv_core PROPERTIES IMPORTED_LOCATION ${CMAKE_SYSROOT}/usr/local/lib/libopencv_core.so)`

But I still don’t know why I needed it…

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [October 10, 2023, 2:20pm UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target-opencv-core/9162/3 "2023-10-10T14:20:37Z")

</div>

It seems like a botched install. Is there anything under the OpenCV install prefix that sets `IMPORTED_LOCATION`?

---

<div class="post-metadata">

**Author:** ![emmenlau](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@emmenlau](https://discourse.cmake.org/u/emmenlau)\
**Post date:** [November 6, 2024, 8:18pm UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target-opencv-core/9162/4 "2024-11-06T20:18:52Z")

</div>

Did you ever figure this out? I’m having the same problem with current latest OpenCV.

I think it may be because I created a static build of OpenCV that is installed into a target directory. I’ve read somewhere that static builds can only be used from the source tree. Is that possible?
