# Why need to set the path for opencv\_world4100d.dll

**URL:** <https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716>\
**Category:** C++\
**Tags:** windows, build\
**Created:** [September 11, 2024, 3:35am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716 "2024-09-11T03:35:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sea_sea/32/11091_2.png) [@Sea\_Sea](https://forum.opencv.org/u/Sea_Sea)\
**Post date:** [September 11, 2024, 3:35am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/1 "2024-09-11T03:35:04Z")

</div>

opencv\_world4100d.dll not found

I download pre-compiled opencv.  
And using the opencv in my project on windows  
It always show “opencv\_world4100d.dll not found”  
Until I set the variable to windows env by hand.

Q1.  
Why need to set opencv\_world4100d.dll ?  
Becuase other lib just find\_package(XXX)  
And then I can directly use.

Q2.  
Does any method (automatically) to set the path for windows?  
Not the interface operation.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [September 11, 2024, 6:29am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/2 "2024-09-11T06:29:16Z")

</div>

notice the `d` suffix? that’s for debug builds. you build your application as release or debug, but then the linked library and the corresponding DLL have to match that.

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sea_sea/32/11091_2.png) [@Sea\_Sea](https://forum.opencv.org/u/Sea_Sea)\
**Post date:** [September 11, 2024, 6:54am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/3 "2024-09-11T06:54:45Z")

</div>

I think you misunderstand

I don’t think so.  
Because I donwload [Releases - OpenCV](https://opencv.org/releases/)  
This is release version.

I try to use the release version and it also show opencv\_world4100.dll not found.  
Until I set the variable to windows env by hand.

And the cmake can’t solve my problem that search opencv\_world4100.dll automatically  
with these command.  
I already assign the install path. find\_package should be found these (include 、bin、lib、…)

```auto
set(OpenCV_DIR "./opencv")
find_package(OpenCV REQUIRED)

```

---

<div class="post-metadata">

**Author:** ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)\
**Post date:** [September 11, 2024, 8:29am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/4 "2024-09-11T08:29:17Z")

</div>

`find_package` locates libraries to be used at compile time. Because you are on Windows and have a shared library (_opencv\_world4100.dll_) this will find _opencv\_world4100.lib_.

At runtime your executable needs to be able to locate _opencv\_world4100.dll_. If the location of this was baked into the executable then you would only be able to use the executable on machines where _opencv\_world4100.dll_ was in the same location as on your build machine.

There are two main ways I am aware of which enable your executable to find shared libraries at runtime on Windows

1. storing it in the same folder as your executable, and
2. adding the path containing it to the user/system path.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [September 11, 2024, 9:43am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/5 "2024-09-11T09:43:25Z")

</div>

> [@cudawarped](#):
>
> At runtime your executable needs to be able to locate _opencv\_world4100.dll_. If the location of this was baked into the executable then you would only be able to use the executable on machines where _opencv\_world4100.dll_ was in the same location as on your build machine.

I doubt that.

Windows `LoadLibrary` has a defined mechanism. among other places, it looks for DLLs in the current working directory, in the directory containing the executable, and in PATH… AFAIK.

---

<div class="post-metadata">

**Author:** ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)\
**Post date:** [September 11, 2024, 9:55am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/6 "2024-09-11T09:55:50Z")

</div>

> [@crackwitz](#):
>
> I doubt that.
> 
> Windows `LoadLibrary` has a defined mechanism. among other places, it looks for DLLs in the current working directory, in the directory containing the executable, and in PATH… AFAIK.

I’ll rephrase. If the only way for an executable to locate a shared library was with a baked in path then…

> [@cudawarped](#):
>
> you would only be able to use the executable on machines where _opencv\_world4100.dll_ was in the same location as on your build machine.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [September 11, 2024, 10:24am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/7 "2024-09-11T10:24:16Z")

</div>

Ah, my misunderstanding 🙂

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sea_sea/32/11091_2.png) [@Sea\_Sea](https://forum.opencv.org/u/Sea_Sea)\
**Post date:** [September 13, 2024, 1:26am UTC](https://forum.opencv.org/t/why-need-to-set-the-path-for-opencv-world4100d-dll/18716/8 "2024-09-13T01:26:41Z")

</div>

> [@cudawarped](#):
>
> - storing it in the same folder as your executable, and
> - adding the path containing it to the user/system path.

maybe the method is good

1. storing it in the same folder as your executable, and

But the method is bad. If I want to move the application to other machine, it will miss the location  
2. adding the path containing it to the user/system path.
