-
Notifications
You must be signed in to change notification settings - Fork 247
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
Pybind11/fixiling windows link problems #1830
Pybind11/fixiling windows link problems #1830
Conversation
@roigcarlo do you think it would be possible to write a few short lines (on the wiki or otherwise) summarizing the best practices regarding this issue? I'd be happy to help check that applications are properly configured but honestly at this point I don't know what to put in the |
@jcotela Sure. Sorry for not doing this straight from the begining but we ended up facing problems as they appeared. The problem Pybind changed how things work a bit while creating modules, and one of the changes made impossible to to have a python module as a dependency of one application, drawing derived apps impossible to compile with the old system (as the symbols were inside the module). In order to solve this, we agreed to divide the applications that are dependencies into This has increased the number of symbols that need to be visible from the "interface", all files that with Solution Missing exported classes: class foo {} to class KRATOS_API(APPLICATION) foo {} Variables: KRATOS_DEFINE_VARIABLE(type, FOO) to KRATOS_DEFINE_APPLICATION_VARIABLE(APPLICATION, type, FOO) Local Flags: KRATOS_DEFINE_LOCAL_FLAG(FOO) to KRATOS_DEFINE_LOCAL_APPLICATION_FLAG(APPLICATION, FOO) Template instantiation in the interface of non header classes This is more tricky. If you happen to expose a templated class and such class in non header-only, you must explicitly instantiate that in your "core" application, for example in the foo_application.cpp file. #foo.h
template<typename Ta, typename Tb> class KRATOS_API(FOO_APPLICATION) MyTemplateClass{
}
#foo.cpp
MyTemplateClass::MyTemplateClass() {
std::cout << "I am implemented in a cpp file" << std::endl;
} and # add_utilities_to_python.cpp
class_<MyTemplateClass<int, int>>(m, "MyTemplateClassInts").def(init<>);
class_<MyTemplateClass<double, double>>(m, "MyTemplateClassDoubles").def(init<>); This will crash, and you need to add: # foo_application.cpp
template class MyTemplateClass<int, int>;
template class MyTemplateClass<double, double>; |
@roigcarlo Thanks a lot for taking the time to write a full explaination of the issue! I fully understand why this was not done in advance, but having it will be extremely useful for the rest of us to avoid repeating the original mistakes. I've gone ahead and copied your post to the wiki here so that it won't get lost once we merge this. |
Several compilation problems fixed on win.
Mainly the problem is that additional symbols are needed to be exported in case the separation of the "core" and the "interface" has been made (or is it planed). We try to enforce this in Linux as well in the next weeks so compilation in both systems is as close as possible.
@KratosMultiphysics/team-maintainers I just want to let you know that this may happen to other apps if you are using windows. As it will not be the case for all apps it is better to fix (in my opinion) them one by one as the problems appear instead changing in case is not necessary.