# PVRTexLib.dll Does Not Unload

**URL:** <https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422>\
**Category:** PowerVR Insider\
**Tags:** pvrtextool\
**Created:** [August 31, 2021, 11:24pm UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422 "2021-08-31T23:24:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![L-Spiro](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/l-spiro/32/410_2.png) [@L-Spiro](https://forums.imgtec.com/u/L-Spiro)\
**Post date:** [August 31, 2021, 11:24pm UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/1 "2021-08-31T23:24:29Z")

</div>

Version: #define PVRTLSTRINGVERSION “5.1.0”  
Compiler: Visual Studio 2015  
OS: Windows 7  
Platforms: Release + Debug, x86 + x64.

Now that PVRTexLib.dll is being imported, my engine no longer closes. All of the windows close, but a single thread remains active in the debugger:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/imagination1/original/1X/3066acff6f66a3d88718513db9736e8d153c6768.png)  
This remains the case regardless of Debug/Release builds or x86/x64 builds. My engine waits inside common\_exit() for the thread to do something and it never finishes.

This happens even if no functions are called inside the DLL. Simply loading the DLL causes this to happen later during shut-down.

#1: Is it possible to not use the DLL at all? I would strongly rather use a static link only to PVRTexLib.lib, but when I tried it still requested that the DLL be present. If I could link only to PVRTexLib.lib, it would solve this problem.  
#2: Otherwise I need to know how to solve this problem.

Thank you,  
L. Spiro

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [September 3, 2021, 10:46am UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/2 "2021-09-03T10:46:17Z")

</div>

Hello L.Spiro,

Thank you for your question. I’ve passed your this onto the tools team, and we’ll get back to you.

All the best,  
Lawrence

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [September 3, 2021, 2:24pm UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/3 "2021-09-03T14:24:13Z")

</div>

Hello,

On our developer portal we have the latest release of PVRTexTool, this comes with a static library PVRTexLib.lib: [Downloads - Imagination Developers](https://developer.imaginationtech.com/downloads/)  
Let us know if that helps resolve the problem.

All the best,  
Lawrence

---

<div class="post-metadata">

**Author:** ![L-Spiro](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/l-spiro/32/410_2.png) [@L-Spiro](https://forums.imgtec.com/u/L-Spiro)\
**Post date:** [September 3, 2021, 8:32pm UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/4 "2021-09-03T20:32:11Z")

</div>

Hello Lawrence.  
That is the static library I already have (unless it has been updated within the past few hours). Linking to it (and not the DLL) gives:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/imagination1/original/1X/f392c061b456790d23145e198a66d02a50fdb5ac.png)  
This is the case even if PVRTEXLIB\_IMPORT is not defined. Dropping the DLL into the folder solves the issue but then I have the above issue with my engine no longer being able to close.  
The instructions do not specify that using only the static library is possible and so do not come with any information on how to perform a static link, instead suggesting that only using the DLL is possible on Windows.

When the DLL is loaded, it starts 8 idle threads, one for each processor. One of these remains open when trying to shut down and unload the DLL. ::FreeLibrary() gives the same hanging situation.

Regards,  
L. Spiro

---

<div class="post-metadata">

**Author:** ![L-Spiro](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/l-spiro/32/410_2.png) [@L-Spiro](https://forums.imgtec.com/u/L-Spiro)\
**Post date:** [September 5, 2021, 8:13am UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/5 "2021-09-05T08:13:56Z")

</div>

I am pretty sure the static library itself links to the DLL. There is no way to link to the static library without it requesting the DLL on start-up.  
PVRTEXLIB\_IMPORT is not defined.

Linking to the DLL is not an option as it always results in shut-down hang, and linking to the static library is not an option because it forces linking to the DLL.  
Fixing this will require a new build of the .LIB and the .DLL, which makes me wonder how I can possibly be the only person with this issue.  
I need to release my tools. Will a fixed build be available soon?

L. Spiro

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [September 6, 2021, 9:58am UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/6 "2021-09-06T09:58:45Z")

</div>

Hello L. Spiro,

I have been speaking with the tools team, the following is true:  
The static lib is not really a static lib, but just an import library that tells the runtime linker which dll to load. and that PVRTexLib creates a thread pool with one thread for each CPU core.

However, we have never come across an issue where the threads block de-init before. We took a look at this callstack you attached, and the function signatures appear to match this project on github: [https://github.com/Chuyu-Team/VC-LTL](https://github.com/Chuyu-Team/VC-LTL)

This project is an opensource C runtime which would introduce different handling of dll loading and deinit. Since we only test the windows libraries with Microsoft’s runtime, this might explain why you are the first to encounter this problem, and would actually suggest an error in the runtime not in PVRTexLib.

If you are using the standard microsoft runtime, then a minimal example will help us rule out possible causes. I have attached a bare bones CMake project to test against.[PVRTextLib\_Test.zip](https://forums.imgtec.com/uploads/short-url/xEk00euxE20Zpt8YoOLr3I5j9WW.zip) (3.2 MB)

Simply extract the zip file  
Open the extracted directory in a terminal:

```auto
mkdir build
cd build
cmake ..

```

And that will generate a Visual studios project, which just loads TexLib and transcodes an image, then exits. Hopefully this will help us pinpoint any issues. You will have to have Cmake ver 3.6+ in your path, or you can use the Cmake gui instead.

I hope this helps  
All the best,  
Lawrence

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [September 8, 2021, 8:33am UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/7 "2021-09-08T08:33:00Z")

</div>

Hello,

We’ve managed to reproduce this issue, using that runtime library. We have a fix that we could supply to you as an engineering drop if you send us a ticket over here: [https://pvrsupport.imgtec.com/](https://pvrsupport.imgtec.com/)

We also have a release coming up soon that will contain this fix.

All the best,  
Lawrence

---

<div class="post-metadata">

**Author:** ![L-Spiro](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/l-spiro/32/410_2.png) [@L-Spiro](https://forums.imgtec.com/u/L-Spiro)\
**Post date:** [September 8, 2021, 9:27am UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/8 "2021-09-08T09:27:06Z")

</div>

Hello Lawrence.

I am not using that library, but I have MSVCRT added to my “Ignore Specific Default Libraries” setting, which must generate code very similar to what that library generates.

I have filed a ticket and look forward to making progress with an engineering drop. I build for both x86\_32 and x86\_64.

Thank you,  
L. Spiro

---

<div class="post-metadata">

**Author:** ![L-Spiro](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/l-spiro/32/410_2.png) [@L-Spiro](https://forums.imgtec.com/u/L-Spiro)\
**Post date:** [September 9, 2021, 5:33am UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/9 "2021-09-09T05:33:08Z")

</div>

Hello Lawrence.

The DLL almost worked, but while it successfully shuts down if loaded and not used, it still fails shut-down if it was used for PVRTC conversion. For example to GL\_COMPRESSED\_RGBA\_PVRTC\_4BPPV2\_IMG from RGBA F32.

Regards,  
L. Spiro

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [September 9, 2021, 7:29am UTC](https://forums.imgtec.com/t/pvrtexlib-dll-does-not-unload/3422/10 "2021-09-09T07:29:53Z")

</div>

Hi L. Spiro,

Thanks for the feedback on the engineering drop, I’ve passed this back to the tools team, and hopefully we should have another fix for you soon

All the best,  
Lawrence
