[OS Windows] > LoadLibrary failed with error 127

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
User avatar
AlSith
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Dec 20, 2019 7:43 am

[OS Windows] > LoadLibrary failed with error 127

Post by AlSith »

Hi guys,

I compiled the wxWidgets-3.1.3 in debugging on Windows (I use a virtual machine with Windows XP; cl compiler) and I compiled my application.
The previous version used wxWidgets-2.9.3 compiled in ANSI mode.
Now, when I load my personal libraries, the wxDynamicLibrary::Load() (::LoadLibrary), returns an error with code 127. Looking on the net, I checked with DependencyWalker and there is only one dependency in error with the library 'msjava.dll', but also the libraries of the old version have the same "error", let's say ..

someone who could suggest me what and where to check for any coding problems..?? ..I may have missed some define in compilation..??

Code: Select all

wxDynamicLibrary *library = new wxDynamicLibrary(file, wxDL_NOW|wxDL_GLOBAL);
file is a wxString containing the full path for "C:\xxxxx\win\debug\plugins\libplugcli_xxxx.dll"
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [OS Windows] > LoadLibrary failed with error 127

Post by doublemax »

Error 127 means that a procedure is not found in the DLL. When switching to a new wxWidgets version, did you also rebuild the DLLs?
Use the source, Luke!
User avatar
AlSith
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Dec 20, 2019 7:43 am

Re: [OS Windows] > LoadLibrary failed with error 127

Post by AlSith »

Yes doublemax,

I rebuild all the project linking new wx sources/dlls.
We abandoned that "strange" design choice of UTF8 on Windows and I recompiled everything by letting Windows use its native format.
The program will then encode the formats in case of communication with a linux/UTF8 server.

The thing that makes me strange is that the same libraries before did not return this error .. and I have not added new methods; could it be a compile problem?

I compile my project with the following define:

Code: Select all

DEFINES=/D "WIN32W /D "__WXMWS__" /D "WXUSINGDLL" /D "_WINDOWS" /D "_UNICODE"
this last added now (but I tried to compile even without and it doesn't change the result)

The wxWidgets are compiled with options:

Code: Select all

BUILD = debug
DEBUG_FLAG = 1
DEBUG_INFO = default
DEBUG_RUNTIME_LIBS = default
MONOLITHIC = 1
USE_GUI = 1
USE_HTML = 1
USE_PROPGRID = 1
USE_STC = 1
USE_EXCEPTIONS = 1
USE_RTTI = 1
USE_THREADS = 1
RUNTIME_LIBS = dynamic
..all other options in the file "build\msw\config.vc" are 0
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: [OS Windows] > LoadLibrary failed with error 127

Post by PB »

AlSith wrote: Fri Aug 07, 2020 3:43 pm I compile my project with the following define:

Code: Select all

DEFINES=/D "WIN32W /D "__WXMWS__" /D "WXUSINGDLL" /D "_WINDOWS" /D "_UNICODE"
The first two defines are incorrect; however, I am not sure it matters here.
AlSith wrote: Fri Aug 07, 2020 3:43 pm The wxWidgets are compiled with options:

Code: Select all

...
So UNICODE is set to 0 there as well?

The way you build wxWidgets is unusual, one is not supposed to modify config.vc, the options are usualy changed either at command line or in the master setup.h.

TBH, I am surprised that wxWidgets 3.1.3 still even run on Windows XP. Out of curiosity, which compiler are you using there?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: [OS Windows] > LoadLibrary failed with error 127

Post by ONEEYEMAN »

Hi,
Please fix you define as PB wrote.
Next, check that you put all libraries in the same directory as executable (wx and your own).
And make sure its a new (i.e.rebuilt one) copy of the libraries.

Thank you.
User avatar
AlSith
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Dec 20, 2019 7:43 am

Re: [OS Windows] > LoadLibrary failed with error 127

Post by AlSith »

Sorry guys.

The define have been reported incorrectly, because I rewrote them by hand, unable to copy them from the virtual machine; the executable is in a main folder, in which I copied the compiled dll of the wx by hand. In the same root there is a folder that contains the dlls of the program to load that generate the error.
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [OS Windows] > LoadLibrary failed with error 127

Post by doublemax »

Can you trace through the code and tell which procedure is not found? If yes, please post its signature (name and all parameters).
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: [OS Windows] > LoadLibrary failed with error 127

Post by ONEEYEMAN »

Hi,
What is failing - the actual LoadLibrary() call or the program can't find the appropriate function in the dll?

Thank you.
User avatar
AlSith
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Dec 20, 2019 7:43 am

Re: [OS Windows] > LoadLibrary failed with error 127

Post by AlSith »

with VisualStudio I'm able to debug only until the call

Code: Select all

return ::LoadLibrary(libname.t_str());
in the file
wxWidgets-3.1.3/src/msw/dlmsw.cpp:163
..modifying the call, I insert a call to GetLastError() and I can see that the error code is the 127.. also if I try with other libraries, the result doesn't change.

In adding, I search the code of LoadLibrary, I find that the ultimate call is the specific
LoadLibraryExW(libname, handle, flags);
which is called by default with two 0 as second and third parameter. I try to change the flags one and, as result, all libraries are loaded, but the process run and the cliend doens't appear.. I report it for completeness, but I'm not sure if the two are connected .. certainly the coincidence is strange .. obviously, it doesn't seem appropriate to modify the wx at this level .. there must be something before, but I don't understand what and where is it.

Thanks for your support.
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [OS Windows] > LoadLibrary failed with error 127

Post by doublemax »

Upon further Googling, an error 127 at LoadLibrary can also mean that the DLL itself if found, but it has a dependency on another DLL which is not found. Is this the case for your DLL?

https://stackoverflow.com/questions/105 ... r-code-127
Use the source, Luke!
User avatar
AlSith
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Dec 20, 2019 7:43 am

Re: [OS Windows] > LoadLibrary failed with error 127

Post by AlSith »

I saw this, and other similar, post before write here. I analyzed few of my dlls with DependencyWalker, and it resulted that there is only one lost link with the msjava.dll.. but I don’t think that the problem is this because analyzing the previous version of the same dlls there is already this ‘problem’, and, for that version, this problem there was never come out.

Could you suggest me some other method/way to deeply analyze this problem..??
it could be a problem due to a difference with the encoding between windows libraries and mine ones..??
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: [OS Windows] > LoadLibrary failed with error 127

Post by ONEEYEMAN »

Hi,
Can you try to rebuild everything? WxWidgets and your program?

Thank you.
User avatar
AlSith
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Dec 20, 2019 7:43 am

Re: [OS Windows] > LoadLibrary failed with error 127

Post by AlSith »

tomorrow morning (Italian time zone) I’ll try, once again, to rebuild all the solutions .. but I doubt to solve

I update you tomorrow.
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [OS Windows] > LoadLibrary failed with error 127

Post by doublemax »

Do the plugin DLLs use wxWidgets, too? Then my best guess is that there is some difference in the build settings between the main application and the plugins.
Use the source, Luke!
User avatar
AlSith
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Dec 20, 2019 7:43 am

Re: [OS Windows] > LoadLibrary failed with error 127

Post by AlSith »

Hy guys,

I'm so sorry .. after leaving the UTF8 compilation project on Windows, I forgot to recompile the wxpdfdoc .. what a careless .. !!

The error seems to be solved. Thanks everyone for the support.
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
Post Reply