www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can't load FreeImage.dll with Windows

reply WhatMeWorry <kheaser gmail.com> writes:
I've tried distilling the problem to its very essence.

I downloaded the FreeImage.dll from 
https://freeimage.sourceforge.io/download.html
to the following directory:

where /R c:\ FreeImage.dll

c:\Users\Admin\Downloads\FreeImage3180Win32Win64\FreeImage\Dist\x64\FreeImage.dll

     dir 
c:\Users\Admin\Downloads\FreeImage3180Win32Win64\FreeImage\Dist\x64\FreeImage.dll
     07/31/2018  12:23 PM         6,942,208 FreeImage.dll
                    1 File(s)      6,942,208 bytes


dependency "bindbc-freeimage" version="~>1.0.0"
versions "FI_318"


but when I try to load the dll with the bindbc-freeimage package 
provided loadFreeImage function, all I get is no library found:

         writeln("The dub.sdl file of this project expects 
FreeImage version ", fiSupport);
         immutable FISupport fiLib = 
loadFreeImage("c:\\Users\\Admin\\Downloads\\FreeImage3180Win32Win64\\FreeImage\\Dist\\x64\\FreeImage.dll");	
         writeln("loadFreeImage returned: ", fiLib);


OUTPUT
-------------------------------------------------------------------
The dub.sdl file of this project expects FreeImage version fi318
loadFreeImage returned: noLibrary



I also tried:

loadFreeImage(`c:\Users\Admin\Downloads\FreeImage3180Win32Win64\FreeImage\Dist\x64\FreeImage.dll`);	
and
loadFreeImage(`c:/Users/Admin/Downloads/FreeImage3180Win32Win64/FreeImage/Dist/x64/FreeImage.dll`);	

but got same results.  Also tried version="~>1.0.2"
Mar 03 2023
next sibling parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
What happens if you put the dll next to your executable, does it 
find it?
Mar 03 2023
parent WhatMeWorry <kheaser gmail.com> writes:
On Friday, 3 March 2023 at 19:44:17 UTC, ryuukk_ wrote:
 What happens if you put the dll next to your executable, does 
 it find it?
Good idea. I copied the dll into same directory as the executable and changed loadFreeImage to immutable FISupport fiLib = loadFreeImage(); And I get the same noLibrary result.
Mar 03 2023
prev sibling next sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
I went ahead and tried to reproduce your setup (this worked).

Used FreeImage3180Win32Win64.zip and recent dmd & ldc.

```json
{
	"authors": [
		"alpha"
	],
	"copyright": "Copyright © 2023, alpha",
	"description": "A minimal D application.",
	"license": "proprietary",
	"name": "whatmeworryfreeimage",
     "dependencies": {
         "bindbc-freeimage": "~>1.0.2"
     },
     "versions": ["FI_318"]
}
```

```d
import std.stdio;
import bindbc.freeimage;

void main()
{
     FISupport ret = loadFreeImage("FreeImage/Dist/x64/FreeImage.dll");
     if(ret != fiSupport) {
         if(ret == FISupport.noLibrary) {
             writeln("no");
         }
         else if(FISupport.badLibrary) {
             writeln("bad");
         }
     } else {
         writeln("good");
     }
}
```

Directory layout:

```
.
├── dub.json
├── FreeImage
│   └── Dist
│       ├── x32
│       │   └── FreeImage.dll
│       └── x64
│           └── FreeImage.dll
└── source
     └── app.d
```
Mar 03 2023
prev sibling parent Adam D Ruppe <destructionator gmail.com> writes:
On Friday, 3 March 2023 at 19:07:14 UTC, WhatMeWorry wrote:
 loadFreeImage(`c:\Users\Admin\Downloads\FreeImage3180Win32Win64\FreeImage\Dist\x64\FreeImage.dll`);	
is your application build 64 bit too?
Mar 03 2023