Thread overview
My tiny program still can't get FreeImage.dll to load... GLFW.dll library loads no problem...
Mar 15, 2023
WhatMeWorry
Mar 15, 2023
Hipreme
March 15, 2023

I appreciate all the help people have given me previously. So I've made everything super simple. The dub.sdl file consists of four lines:

name "00_03_freeimage_debug"
dependency "bindbc-glfw" version="~>1.0.0"
dependency "bindbc-freeimage" version="~>1.0.2"
versions "FI_318"

The app.d use exists() functions to prove the existence of both .dll files before their load_xxx functions.

import std.stdio;
import std.file; // exists
import bindbc.freeimage;
import bindbc.loader;
import bindbc.glfw;

void main()
{
if (exists("FreeImage.dll"))
writeln("the file FreeImage.dll DOES exist");
else
writeln("the file FreeImage.dll NOT FOUND");

FISupport ret = loadFreeImage(`FreeImage.dll`);
writeln("ret = ", ret);

ret = loadFreeImage();
writeln("ret = ", ret);

if (exists("glfw3.dll"))
    writeln("the file glfw3.dll DOES exist");
else
    writeln("the file glfw3.dll NOT FOUND");

GLFWSupport retGLFW = loadGLFW("glfw3.dll");
writeln("retGLFW = ", retGLFW);

retGLFW = loadGLFW();
writeln("retGLFW = ", retGLFW);	

}

The Output shows:

the file FreeImage.dll DOES exist
ret = noLibrary
ret = noLibrary
the file glfw3.dll DOES exist
retGLFW = glfw30
retGLFW = glfw30

So my app.d thinks that FreeImage.dll is present. But loadloadFreeImage fails.

My dub command uses the --arch=x86_64 so I know app.d is a 64 bit app. And I've checked the FreeImage.dll and downloaded it countless times making extra sure that it is the 64 bit Freeimage library and not the 32 bits. I'm getting the FreeImage.dll from SourceForge if that is relevant.

My windows 10 machine shows FreeImage.dll to be the following:

07/31/2018 01:23 PM 6,942,208 FreeImage.dll
03/06/2023 04:25 PM 216,576 glfw3.dll

I'm stuck. Not sure how to make any headway.

March 15, 2023

On Wednesday, 15 March 2023 at 22:09:35 UTC, WhatMeWorry wrote:

>

I appreciate all the help people have given me previously. So I've made everything super simple. The dub.sdl file consists of four lines:

  • Solution to this problem: Checking whether it exists is completely irrelevant if you don't pass absolute path to it. Plus, the load function checks whether it exists on system32 too. For a DLL to be load, it must be beside you .exe file. That means: exists() is relative to your working directory, dll load is relative to the directory the .exe is.

  • Better solution: There's no point into using libfreeimage. In D we already have Gamut1 and 2 arsd:image_files. Both solutions is better suited to working with D as they use actual D syntax and features to make your code faster and safer, there will be no need to have a C compiler nor to pack a DLL together with your program.

March 16, 2023
I replicated it, copied the Dist folder from the zip beside app.json, set the right file to load and it worked.

http://downloads.sourceforge.net/freeimage/FreeImage3180Win32Win64.zip

```
$ dub run
    Starting Performing "debug" build using C:\Tools\D\ldc2-1.31.0-windows-multilib\bin\ldc2.exe for x86_64.
  Up-to-date bindbc-loader 1.0.3: target for configuration [noBC] is up to date.
  Up-to-date bindbc-freeimage 1.0.2: target for configuration [dynamic] is up to date.
  Up-to-date bindbc-glfw 1.0.2: target for configuration [dynamic] is up to date.
    Building whatmeworry_freeimage ~master: building configuration [application]
     Linking whatmeworry_freeimage
    Finished To force a rebuild of up-to-date targets, run again with --force
     Running whatmeworry_freeimage.exe
the file FreeImage.dll NOT FOUND
ret = fi318
ret = fi318
the file glfw3.dll NOT FOUND
retGLFW = noLibrary
retGLFW = noLibrary
```

Lets see if its a dependency problem, try adding:

libs "Dist/x64/FreeImage"

That'll statically linking against the DLL, if there is DLL's missing that it needs or something isn't right, it'll error.

Worst case scenario if that works, just use the static configuration for bindbc-freeimage.

https://github.com/BindBC/bindbc-freeimage/blob/master/dub.sdl#L21