Author Topic: Deployment of application with DLL in Windows 10  (Read 4077 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: March 18, 2021, 03:42:33 am »
Environment:
64-bit Windows 10 version 2004 PC. 64-bit QB64 is installed, and a dynamic library named NmxDLLx64.DLL is added, which as its name indicates is 64-bit, in the same folder as the executable.
A program is created that uses the library without problem, even if it is copied to another folder
Library declaration
DECLARE DYNAMIC LIBRARY ". \ NmxDLLx64"

Laptop with Windows 10 version 1909 64-bit. Do not have QB64 installed.

Tests:
1) Copy program and DLL to laptop and run. Result: Cannot find the DLL (popup with message: 'Cannot find dynamic library file'.
2) Install QB64 on laptop. Copy the source of the program and compile it. Then the program works correctly.
3) Copy the executable again from the PC and run. The message box not found message appears again.
4) Create on the PC a path equal to the destination of the laptop where I want to install the application and its DLL. Compile it there. Copy it to the laptop and now it works.
5) One last test: Rename the folder where the executable and the DLL are located and it stops working

Conclusion:
The load address of the DLL is resolved in the compilation and linking process, from unit level.
Therefore, to deploy the application with its DLL, it must be copied to the same address relative to the computer that it was occupying when it was compiled.

¿There is another option?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #1 on: March 18, 2021, 11:17:09 am »
Interesting, assuming you updated step 4 Path when you changed folder name, you could try keeping DLL in QB64 folder?

All .h files need to be kept there (QB64 folder that contains .exe), they won't even work from your app folder.

(Sorry no experience of using DLL's from me but sometimes I catch the blunder since I am very experienced from my own.)

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #2 on: March 18, 2021, 12:27:42 pm »
In this case it is a DLL provided by a provider and does not include an .h file.

Are the conclusions valid?

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #3 on: March 18, 2021, 01:42:58 pm »
All .h files need to be kept there (QB64 folder that contains .exe), they won't even work from your app folder.

Sorry, but that's absolutly wrong b+, the .h files can be everywhere, you just must give the correct path relative to the folder where qb64.exe is in. See my libraries collection and/or GuiTools, there are .h files scattered all over, but the respective DECLARE LIBRARY statements define the relative path to them, assuming the qb64 base folder as root directory.

EDIT:
@moises1953, did you try to waive to the .\ in front of your DLL name? -- AFAIK the name only should be enough to designate the DLL to the same folder as your program exe.
« Last Edit: March 18, 2021, 01:47:09 pm by RhoSigma »
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #4 on: March 18, 2021, 01:47:48 pm »
Sorry, but that's absolutly wrong b+, the .h files can be everywhere, you just must give the correct path relative to the folder where qb64.exe is in. See my libraries collection and/or GuiTools, there are .h files scattered all over, but the respective DECLARE LIBRARY statements define the relative path to them, assuming the qb64 base folder as root directory.

b+
Quote
they won't even work from your app folder

Not absolutely. Put an .h file in the folder with all your sound and image and source bas, will it be found? no, sure maybe fully pathed or relative path but not the obvious place to be included in a proper search!
« Last Edit: March 18, 2021, 01:50:07 pm by bplus »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Deployment of application with DLL in Windows 10
« Reply #5 on: March 18, 2021, 01:57:57 pm »
bplus, you just make the path in Declare Library match the absolute or relative path. Of course it won't find it without you telling it where it exists.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #6 on: March 18, 2021, 02:02:43 pm »
bplus, you just make the path in Declare Library match the absolute or relative path. Of course it won't find it without you telling it where it exists.

And I am not saying you can't do that. WTH?

When you leave it up to someone else to compile the source, there is no telling where they are going to put the source so there really is no way of telling where the path or relative path is going to be. So in my opinion the next best thing to do is to put it in your/their QB64.exe folder.
« Last Edit: March 18, 2021, 02:07:07 pm by bplus »

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #7 on: March 18, 2021, 02:11:25 pm »
When you leave it up to someone else to compile the source, there is no telling where they are going to put the source so there really no way of telling where the path of relative path is going to be. So in my opinion the next best thing to do is to put it in your QB64.exe folder.

Ah, now I got your point, you're right :) That's why I mention on my Libs/GuiTools downloads to extract into the QB64 folder and mention it within the HTML docs again and also in the forum several times. You are correct, somewere you need a fixpoint, even for relative paths...
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Deployment of application with DLL in Windows 10
« Reply #8 on: March 18, 2021, 04:23:00 pm »
@bplus I misunderstood you. And I'm just now saying that because my internet on my phone wouldn't allow me to post the reply. Apologies, friend.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #9 on: March 18, 2021, 04:47:43 pm »
@bplus I misunderstood you. And I'm just now saying that because my internet on my phone wouldn't allow me to post the reply. Apologies, friend.

s'Ok, my Dad was like that too! He'd say something and you think, WTH? then a little more explanation and oh yeah!

I'm sorry too, I am thinking one thing and my fingers are typing something else ;P

Back on topic, are DLL's searched for like .h files? I don't know, that's "under-the-hood" (a term I picked reading a book on QB4.5 back in 90's).

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Deployment of application with DLL in Windows 10
« Reply #10 on: March 20, 2021, 02:46:29 pm »
Well, if you are going to deploy an application with a DLL and you want it to look for it in the executable folder using 'DECLARE DYNAMIC LIBRARY ". \ <Dll name>", it will not do it, unless it is the same path in which it was compiled .
For more information read the initial post.