beltoforion/muparser

Error compiling muparser with Rtools/MinGW on Windows

thinhong opened this issue · 4 comments

Hi,

I embedded muparser into my R package with Rcpp. It can compile very well with GCC (on my Linux machine) but I encountered lots of warnings and errors when compiling it on Windows using the compiler MinGW in Rtools. Since this is an R package, on Windows I can only embed it with the MinGW in Rtools.

The main warning is: warning: [...] redeclared without dllimport attribute: previous dllimport ignored
And the main error is: error: definition of static data member [...] of dllimport'd class

Do you happen to know any way to fix these? I see there is a line for dllimport and dllexport in the muParserFixes.h but not sure whether these are solutions and how to fix it.

Thank you!

"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"D:/Program/Statistics/R-4.1.1/include" -DNDEBUG  -I'D:/Program/Statistics/R-4.1.1/library/Rcpp/include'     -std=c++17   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c muParser.cpp -o muParser.o
muParser.cpp:55:6: warning: 'static int mu::Parser::IsVal(const char_type*, int*, mu::value_type*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  int Parser::IsVal(const char_type* a_szExpr, int* a_iPos, value_type* a_fVal)
      ^~~~~~
muParser.cpp:79:2: warning: 'mu::Parser::Parser()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  Parser::Parser()
  ^~~~~~
muParser.cpp:97:7: warning: 'virtual void mu::Parser::InitCharSets()' redeclared without dllimport attribute after being referenced with dll linkage
  void Parser::InitCharSets()
       ^~~~~~
muParser.cpp:106:7: warning: 'virtual void mu::Parser::InitFun()' redeclared without dllimport attribute after being referenced with dll linkage
  void Parser::InitFun()
       ^~~~~~
muParser.cpp:160:7: warning: 'virtual void mu::Parser::InitConst()' redeclared without dllimport attribute after being referenced with dll linkage
  void Parser::InitConst()
       ^~~~~~
muParser.cpp:171:7: warning: 'virtual void mu::Parser::InitOprt()' redeclared without dllimport attribute after being referenced with dll linkage
  void Parser::InitOprt()
       ^~~~~~
muParser.cpp:178:7: warning: 'virtual void mu::Parser::OnDetectVar(mu::string_type*, int&, int&)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void Parser::OnDetectVar(string_type* /*pExpr*/, int& /*nStart*/, int& /*nEnd*/)
       ^~~~~~
muParser.cpp:212:13: warning: 'mu::value_type mu::Parser::Diff(mu::value_type*, mu::value_type, mu::value_type) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  value_type Parser::Diff(value_type* a_Var, value_type  a_fPos, value_type  a_fEpsilon) const
             ^~~~~~
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"D:/Program/Statistics/R-4.1.1/include" -DNDEBUG  -I'D:/Program/Statistics/R-4.1.1/library/Rcpp/include'     -std=c++17   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c muParserBase.cpp -o muParserBase.o
muParserBase.cpp:62:26: warning: 'mu::ParserBase::s_locale' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  std::locale ParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep<char_type>('.'));
                          ^~~~~~~~
muParserBase.cpp:64:19: warning: 'mu::ParserBase::g_DbgDumpCmdCode' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  bool ParserBase::g_DbgDumpCmdCode = false;
                   ^~~~~~~~~~~~~~~~
muParserBase.cpp:65:19: warning: 'mu::ParserBase::g_DbgDumpStack' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  bool ParserBase::g_DbgDumpStack = false;
                   ^~~~~~~~~~~~~~
muParserBase.cpp:73:45: warning: 'mu::ParserBase::c_DefaultOprt' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const char_type* ParserBase::c_DefaultOprt[] =
                                             ^
muParserBase.cpp:83:24: warning: 'mu::ParserBase::s_MaxNumOpenMPThreads' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const int ParserBase::s_MaxNumOpenMPThreads = 16;
                        ^~~~~~~~~~~~~~~~~~~~~
muParserBase.cpp:90:2: warning: 'mu::ParserBase::ParserBase()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  ParserBase::ParserBase()
  ^~~~~~~~~~
muParserBase.cpp:118:2: warning: 'mu::ParserBase::ParserBase(const mu::ParserBase&)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  ParserBase::ParserBase(const ParserBase& a_Parser)
  ^~~~~~~~~~
muParserBase.cpp:140:2: warning: 'virtual mu::ParserBase::~ParserBase()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  ParserBase::~ParserBase()
  ^~~~~~~~~~
