Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

error in LoadLibrary call in ceflib.pas if dll is not in same directory as exe #76

Open
chookhen60 opened this issue Apr 13, 2017 · 3 comments

Comments

@chookhen60
Copy link

chookhen60 commented Apr 13, 2017

In the CefLoadLib function in ceflib.pas (using build 2924 of Chrome, if you try to load the libcef.dll file from a different directory to the exe that you are running in / calling from (i.e. the CefLibrary variable has an explicit path e.g. c:\myFolder\libcef.dll), then you will end up with a LibHandle assignment of 0, and an OS error code of 126 ("The Specified module could not be found").

We believe this is an issue with the DLLs, where the libcef.dll file calls other DLLs which may be omitting the path that we specify in the LoadLibrary call's CefLibrary variable. After further inspection, we found that if we copy the relevant files into the same directory as the exe, and then run the application, then the problem no longer occurs and we receive a valid handle. This also backs up our theory that subsequent calls to other DLLs for CEF are not making use of the folder path we specified in the CefLibrary variable.

UPDATE: We have just completed testing to build in a solution which requires copying in the additional DLLs in which chain to the libcef.dll, and found that the only DLL that needs copying into the same directory as the exe is the chrome_elf.dll file.

While this would suggest a problem with the CEF and not the dcef3 project, I wanted to see if anyone was aware of this issue, and secondly a timeline on when an updated source for build 2987 of the CEF will be available?

We also tried downloading build 2987 directly from the CEF website, and copied the files into the directory we are wanting the files to be in, and we were able to then get a valid handle from the LoadLibrary call, but then our exe crashed with an access violation, suggesting unrelated breaking changes have been implemented with the CEF DLLs. Therefore our theory is the new CEF version 2987 will resolve the bug, and really just an accompanying dcef3 src with support for this version of CEF will resolve our issue.

Our software is a multi-exe application and we make use of CEF in many of our exe's, hence the reason for not wanting to reference the CEF DLLs locally.

Has anyone else come up against this issue and been able to resolve it in some straightforward way?

Thanks to hgourvest for this project and doing their best to keep the project up to date as best as you can!

@astral2k5
Copy link

Have you checked the CEF4Delphi project ? It's based on this one but updated more often:
https://github.com/salvadordf/CEF4Delphi

@chookhen60
Copy link
Author

Have you checked the CEF4Delphi project ? It's based on this one but updated more often:
https://github.com/salvadordf/CEF4Delphi

Thanks - We did have a brief look at that project, which looked promising, however the structure of the code files looks to be completely different, and didn't want to go down the path of integrating that version into our source unless absolutely necessary.

@mterrisse
Copy link

You just need to change
LibHandle := LoadLibrary(PChar(CefLibrary));
in CefLoadLib (ceflib.pas) to
LibHandle := LoadLibraryEx (PChar (LCefDll), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
where LCefDll is the full path of libcef.dll

Regards,

Michel Terrisse

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants