Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DllNotFoundException nlopt_x64.dll #29

Closed
dklein0 opened this issue May 30, 2022 · 3 comments
Closed

DllNotFoundException nlopt_x64.dll #29

dklein0 opened this issue May 30, 2022 · 3 comments

Comments

@dklein0
Copy link

dklein0 commented May 30, 2022

I NuGet installed NLOptNet and copy/pasted some code from the ReadMe

When I execute the line:
var solver = new NLoptSolver(NLoptAlgorithm.LN_COBYLA, 1, 0.001, 100)

I get the below error

(Note: I am using .NET Framework 4.8. I also downloaded and installed https://github.com/stevengj/NLoptBuilder/releases/download/v2.6.1/NLopt.v2.6.1.x86_64-w64-mingw32.tar.gz and I even copied the libnlopt.dll from its bin directory to my executable directory and renamed it to nlopt_x64.dll.)

System.DllNotFoundException
HResult=0x80131524
Message=Unable to load DLL 'nlopt_x64.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source=NLoptNet
StackTrace:
at NLoptNet.NLoptSolver.nlopt_create64(NLoptAlgorithm algorithm, UInt32 n)
at NLoptNet.NLoptSolver..ctor(NLoptAlgorithm algorithm, UInt32 numVariables, Double relativeStoppingTolerance, Int32 maximumIterations, Nullable`1 childAlgorithm)

@BrannonKing
Copy link
Owner

BrannonKing commented Jun 1, 2022

What OS are you running on? And you verified that you're running an x64 build of your C# application? Perhaps there's a dependency missing. You could try dumpbin /DEPENDENTS nlopt_x64.dll and verify that you have all the dependent DLLs. I'm assuming that the .NET 4.7 target will automatically work for .NET 4.8, but I don't know that for sure. Are you able to use .NET Core instead?

@dklein0
Copy link
Author

dklein0 commented Jun 2, 2022

Ok, I realized my mistake. Since it was looking for nlopt_x64.dll, not nloptNET_x64.dll I thought it was looking for the underlying nlopt library. So I installed it from the nlopt binaries for windows. I now realize that NuGet installed the nloptnet library as nlopt.dll. I renamed it to nlopt_x64.dll and now it works.

May I suggest updating the NuGet package to install the library with the correct name? Alternatively, add instructions in the README file.

In any case, thank you ever so much for making the .NET interface available.

@BrannonKing
Copy link
Owner

Fixed in 1.4.2

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

No branches or pull requests

2 participants