trailofbits / pe-parse

Principled, lightweight C/C++ PE parser
MIT License
794 stars 155 forks source link

Compile error #152

Closed guoguojiacheng closed 1 year ago

guoguojiacheng commented 3 years ago

Env:Windows10、vistual studio 2017、cmake version 3.19.4

Error info:

Determining if the include file filesystem exists failed with the following output: Change Dir: D:/FoxitGit/pe-parse/build/CMakeFiles/CMakeTmp

Run Build Command(s):D:/vs2017/MSBuild/15.0/Bin/MSBuild.exe cmTC_7d71c.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:VisualStudioVersion=15.0 /v:m && 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3

版权所有(C) Microsoft Corporation。保留所有权利。

用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.16.27045 版

版权所有(C) Microsoft Corporation。保留所有权利。

cl /c /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++17 /Fo"cmTC_7d71c.dir\Debug\" /Fd"cmTC_7d71c.dir\Debug\vc141.pdb" /Gd /TP /analyze- /errorReport:queue "D:\FoxitGit\pe-parse\build\CMakeFiles\CMakeTmp\CheckIncludeFile.cxx"

CheckIncludeFile.cxx

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(137): error C2039: “_W_int_curr_symbol”: 不是“lconv”的成员 [D:\FoxitGit\pe-parse\build\CMakeFiles\CMakeTmp\cmTC_7d71c.vcxproj]

D:\Windows Kits\10\Include\10.0.17763.0\ucrt\locale.h(99): note: 参见“lconv”的声明

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(135): note: 编译 类 模板 成员函数 "void std::_Mpunct<_Elem>::_Getvals(wchar_t,const lconv *)" 时

      with

      [

          _Elem=wchar_t

      ]

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(160): note: 参见对正在编译的函数 模板 实例化“void std::_Mpunct<_Elem>::_Getvals(wchar_t,const lconv *)”的引用

      with

      [

          _Elem=wchar_t

      ]

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(276): note: 参见对正在编译的 类 模板 实例化 "std::_Mpunct<_Elem>" 的引用

      with

      [

          _Elem=wchar_t

      ]

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(1030): note: 参见对正在编译的 类 模板 实例化 "std::moneypunct<wchar_t,true>" 的引用

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(137): error C2039: “_W_currency_symbol”: 不是“lconv”的成员 [D:\FoxitGit\pe-parse\build\CMakeFiles\CMakeTmp\cmTC_7d71c.vcxproj]

D:\Windows Kits\10\Include\10.0.17763.0\ucrt\locale.h(99): note: 参见“lconv”的声明

Determining if the include file experimental/filesystem exists failed with the following output: Change Dir: D:/FoxitGit/pe-parse/build/CMakeFiles/CMakeTmp

Run Build Command(s):D:/vs2017/MSBuild/15.0/Bin/MSBuild.exe cmTC_66dc4.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:VisualStudioVersion=15.0 /v:m && 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3

版权所有(C) Microsoft Corporation。保留所有权利。

用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.16.27045 版

版权所有(C) Microsoft Corporation。保留所有权利。

cl /c /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++17 /Fo"cmTC_66dc4.dir\Debug\" /Fd"cmTC_66dc4.dir\Debug\vc141.pdb" /Gd /TP /analyze- /errorReport:queue "D:\FoxitGit\pe-parse\build\CMakeFiles\CMakeTmp\CheckIncludeFile.cxx"

CheckIncludeFile.cxx

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(137): error C2039: “_W_int_curr_symbol”: 不是“lconv”的成员 [D:\FoxitGit\pe-parse\build\CMakeFiles\CMakeTmp\cmTC_66dc4.vcxproj]

D:\Windows Kits\10\Include\10.0.17763.0\ucrt\locale.h(99): note: 参见“lconv”的声明

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(135): note: 编译 类 模板 成员函数 "void std::_Mpunct<_Elem>::_Getvals(wchar_t,const lconv *)" 时

      with

      [

          _Elem=wchar_t

      ]

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(160): note: 参见对正在编译的函数 模板 实例化“void std::_Mpunct<_Elem>::_Getvals(wchar_t,const lconv *)”的引用

      with

      [

          _Elem=wchar_t

      ]

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(276): note: 参见对正在编译的 类 模板 实例化 "std::_Mpunct<_Elem>" 的引用

      with

      [

          _Elem=wchar_t

      ]

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(1030): note: 参见对正在编译的 类 模板 实例化 "std::moneypunct<wchar_t,true>" 的引用

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(137): error C2039: “_W_currency_symbol”: 不是“lconv”的成员 [D:\FoxitGit\pe-parse\build\CMakeFiles\CMakeTmp\cmTC_66dc4.vcxproj]

D:\Windows Kits\10\Include\10.0.17763.0\ucrt\locale.h(99): note: 参见“lconv”的声明

woodruffw commented 3 years ago

I'm sorry, but I've never seen anything remotely like this before. Are you attempting to compile from the latest master?

ekilmer commented 3 years ago

This seems to be something to do with lconv while trying to test the compatibility for std::filesystem

Determining if the include file filesystem exists failed with the following output:

Determining if the include file experimental/filesystem exists failed with the following output:

The errors translate to missing members

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(137): error C2039: “_W_currency_symbol”: 不是“lconv”的成员

D:\vs2017\VC\Tools\MSVC\14.16.27023\include\xlocmon(137): error C2039: “_W_currency_symbol”: not a member of “lconv”

ekilmer commented 3 years ago

One thing to try would be removing or commenting out the std::filesystem check here https://github.com/trailofbits/pe-parse/blob/4286f109b0763972d1db7177ec6fe5f6791350f8/CMakeLists.txt#L17-L18

If this works, I'll move those lines into just the testing section, since the tests are the only place we use the std::filesystem

guoguojiacheng commented 3 years ago

I'm sorry, but I've never seen anything remotely like this before. Are you attempting to compile from the latest master?

Yes,A few days ago, it could be compiled. I don't know what I did to cause this problem, so I clone a copy of the code again. The result is still the same problem

guoguojiacheng commented 3 years ago

One thing to try would be removing or commenting out the std::filesystem check here

https://github.com/trailofbits/pe-parse/blob/4286f109b0763972d1db7177ec6fe5f6791350f8/CMakeLists.txt#L17-L18

If this works, I'll move those lines into just the testing section, since the tests are the only place we use the std::filesystem

Oh,I tried to remove them, and yes, I could use CMake to generate the project, but I still get this error with Vistual Studio

ekilmer commented 3 years ago

I still get this error with Vistual Studio

We did recently start using C++17 to make writing the tests easier, so there might be something weird happening with your environment while trying to use C++17.

However, if you're not building and running tests, then C++17 shouldn't be required. Can you also try making this change here https://github.com/trailofbits/pe-parse/blob/4286f109b0763972d1db7177ec6fe5f6791350f8/cmake/compilation_flags.cmake#L1

- set(CMAKE_CXX_STANDARD 17)
+ set(CMAKE_CXX_STANDARD 11)

So if you make both of these changes:

  1. Removing the 2 lines mentioned here https://github.com/trailofbits/pe-parse/issues/152#issuecomment-811997406
  2. Changing the C++ standard back to 11

I think it might work.

We only test with the latest Windows Visual Studio (2019) in CI, and I'm not aware of the extent of C++17 compatibility in the different Visual Studio versions. If you're able to submit a patch that works for you while also passing CI, then we would be happy to review it!