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

IpCalculatedQuantities compile errors on MSVC #572

Closed
mahonbt1 opened this issue Apr 29, 2022 · 5 comments
Closed

IpCalculatedQuantities compile errors on MSVC #572

mahonbt1 opened this issue Apr 29, 2022 · 5 comments

Comments

@mahonbt1
Copy link

We've started making use of the 'IpCalculatedQuantities*' object via the Ipopt::TNLP::intermediate_callback(...) method on my team, and we run into issues when compiling on Visual Studio. On our Msys2 and linux/gcc CI pipelines everything works, but the MSVC pipeline fails and gives \thirdparty\Ipopt-3.14.5-win64-msvs2019-md\include\coin-or\IpSmartPtr.hpp(640,1): error C2027: use of undefined type 'Ipopt::Matrix' as the error repeated 100s of times.

I narrowed it down to the #include "IpIpoptCalculatedQuantities.hpp" file and made a stub header for our MSVC pipeline, but it would be nice if I could get away from that.

@svigerske
Copy link
Member

It looks to me like the forward declaration of Ipopt::Matrix in IpIpoptCalculatedQuantities.hpp is intentional.
Do you just need to add an #include "IpMatrix.hpp" before your #include IpIpoptCalculatedQuantities.hpp?
Or how does your "stub header" look like?

@mahonbt1
Copy link
Author

Including "IpMatrix.hpp" and "IpSymMatrix.hpp" before the include for "IpIpoptCalculatedQuantities.hpp" seems to have solved my compile problem at the expense of a whole lot more warnings, but that's to be expected.

I guess my question more narrowly is why does this show up on the MSVC build pipeline, and not on the gcc ones? We're using the precompiled dlls for our MSVC work rather than compiling from source so that's my best guess at the difference.

Why do I have to do these two extra includes for this toolchain, and not for the others?

@mahonbt1
Copy link
Author

The stub header was a copy and paste of the IpIpoptCalculatedQuantities.hpp header that I just pruned back to give a fake implementation of the methods we were using. Core development is on linux so the feature was just going to be unsupported on the MSVC branch.

@svigerske
Copy link
Member

I would guess that GCC was ok with SmartPtr<Matrix> when it didn't know the actual declaration of Matrix as long as your code didn't really use these matrices. And MSVC may be more picky.

@mahonbt1
Copy link
Author

Since I've got a workaround I think this can be closed. I'll leave that to your discretion if there are any changes needed within ipopt to support MSVC builds.

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