Page 1 of 1

Can't locate DLL

Posted: Fri May 17, 2024 12:05 am
by blueb
Quick question..

This program runs well on my main computer. (Win 11 Pro 64 and Pure 6.11 beta)

Here's the problem snippet...

Code: Select all

; Libraries required
UseSQLiteDatabase("sqlcipher.dll")   ; Use the DLL from 'DB Browser for SQLCipher'
UseMD5Fingerprint()

Declare CheckDatabaseUpdate(Database, Query$)
Declare.s Requester(Title$,Message$,DefaultString$)

;- Globals
Global DatabaseFile.s = GetCurrentDirectory()+"PassKeeper.db"
Global theImage.s
Global Quit

If OpenDatabase(0, DatabaseFile, "", "") 
     CheckDatabaseUpdate(0, "PRAGMA key = 'Lions On A Diet'")  ; Database 'SALT'
     
     If DatabaseQuery(0, "SELECT * FROM Keeper WHERE Website LIKE '%AAAA Passcode%';") ; get the password string from row selected
            While NextDatabaseRow(0)
               theImage = GetDatabaseString(0, 3) ; go to col 3 where the password 'Blueb' is located. (you can change this after initial opening)
            Wend
           FinishDatabaseQuery(0)
    EndIf

EndIf
As you can see from the code, I am using 'DB Browser for SQLCipher'
(but I'm only using the sqlcipher.dll. And... it works well on my main computer)

When I try it on my Win 11 Home tablet (using PureBasic editor or the EXE), it appears not to find the sqlcipher.DLL

I get this error...
[16:36:54] [ERROR] Passkeeper.pb (Line: 78)
[16:36:54] [ERROR] UseODBCDatabase(), UseSQLiteDatase() or UsePostgreSQLDatabase() need to be called before using database commands.

Which is odd, as "sqlcipher.dll" is in the same directory as the code.

Debugging...
Debug UseSQLiteDatabase("sqlcipher.dll")
gives me a zero.
It's like PB 6.10 LTS can't find the DLL file to get to the next step.


I've tried adding..
UseSQLiteDatabase() No error, but can't find database
UseSQLiteDatabase(GetCurrentDirectory() + "sqlcipher.dll") does not work

Global myDLL.s = GetCurrentDirectory() + "sqlcipher.dll"
UseSQLiteDatabase(myDLL) Does not work


PS - I have the complete 'DB Browser for SQLCipher' installed and have no trouble opening the DB file directly.

Maybe there's some Windows setting that hides DLL's ??

Re: Can't locate DLL

Posted: Fri May 17, 2024 12:17 am
by AZJIO

Re: Can't locate DLL

Posted: Fri May 17, 2024 7:44 am
by fryquez
That sqlcipher.dll has dependency, the PortableApp version needs libcrypto-1_1-x64.dll and vcruntime140.dll.

AZJIO is also right, never use GetCurrentDirectory() + "sqlcipher.dll"

Re: Can't locate DLL

Posted: Fri May 17, 2024 2:28 pm
by blueb
AZJIO is also right, never use GetCurrentDirectory() + "sqlcipher.dll"
Yes, of course. I was testing everything, trying to hunt down the reason for the inconsistency.
That sqlcipher.dll has dependency, the PortableApp version needs libcrypto-1_1-x64.dll and vcruntime140.dll.
I made an assumption that 'sqlcipher.dll' was the only file required. My Bad :)

I tried using 'Dependency Walker' to find dependencies, but was having trouble with the program, so I just continued on.

Today, I hunted down another program called 'Dependencies' on SourceForge that works well: https://sourceforge.net/projects/dependencies.mirror/

It showed that indeed libcrypto-1_1-x64.dll was required.(thanks fryquez), but only showed 'C:\WINDOWS\system32\kernel32.dll' as another dependency.

So I added libcrypto-1_1-x64.dll to my program's folder and everything is fine!

Thanks everyone