You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to compile the library using MSYS2 GNU C++.
However there is a problem on how GNU C++ and Microsoft CL handle the template instantiation.
The problem is located in WSTP .h/.c. files, in the template definitions as (for example in Get.h)
When GNU C++ compiler includes the .h in ANOTHER project, it instantiate the template.
BUT the template is ALREADY instantiated and present in "libLLU.a", the library created compiling these source files.
This generates a linker error for "multiple instances of the same template".
The solution can be simple: it is enough to replace
#ifndef _WIN32
with
#if !defined(_WIN32) || defined(__GNUC__)
where GNUC is a unique predefined macro in GNU C/C++ compiler, in this way, the templates are instantiates inside *.c and made them available as "extern template" in the other projects.
The text was updated successfully, but these errors were encountered:
corradomio
changed the title
[ENH] Duplicate templates using MSYS2 GNU g++ compiler
[ENH] Duplicate templates using MSYS2 GNU C++ compiler
Jul 21, 2023
corradomio
changed the title
[ENH] Duplicate templates using MSYS2 GNU C++ compiler
[BUG] Duplicate templates using MSYS2 GNU C++ compiler
Jul 22, 2023
It is possible to compile the library using MSYS2 GNU C++.
However there is a problem on how GNU C++ and Microsoft CL handle the template instantiation.
The problem is located in WSTP .h/.c. files, in the template definitions as (for example in Get.h)
MSYS2 GNU C++ define the macro "_WIN32". This means that in "Get.c/Get.h" is active the "else" part of
When GNU C++ compiler includes the .h in ANOTHER project, it instantiate the template.
BUT the template is ALREADY instantiated and present in "libLLU.a", the library created compiling these source files.
This generates a linker error for "multiple instances of the same template".
The solution can be simple: it is enough to replace
with
where GNUC is a unique predefined macro in GNU C/C++ compiler, in this way, the templates are instantiates inside *.c and made them available as "extern template" in the other projects.
The text was updated successfully, but these errors were encountered: