Author Topic: Deployment of application with DLL in Windows 10  (Read 2666 times)

0 Members and 1 Guest are viewing this topic.

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Deployment of application with DLL in Windows 10
« on: May 22, 2021, 02:25:42 am »
Use and deployment of external DLL's in QB64 version 1.4:
The DECLARE DYNAMIC LIBRARY ["DLL name1", "DLL name2", ...] instruction allows the use of any type of dynamic library, both in Windows (DLL) and in Linux (SO), as long as it is declared below the call structure with the correct data types. For example (Windows):
DECLARE DYNAMIC LIBRARY "kernel32"
  FUNCTION GetThreadUILanguage% ()
  FUNCTION LCIDToLocaleName% (BYVAL LCID &, lcidName $, BYVAL length%, BYVAL dwFlags ~ &)
  FUNCTION GetUserDefaultLocaleName% (pwsLocale $, BYVAL LocaleLength%)
END DECLARE

These language functions are in the Windows 'kernel32' module, but since they have not been used by QB64, they need to be declared, as well as the call structure of the functions to use.
To use a library from a provider, it should be enough to copy it to the application folder, and call it by its name, without more, for example:
DECLARE DYNAMIC LIBRARY "NmxDLLx64"
 SUB NMX_GetDllVersion_1 (usMajor ~%, usMinor ~%, usPatch ~%, usBuild ~%)

Unfortunately, if it is only in the application folder, the IDE cannot find it and therefore does not allow it to be compiled, so it is necessary to copy it to system32 for the IDE to find it. On the other hand, the use of a relative location address such as ". \ NmxDLLx64" makes it work when compiling, but not when deploying the application, since the absolute address is resolved at compile time and makes the application not find the DLL in its own folder, but instead looks for the address where it was located when it was compiled.
For the generated executable to be able to use an external library with a simple name declaration, it must be located in C: \ windows \ system32 or in the same folder as the application, and this is sufficient for most cases, But for the IDE to find it and allow compiling, it must be in system32, however the generated executable will look for it in the application folder itself, so it will be enough to copy the application and the DLL together.
In my opinion it is necesary to make the IDE look like the executable.

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #1 on: May 29, 2021, 02:28:29 am »
The deployment of a 64 bit application in Windows also needs the 'Microsoft C++ redistributable (x64) 2015'

Now I have installed QB64 version 1.5, and the problem persists.
Since deploying a DLL in the .EXE folder itself works, the IDE should not give an error when it exists.
This is an IDE bug, preventing compilation if the DLL is not in system32.
« Last Edit: May 29, 2021, 07:24:31 am by moises1953 »