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

Access more detailed error message via nlopt_get_errmsg? #172

Open
helske opened this issue Nov 5, 2024 · 1 comment
Open

Access more detailed error message via nlopt_get_errmsg? #172

helske opened this issue Nov 5, 2024 · 1 comment

Comments

@helske
Copy link

helske commented Nov 5, 2024

I'm using nloptrAPI in my pacakge and trying to figure out why my optimization fails with generic error code -1. I noticed that there is a function nlopt_get_errmsg in NLopt but when trying to use it in my R package I get an error undefined reference to nlopt_get_errmsg'` during the compilation. Is this function missing from the API, and if so, could it be added?

@eddelbuettel
Copy link
Contributor

The nlopt.h header has it defined as

NLOPT_EXTERN(const char *) nlopt_get_errmsg(nlopt_opt opt);

and the problem may be that we do not hold one (long enough?) to the nlopt_opt instance describing it. So it would likely require some minor rejigging of things.

A cheapish way may be put a fixed-length char buffer somewher (easy and ugly: as a global var), say char buf[256], and in the case of error have that function called to fill it. You can then easily add an R accessor to buf to return its content as a character variable to R.

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