Since version 1.39.5 building with -DBUILD_SHARED_LIBS:BOOL=ON on Windows (in my case with GCC+MinGW-w64) fails.
The reason is that in source/MaterialXCore/Value.h there is a template class
template <class T> class TypedValue : public Value
whose functions are defined with MX_CORE_API, which is in that case defined as __declspec(dllexport).
This results in the following build errors:
In file included from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Element.h:16,
from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Geom.h:14,
from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Interface.h:14,
from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Definition.h:14,
from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Node.h:14,
from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Material.h:14,
from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Look.h:14,
from R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Document.h:14:
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:130:17: error: function 'MaterialX_v1_39_5::TypedValue<T>::TypedValue()' definition is marked dllimport [-Wtemplate-body]
130 | MX_CORE_API TypedValue() :
| ^~~~~~~~~~
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:134:26: error: function 'MaterialX_v1_39_5::TypedValue<T>::TypedValue(const T&)' definition is marked dllimport [-Wtemplate-body]
134 | MX_CORE_API explicit TypedValue(const T& value) :
| ^~~~~~~~~~
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:138:25: error: function 'MaterialX_v1_39_5::TypedValue<T>::~TypedValue()' definition is marked dllimport [-Wtemplate-body]
138 | MX_CORE_API virtual ~TypedValue() { }
| ^
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:141:26: error: function 'MaterialX_v1_39_5::ValuePtr MaterialX_v1_39_5::TypedValue<T>::copy() const' definition is marked dllimport [-Wtemplate-body]
141 | MX_CORE_API ValuePtr copy() const override
| ^~~~
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:147:22: error: function 'void MaterialX_v1_39_5::TypedValue<T>::setData(const T&)' definition is marked dllimport [-Wtemplate-body]
147 | MX_CORE_API void setData(const T& value)
| ^~~~~~~
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:153:22: error: function 'void MaterialX_v1_39_5::TypedValue<T>::setData(const MaterialX_v1_39_5::TypedValue<T>&)' definition is marked dllimport [-Wtemplate-body]
153 | MX_CORE_API void setData(const TypedValue<T>& value)
| ^~~~~~~
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:159:26: error: function 'const T& MaterialX_v1_39_5::TypedValue<T>::getData() const' definition is marked dllimport [-Wtemplate-body]
159 | MX_CORE_API const T& getData() const
| ^~~~~~~
R:/winlibs16.1.0msvcrt64/MaterialX-1.39.5/source/MaterialXCore/Value.h:171:22: error: function 'bool MaterialX_v1_39_5::TypedValue<T>::isEqual(MaterialX_v1_39_5::ConstValuePtr) const' definition is marked dllimport [-Wtemplate-body]
171 | MX_CORE_API bool isEqual(ConstValuePtr other) const override
| ^~~~~~~
ninja: build stopped: subcommand failed.
Since version 1.39.5 building with
-DBUILD_SHARED_LIBS:BOOL=ONon Windows (in my case with GCC+MinGW-w64) fails.The reason is that in
source/MaterialXCore/Value.hthere is a template classwhose functions are defined with
MX_CORE_API, which is in that case defined as__declspec(dllexport).This results in the following build errors: