Thread overview
Can't load FreeImage.dll with Windows
Mar 03, 2023
WhatMeWorry
Mar 03, 2023
ryuukk_
Mar 03, 2023
WhatMeWorry
Mar 03, 2023
Adam D Ruppe
March 03, 2023

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"

March 03, 2023

What happens if you put the dll next to your executable, does it find it?

March 03, 2023

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.

March 04, 2023
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
```
March 03, 2023
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?