muParserBase.cpp:151:14: warning: 'mu::ParserBase& mu::ParserBase::operator=(const mu::ParserBase&)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  ParserBase& ParserBase::operator=(const ParserBase& a_Parser)
              ^~~~~~~~~~
muParserBase.cpp:166:7: warning: 'void mu::ParserBase::Assign(const mu::ParserBase&)' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::Assign(const ParserBase& a_Parser)
       ^~~~~~~~~~
muParserBase.cpp:204:7: warning: 'void mu::ParserBase::SetDecSep(mu::char_type)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::SetDecSep(char_type cDecSep)
       ^~~~~~~~~~
muParserBase.cpp:218:7: warning: 'void mu::ParserBase::SetThousandsSep(mu::char_type)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::SetThousandsSep(char_type cThousandsSep)
       ^~~~~~~~~~
muParserBase.cpp:230:7: warning: 'void mu::ParserBase::ResetLocale()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ResetLocale()
       ^~~~~~~~~~
muParserBase.cpp:245:7: warning: 'void mu::ParserBase::InitTokenReader()' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::InitTokenReader()
       ^~~~~~~~~~
muParserBase.cpp:256:7: warning: 'void mu::ParserBase::ReInit() const' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::ReInit() const
       ^~~~~~~~~~
muParserBase.cpp:265:7: warning: 'virtual void mu::ParserBase::OnDetectVar(mu::string_type*, int&, int&)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::OnDetectVar(string_type* /*pExpr*/, int& /*nStart*/, int& /*nEnd*/)
       ^~~~~~~~~~
muParserBase.cpp:271:24: warning: 'const mu::ParserByteCode& mu::ParserBase::GetByteCode() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const ParserByteCode& ParserBase::GetByteCode() const
                        ^~~~~~~~~~
muParserBase.cpp:284:14: warning: 'mu::string_type mu::ParserBase::GetVersion(mu::EParserVersionInfo) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  string_type ParserBase::GetVersion(EParserVersionInfo eInfo) const
              ^~~~~~~~~~
muParserBase.cpp:328:7: warning: 'void mu::ParserBase::AddValIdent(mu::identfun_type)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::AddValIdent(identfun_type a_pCallback)
       ^~~~~~~~~~
muParserBase.cpp:338:7: warning: 'void mu::ParserBase::SetVarFactory(mu::facfun_type, void*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::SetVarFactory(facfun_type a_pFactory, void* pUserData)
       ^~~~~~~~~~
