DLL is not loading

ty wang 41 Reputation points
2021-11-08T20:30:23.86+00:00

I'm having trouble running my program. It shows the following dialog:

The procedure entry point nlopt_add_equality_constraint could not be located in the dynamic link library G:\WorkDir\Projects\xxxxxxx\x64\Debug\xxxxxxx.exe.

nlopt_add_equality_constraint should be in libnlopt.dll, and I checked it, the export is ok. So I turned on "Show loader Snaps" flag and got some log:
https://pastebin.com/p381nCXg

Line 1153
DebugString: "10afc:2818 @ 197842421 - LdrpNameToOrdinal - WARNING: Procedure "nlopt_add_equality_constraint" could not be located in DLL at base 0x000000006D7C0000."

Line 578 and 579
DLL Loaded: 000000006D7C0000 G:\WorkDir\Projects\xxxxxxx\x64\Debug\libopenblas.dll
DLL Loaded: 000000006A740000 G:\WorkDir\Projects\xxxxxxx\x64\Debug\libnlopt.dll

The log shows that it tries to load nlopt_add_equality_constraint from the wrong DLL. libnlopt was compiled with 64bit mingw. It was working, and the problem happened for some unknown reason.
I tried to recompile nlopt and update the lib and dll, the problem is still there. Is there any other cause?

Update:
Seems that if I enable one of them(nlopt/openblas), it works, but if both are enabled, the imports get messed up.
I made a minimum example, use x64 Debug to compile.
https://1drv.ms/u/s!AkqxTizATCPayWNinQzbqmlu2UIS?e=bl9bKx

Update2
I removed the c++ code and calls openblas/nlopt's C api directly. Note the changes sometimes needs "rebuild" to take effect.
https://1drv.ms/u/s!AkqxTizATCPayWT3LjElc5e7zltX?e=2rJgIB

Also here's the import shown by Dependencies
only nlopt used, working
147777-nlopt.png
only openblas used, working, note the import name is correct.
147851-openblas.png
both used, not working, the import of openblas is the same as nlopt (overwritten?).
147842-both.png

Thanks

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
{count} votes

Answer accepted by question author
  1. Minxin Yu 13,506 Reputation points Microsoft External Staff
    2021-11-09T09:26:52.233+00:00

    Hi, @ty wang

    Since I can't see the code of the DLL, I tried not to use the namespace, and instead use codes such as nlopt::. Also, I modified the code m, and it can run.
    147761-%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE-2021-11-09-172841.png

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.