muParserBase.cpp:345:7: warning: 'void mu::ParserBase::AddCallback(const string_type&, const mu::ParserCallback&, mu::funmap_type&, const char_type*)' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::AddCallback(
       ^~~~~~~~~~
muParserBase.cpp:379:7: warning: 'void mu::ParserBase::CheckOprt(const string_type&, const mu::ParserCallback&, const string_type&) const' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::CheckOprt(const string_type& a_sName,
       ^~~~~~~~~~
muParserBase.cpp:400:7: warning: 'void mu::ParserBase::CheckName(const string_type&, const string_type&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::CheckName(const string_type& a_sName, const string_type& a_szCharSet) const
       ^~~~~~~~~~
muParserBase.cpp:417:7: warning: 'void mu::ParserBase::SetExpr(const string_type&)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::SetExpr(const string_type& a_sExpr)
       ^~~~~~~~~~
muParserBase.cpp:435:20: warning: 'const char_type** mu::ParserBase::GetOprtDef() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const char_type** ParserBase::GetOprtDef() const
                    ^~~~~~~~~~
muParserBase.cpp:444:7: warning: 'void mu::ParserBase::DefineNameChars(const char_type*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineNameChars(const char_type* a_szCharset)
       ^~~~~~~~~~
muParserBase.cpp:453:7: warning: 'void mu::ParserBase::DefineOprtChars(const char_type*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineOprtChars(const char_type* a_szCharset)
       ^~~~~~~~~~
muParserBase.cpp:462:7: warning: 'void mu::ParserBase::DefineInfixOprtChars(const char_type*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineInfixOprtChars(const char_type* a_szCharset)
       ^~~~~~~~~~
muParserBase.cpp:471:19: warning: 'const char_type* mu::ParserBase::ValidNameChars() const' redeclared without dllimport attribute after being referenced with dll linkage
  const char_type* ParserBase::ValidNameChars() const
                   ^~~~~~~~~~
muParserBase.cpp:481:19: warning: 'const char_type* mu::ParserBase::ValidOprtChars() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const char_type* ParserBase::ValidOprtChars() const
                   ^~~~~~~~~~
muParserBase.cpp:491:19: warning: 'const char_type* mu::ParserBase::ValidInfixOprtChars() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const char_type* ParserBase::ValidInfixOprtChars() const
                   ^~~~~~~~~~
muParserBase.cpp:501:7: warning: 'void mu::ParserBase::DefinePostfixOprt(const string_type&, mu::fun_type1, bool)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefinePostfixOprt(const string_type& a_sName, fun_type1 a_pFun, bool a_bAllowOpt)
       ^~~~~~~~~~
muParserBase.cpp:514:7: warning: 'void mu::ParserBase::Init()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::Init()
       ^~~~~~~~~~
muParserBase.cpp:531:7: warning: 'void mu::ParserBase::DefineInfixOprt(const string_type&, mu::fun_type1, int, bool)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineInfixOprt(const string_type& a_sName, fun_type1 a_pFun, int a_iPrec, bool a_bAllowOpt)
       ^~~~~~~~~~
muParserBase.cpp:550:7: warning: 'void mu::ParserBase::DefineOprt(const string_type&, mu::fun_type2, unsigned int, mu::EOprtAssociativity, bool)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineOprt(const string_type& a_sName, fun_type2 a_pFun, unsigned a_iPrec, EOprtAssociativity a_eAssociativity, bool a_bAllowOpt)
       ^~~~~~~~~~
muParserBase.cpp:572:7: warning: 'void mu::ParserBase::DefineStrConst(const string_type&, const string_type&)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineStrConst(const string_type& a_strName, const string_type& a_strVal)
       ^~~~~~~~~~
muParserBase.cpp:593:7: warning: 'void mu::ParserBase::DefineVar(const string_type&, mu::value_type*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineVar(const string_type& a_sName, value_type* a_pVar)
       ^~~~~~~~~~
muParserBase.cpp:617:7: warning: 'void mu::ParserBase::DefineConst(const string_type&, mu::value_type)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::DefineConst(const string_type& a_sName, value_type a_fVal)
       ^~~~~~~~~~
muParserBase.cpp:631:6: warning: 'int mu::ParserBase::GetOprtPrecedence(const token_type&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  int ParserBase::GetOprtPrecedence(const token_type& a_Tok) const
      ^~~~~~~~~~
muParserBase.cpp:667:21: warning: 'mu::EOprtAssociativity mu::ParserBase::GetOprtAssociativity(const token_type&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  EOprtAssociativity ParserBase::GetOprtAssociativity(const token_type& a_Tok) const
                     ^~~~~~~~~~
muParserBase.cpp:692:21: warning: 'const varmap_type& mu::ParserBase::GetUsedVar() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const varmap_type& ParserBase::GetUsedVar() const
                     ^~~~~~~~~~
muParserBase.cpp:716:21: warning: 'const varmap_type& mu::ParserBase::GetVar() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const varmap_type& ParserBase::GetVar() const
                     ^~~~~~~~~~
muParserBase.cpp:723:21: warning: 'const valmap_type& mu::ParserBase::GetConst() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const valmap_type& ParserBase::GetConst() const
                     ^~~~~~~~~~
muParserBase.cpp:739:21: warning: 'const funmap_type& mu::ParserBase::GetFunDef() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const funmap_type& ParserBase::GetFunDef() const
                     ^~~~~~~~~~
muParserBase.cpp:746:21: warning: 'const string_type& mu::ParserBase::GetExpr() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  const string_type& ParserBase::GetExpr() const
                     ^~~~~~~~~~
muParserBase.cpp:756:25: warning: 'mu::ParserBase::token_type mu::ParserBase::ApplyStrFunc(const token_type&, const std::vector<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  ParserBase::token_type ParserBase::ApplyStrFunc(
                         ^~~~~~~~~~
muParserBase.cpp:799:7: warning: 'void mu::ParserBase::ApplyFunc(std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&, std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&, int) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ApplyFunc(std::stack<token_type>& a_stOpt, std::stack<token_type>& a_stVal, int a_iArgCount) const
       ^~~~~~~~~~
muParserBase.cpp:889:7: warning: 'void mu::ParserBase::ApplyIfElse(std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&, std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ApplyIfElse(std::stack<token_type>& a_stOpt, std::stack<token_type>& a_stVal) const
       ^~~~~~~~~~
muParserBase.cpp:937:7: warning: 'void mu::ParserBase::ApplyBinOprt(std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&, std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ApplyBinOprt(std::stack<token_type>& a_stOpt, std::stack<token_type>& a_stVal) const
       ^~~~~~~~~~
muParserBase.cpp:984:7: warning: 'void mu::ParserBase::ApplyRemainingOprt(std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&, std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ApplyRemainingOprt(std::stack<token_type>& stOpt, std::stack<token_type>& stVal) const
       ^~~~~~~~~~
muParserBase.cpp:1033:13: warning: 'mu::value_type mu::ParserBase::ParseCmdCode() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  value_type ParserBase::ParseCmdCode() const
             ^~~~~~~~~~
muParserBase.cpp:1038:13: warning: 'mu::value_type mu::ParserBase::ParseCmdCodeShort() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  value_type ParserBase::ParseCmdCodeShort() const
             ^~~~~~~~~~
muParserBase.cpp:1084:13: warning: 'mu::value_type mu::ParserBase::ParseCmdCodeBulk(int, int) const' redeclared without dllimport attribute after being referenced with dll linkage
  value_type ParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const
             ^~~~~~~~~~
muParserBase.cpp:1258:7: warning: 'void mu::ParserBase::CreateRPN() const' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::CreateRPN() const
       ^~~~~~~~~~
muParserBase.cpp:1525:13: warning: 'mu::value_type mu::ParserBase::ParseString() const' redeclared without dllimport attribute after being referenced with dll linkage
  value_type ParserBase::ParseString() const
             ^~~~~~~~~~
muParserBase.cpp:1561:8: warning: 'void mu::ParserBase::Error(mu::EErrorCodes, int, const string_type&) const' redeclared without dllimport attribute after being referenced with dll linkage
  void  ParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const string_type& a_sTok) const
        ^~~~~~~~~~
muParserBase.cpp:1572:7: warning: 'void mu::ParserBase::ClearVar()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ClearVar()
       ^~~~~~~~~~
muParserBase.cpp:1584:7: warning: 'void mu::ParserBase::RemoveVar(const string_type&)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::RemoveVar(const string_type& a_strVarName)
       ^~~~~~~~~~
muParserBase.cpp:1599:7: warning: 'void mu::ParserBase::ClearFun()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ClearFun()
       ^~~~~~~~~~
muParserBase.cpp:1612:7: warning: 'void mu::ParserBase::ClearConst()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ClearConst()
       ^~~~~~~~~~
muParserBase.cpp:1624:7: warning: 'void mu::ParserBase::ClearPostfixOprt()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ClearPostfixOprt()
       ^~~~~~~~~~
muParserBase.cpp:1635:7: warning: 'void mu::ParserBase::ClearOprt()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ClearOprt()
       ^~~~~~~~~~
muParserBase.cpp:1646:7: warning: 'void mu::ParserBase::ClearInfixOprt()' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::ClearInfixOprt()
       ^~~~~~~~~~
muParserBase.cpp:1657:7: warning: 'void mu::ParserBase::EnableOptimizer(bool)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::EnableOptimizer(bool a_bIsOn)
       ^~~~~~~~~~
muParserBase.cpp:1670:7: warning: 'static void mu::ParserBase::EnableDebugDump(bool, bool)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::EnableDebugDump(bool bDumpCmd, bool bDumpStack)
       ^~~~~~~~~~
muParserBase.cpp:1686:7: warning: 'void mu::ParserBase::EnableBuiltInOprt(bool)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::EnableBuiltInOprt(bool a_bIsOn)
       ^~~~~~~~~~
muParserBase.cpp:1697:7: warning: 'bool mu::ParserBase::HasBuiltInOprt() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  bool ParserBase::HasBuiltInOprt() const
       ^~~~~~~~~~
muParserBase.cpp:1705:12: warning: 'mu::char_type mu::ParserBase::GetArgSep() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  char_type ParserBase::GetArgSep() const
            ^~~~~~~~~~
muParserBase.cpp:1714:7: warning: 'void mu::ParserBase::SetArgSep(mu::char_type)' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::SetArgSep(char_type cArgSep)
       ^~~~~~~~~~
muParserBase.cpp:1724:7: warning: 'void mu::ParserBase::StackDump(const std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&, const std::stack<mu::ParserToken<double, std::__cxx11::basic_string<char> > >&) const' redeclared without dllimport attribute after being referenced with dll linkage
  void ParserBase::StackDump(const std::stack<token_type>& a_stVal, const std::stack<token_type>& a_stOprt) const
       ^~~~~~~~~~
muParserBase.cpp:1814:13: warning: 'mu::value_type mu::ParserBase::Eval() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  value_type ParserBase::Eval() const
             ^~~~~~~~~~
muParserBase.cpp:1827:14: warning: 'mu::value_type* mu::ParserBase::Eval(int&) const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  value_type* ParserBase::Eval(int& nStackSize) const
              ^~~~~~~~~~
muParserBase.cpp:1851:6: warning: 'int mu::ParserBase::GetNumResults() const' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  int ParserBase::GetNumResults() const
      ^~~~~~~~~~
muParserBase.cpp:1857:7: warning: 'void mu::ParserBase::Eval(mu::value_type*, int)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  void ParserBase::Eval(value_type* results, int nBulkSize)
       ^~~~~~~~~~
muParserBase.cpp: In function 'void __tcf_3()':
muParserBase.cpp:62:14: error: definition of static data member 'mu::ParserBase::s_locale' of dllimport'd class
  std::locale ParserBase::s_locale = std::locale(std::locale::classic(), new change_dec_sep<char_type>('.'));
              ^~~~~~~~~~
muParserBase.cpp: In member function 'const char_type** mu::ParserBase::GetOprtDef() const':
muParserBase.cpp:73:19: error: definition of static data member 'mu::ParserBase::c_DefaultOprt' of dllimport'd class
  const char_type* ParserBase::c_DefaultOprt[] =
                   ^~~~~~~~~~
muParserBase.cpp: In static member function 'static void mu::ParserBase::EnableDebugDump(bool, bool)':
muParserBase.cpp:64:7: error: definition of static data member 'mu::ParserBase::g_DbgDumpCmdCode' of dllimport'd class
  bool ParserBase::g_DbgDumpCmdCode = false;
       ^~~~~~~~~~
muParserBase.cpp:65:7: error: definition of static data member 'mu::ParserBase::g_DbgDumpStack' of dllimport'd class
  bool ParserBase::g_DbgDumpStack = false;
       ^~~~~~~~~~
make: *** [D:/Program/Statistics/R-4.1.1/etc/x64/Makeconf:245: muParserBase.o] Error 1

Sorry, can't help you i don't use mingw.

Hi Ingo,

When I changed line 69 to DLL_EXPORT it fixed my case. Hope to help somebody having the same issue as me lol. Thank you so much for such a great library!

image

Thanks for the feedback. I'm trying to figure this one out. If you changed line 69 to MUPARSER_HELPER_DLL_EXPORT you did the same that the -DBUILD_SHARED_LIBS=ON/OFF would do when using cmake. I never used mingw, so this may be a stupid question but does cmake work with mingw? Did you use cmake of did you have to create your own build script?

Thanks for the feedback. I'm trying to figure this one out. If you changed line 69 to MUPARSER_HELPER_DLL_EXPORT you did the same that the -DBUILD_SHARED_LIBS=ON/OFF would do when using cmake. I never used mingw, so this may be a stupid question but does cmake work with mingw? Did you use cmake of did you have to create your own build script?

Hi,

Sorry I haven't worked with C++ long enough, actually I guess I am the one who did stupid things lol. I'm an R user and only learn C++ recently to improve my R packages. I'm a self taught developer and don't even know exactly what is building a C++ library (haven't read to that part yet, but I'll find it now), only follow your instructions to copy the essential files into src folder to use it. When the error occurred and I see that line of comments in file muParserFixes.h I think I may change it since I only use muparser and not building anything, luckily it worked.

In my case, I tried to implement muparser into my R package (because C++ run around 10x faster than R native code so many people are mixing R with C++). The package is developed to advance SIR model simulation used in infectious diseases outbreak modelling such as the COVID-19 pandemic, if you have any interest you can have a look at it here lol. In R, we compile the C++ code with another package called Rcpp, and it basically uses the native compiler on users' computer to compile C++ code. The Rcpp has its own script to compile the C++ code and we do nothing on that part. I checked and figured that the mingw actually use g++ on my windows machine.

More and more people are developing their R package with C++ code and libraries implementation, personally I think muparser will be used more often in the future so I came back to report how I solved this problem, hoping it can help other R users who intend to use muparser (and also who are not very proficient in C++ like me lol). Thank you so much for writing such a nice and powerful library.