mfem icon indicating copy to clipboard operation
mfem copied to clipboard

It seems occur some errors when I build the MFEM on the Windows 11 with Visual Studio 17 2022

Open fastRKIMR opened this issue 2 years ago • 17 comments

Ref #2662

PS D:\lib\mfem-4.5.2\build>  cmake --build . --config Release --target INSTALL
MSBuild version 17.6.3+07e294721 for .NET Framework

  estimators.cpp
D:\lib\mfem-4.5.2\fem\estimators.cpp(251,46): error C2065: “i”: undeclared identifier [D:\lib\mfem-4.5.2\build\mfem.vcxproj]
D:\lib\mfem-4.5.2\fem\estimators.cpp(251,26): error C2530: “fip”: reference must be initialized [D:\lib\mfem-4.5.2\build\mfem.vcxproj]
D:\lib\mfem-4.5.2\fem\estimators.cpp(253,38): error C3536: “fip”: Cannot be used before initialization [D:\lib\mfem-4.5.2\build\mfem.vcxproj]
D:\lib\mfem-4.5.2\fem\estimators.cpp(253,24): error C2665: “mfem::IntegrationPointTransformation::Transform”: No overloaded function can convert all argument types [D:\lib\mfem-4.5.2\build\mfem.vcxproj]

I translate some comments by myself in those Errors infomations.

fastRKIMR avatar Aug 10 '23 12:08 fastRKIMR

Can you check that you have not made any edits to the file? For example, there is no i or fip on line 251 in estimators.cpp as the first two errors above suggest, see https://github.com/mfem/mfem/blob/v4.5.2/fem/estimators.cpp#L251: https://github.com/mfem/mfem/blob/00b2a0705f647e17a1d4ffcb289adca503f28d42/fem/estimators.cpp#L251

v-dobrev avatar Aug 10 '23 16:08 v-dobrev

Thanks for your reply. I am new to C++ (Basic grammar study only) and just want to use the MFEM in my study. But I cannot find any way to build it, so I need to refer the #2662. I am sure that I do not edit in any files.

1.I download the release package from the github and run the command as follows(Ref #2662): PS D:\lib\mfem-4.5.2> mkdir build PS D:\lib\mfem-4.5.2> cd build PS D:\lib\mfem-4.5.2\build> cmake .. -G "Visual Studio 17 2022" -- CMake version: 3.27.1 -- Loading USER_CONFIG = D:/lib/mfem-4.5.2/config/user.cmake (NOTFOUND) -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621. CMake Error at CMakeLists.txt:64 (message): MFEM does not support in-source CMake builds at this time.

2.Then I remove the CMakeLists.txt in the dir of MFEM and run the rest of the command: PS D:\lib\mfem-4.5.2\build> cmake .. -G "Visual Studio 17 2022" ... -- Configuring done (5.4s) -- Generating done (4.1s) PS D:\lib\mfem-4.5.2\build> cmake --build . --config Release ... D:\lib\mfem-4.5.2\fem\estimators.cpp(251,46): error C2065: “i”: undeclared identifier [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(251,26): error C2530: “fip”: reference must be initialized [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(253,38): error C3536: “fip”: Cannot be used before initialization [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(253,24): error C2665: “mfem::IntegrationPointTransformation::Transform”: No overloaded function can convert all argument types [D:\lib\mfem-4.5.2\build\mfem.vcxproj] ... D:\lib\mfem-4.5.2\fem\estimators.cpp(260,24): error C2664: “void mfem::ElementTransformation::SetIntPoint(const mfem::I ntegrationPoint *)”: Unable to convert parameter 1 from "int *" to "const mfem::IntegrationPoint *” [D:\lib\mfem-4.5.2\build\mfem.vcxproj] ...

  1. And then I ignore those errors and continue to run the rest of the command. It appears same error as above.

That is all for my bug information.

fastRKIMR avatar Aug 11 '23 02:08 fastRKIMR

If the command

cmake .. -G "Visual Studio 17 2022"

fails then we should fix that before continuing, Also, you should not delete CMakeLists.txt from the main MFEM dir.

Can you try replacing this line https://github.com/mfem/mfem/blob/v4.5.2/CMakeLists.txt#L63: https://github.com/mfem/mfem/blob/00b2a0705f647e17a1d4ffcb289adca503f28d42/CMakeLists.txt#L63 with

if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")

i.e. add double-quotes around the two variable references in the if statement. Make sure you delete all files and directories inside the build directory before you run the above CMake command again.

v-dobrev avatar Aug 11 '23 16:08 v-dobrev

I refer to your method and make sure it is not a different step in your way, but the error occurs again as before when I run the command: ` PS D:\lib\mfem-4.5.2\build> cmake .. -G "Visual Studio 17 2022" ... -- Configuring done (4.8s) -- Generating done (0.4s) -- Build files have been written to: D:/lib/mfem-4.5.2/build

PS D:\lib\mfem-4.5.2\build> cmake --build . --config Release ... D:\lib\mfem-4.5.2\fem\estimators.cpp(251,46): error C2065: “i”: undeclared identifier [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(251,26): error C2530: “fip”: reference must be initialized [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(253,38): error C3536: “fip”: Cannot be used before initialization [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(253,24): error C2665: “mfem::IntegrationPointTransformation::Transform”: No overloaded function can convert all argument types [D:\lib\mfem-4.5.2\build\mfem.vcxproj] ... ` Thanks for your reply.

fastRKIMR avatar Aug 12 '23 01:08 fastRKIMR

:warning: This issue or PR has been automatically marked as stale because it has not had any activity in the last month. If no activity occurs in the next week, it will be automatically closed. Thank you for your contributions.

stale[bot] avatar Sep 17 '23 23:09 stale[bot]

@v-dobrev Same thing happened on my computer (which updated to windows11 from windows 10 just last week, then errror happens)

ruihuasun avatar Sep 25 '23 10:09 ruihuasun

Unfortunately, I'm not sure I understand what is going wrong for you -- the Windows tests on both GitHub and Appveyor seem to work fine: see e.g. https://github.com/mfem/mfem/actions/runs/6303259712/job/17112147012. Maybe you can try cloning the latest master branch of MFEM instead of v4.5.2?

v-dobrev avatar Sep 25 '23 23:09 v-dobrev

Unfortunately, I'm not sure I understand what is going wrong for you -- the Windows tests on both GitHub and Appveyor seem to work fine: see e.g. https://github.com/mfem/mfem/actions/runs/6303259712/job/17112147012. Maybe you can try cloning the latest master branch of MFEM instead of v4.5.2?

The compile error is totally same with @fastRKIMR . Both latest 'master' branch and latest release 'v4.5.2' have been tested, and they all compile with error in estimators.cpp. The system and IDE version is Windows 11 VS 2022.

ruihuasun avatar Sep 26 '23 00:09 ruihuasun

:warning: This issue or PR has been automatically marked as stale because it has not had any activity in the last month. If no activity occurs in the next week, it will be automatically closed. Thank you for your contributions.

stale[bot] avatar Dec 15 '23 07:12 stale[bot]

@fastRKIMR, @ruihuasun, were you able to find a solution to this?

The error messages don't make any sense to me. I'm not sure what to recommend here.

v-dobrev avatar Dec 19 '23 03:12 v-dobrev

I refer to your method and make sure it is not a different step in your way, but the error occurs again as before when I run the command: ` PS D:\lib\mfem-4.5.2\build> cmake .. -G "Visual Studio 17 2022" ... -- Configuring done (4.8s) -- Generating done (0.4s) -- Build files have been written to: D:/lib/mfem-4.5.2/build

PS D:\lib\mfem-4.5.2\build> cmake --build . --config Release ... D:\lib\mfem-4.5.2\fem\estimators.cpp(251,46): error C2065: “i”: undeclared identifier [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(251,26): error C2530: “fip”: reference must be initialized [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(253,38): error C3536: “fip”: Cannot be used before initialization [D:\lib\mfem-4.5.2\build\mfem.vcxproj] D:\lib\mfem-4.5.2\fem\estimators.cpp(253,24): error C2665: “mfem::IntegrationPointTransformation::Transform”: No overloaded function can convert all argument types [D:\lib\mfem-4.5.2\build\mfem.vcxproj] ... ` Thanks for your reply.

did you solve the problem? I encountered the same issue.

xujiangping avatar Dec 19 '23 09:12 xujiangping

I tried the same thing but the error is different this time.

`PS C:\mfem\mfem-4.6\build> cmake --build . --config Release

In file included from /cygdrive/c/mfem/mfem-4.6/fem/../mesh/mesh.hpp:25, from /cygdrive/c/mfem/mfem-4.6/fem/fespace.hpp:17, from /cygdrive/c/mfem/mfem-4.6/fem/gridfunc.hpp:16, from /cygdrive/c/mfem/mfem-4.6/fem/kdtree.hpp:16, from /cygdrive/c/mfem/mfem-4.6/fem/kdtree.cpp:12: /cygdrive/c/mfem/mfem-4.6/fem/../mesh/../general/zstr.hpp: In function ‘std::string strict_fstream::strerror()’: /cygdrive/c/mfem/mfem-4.6/fem/../mesh/../general/zstr.hpp:88:31: error: ‘strerror_r’ was not declared in this scope; did you mean ‘_strerror_r’? 88 | char* p = check_strerror_r(strerror_r(errno, &buff[0], buff.size()), &buff[0], | ^~~~~~~~~~ | _strerror_r make[2]: *** [CMakeFiles/mfem.dir/build.make:892: CMakeFiles/mfem.dir/fem/kdtree.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:749: CMakeFiles/mfem.dir/all] Error 2 make: *** [Makefile:146: all] Error 2`

Before using CMake, I tried running it in the Cygwin terminal and got the same error. After that, I decided to use CMake in VS Code but the same thing happened. How can I solve this problem? Thank you.

rozerinyildiz23 avatar Feb 12 '24 06:02 rozerinyildiz23

Are you are still using Visual Studio 17 2022? Or did you try to compile with a different compiler?

If you are still using VS, it looks like the macro _WIN32 is not defined on this line: https://github.com/mfem/mfem/blob/db77249ac0f22e277081d43a5db6c3601e9e2830/general/zstr.hpp#L81 because the error message is from a line (zstr.hpp:88) in the #else section. According to https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170, _WIN32 should be defined, unless you are not building for one of the compilation targets for which _WIN32 is defined; according to the link these targets are "32-bit ARM, 64-bit ARM, x86, or x64". What target are you building for?

If you are using Cygwin, you can try adding the line

#define _GNU_SOURCE

right after the following lines: https://github.com/mfem/mfem/blob/69fbae732d5279c8d0f42c5430c4fd5656731d00/config/config.hpp#L58-L62 however, that should not be necessary -- as noted in the comment in the source above, defining _XOPEN_SOURCE 600 should be sufficient to get the strerror_r() definition.

v-dobrev avatar Feb 13 '24 23:02 v-dobrev

Are you are still using Visual Studio 17 2022? Or did you try to compile with a different compiler?

If you are still using VS, it looks like the macro _WIN32 is not defined on this line:

https://github.com/mfem/mfem/blob/db77249ac0f22e277081d43a5db6c3601e9e2830/general/zstr.hpp#L81

because the error message is from a line (zstr.hpp:88) in the #else section. According to https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170, _WIN32 should be defined, unless you are not building for one of the compilation targets for which _WIN32 is defined; according to the link these targets are "32-bit ARM, 64-bit ARM, x86, or x64". What target are you building for? If you are using Cygwin, you can try adding the line

#define _GNU_SOURCE

right after the following lines:

https://github.com/mfem/mfem/blob/69fbae732d5279c8d0f42c5430c4fd5656731d00/config/config.hpp#L58-L62

however, that should not be necessary -- as noted in the comment in the source above, defining _XOPEN_SOURCE 600 should be sufficient to get the strerror_r() definition.

I am trying both of them. For Cygwin, I tried what you recommended to me but it didn't work, I got the same error.

In file included from fem/../mesh/mesh.hpp:25, from fem/fespace.hpp:17, from fem/gridfunc.hpp:16, from fem/kdtree.hpp:16, from fem/kdtree.cpp:12: fem/../mesh/../general/zstr.hpp: In function ‘std::string strict_fstream::strerror()’: fem/../mesh/../general/zstr.hpp:87:31: error: ‘strerror_r’ was not declared in this scope; did you mean ‘_strerror_r’? 87 | char* p = check_strerror_r(strerror_r(errno, &buff[0], buff.size()), &buff[0], | ^~~~~~~~~~ | _strerror_r

And for VS, yes I am using Visual Studio 17 2022. But the problem here was CMake. I couldn't even build a basic project with CMake in Windows yet. I am trying to solve CMake issue in Windows.

rozerinyildiz23 avatar Feb 14 '24 06:02 rozerinyildiz23

See here: https://github.com/mfem/mfem/issues/4124#issuecomment-1975557977 for a solution for the Cygwin error.

v-dobrev avatar Mar 04 '24 02:03 v-dobrev

Are you are still using Visual Studio 17 2022? Or did you try to compile with a different compiler? If you are still using VS, it looks like the macro _WIN32 is not defined on this line: https://github.com/mfem/mfem/blob/db77249ac0f22e277081d43a5db6c3601e9e2830/general/zstr.hpp#L81

because the error message is from a line (zstr.hpp:88) in the #else section. According to https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170, _WIN32 should be defined, unless you are not building for one of the compilation targets for which _WIN32 is defined; according to the link these targets are "32-bit ARM, 64-bit ARM, x86, or x64". What target are you building for? If you are using Cygwin, you can try adding the line

#define _GNU_SOURCE

right after the following lines: https://github.com/mfem/mfem/blob/69fbae732d5279c8d0f42c5430c4fd5656731d00/config/config.hpp#L58-L62

however, that should not be necessary -- as noted in the comment in the source above, defining _XOPEN_SOURCE 600 should be sufficient to get the strerror_r() definition.

I am trying both of them. For Cygwin, I tried what you recommended to me but it didn't work, I got the same error.

In file included from fem/../mesh/mesh.hpp:25, from fem/fespace.hpp:17, from fem/gridfunc.hpp:16, from fem/kdtree.hpp:16, from fem/kdtree.cpp:12: fem/../mesh/../general/zstr.hpp: In function ‘std::string strict_fstream::strerror()’: fem/../mesh/../general/zstr.hpp:87:31: error: ‘strerror_r’ was not declared in this scope; did you mean ‘_strerror_r’? 87 | char* p = check_strerror_r(strerror_r(errno, &buff[0], buff.size()), &buff[0], | ^~~~~~~~~~ | _strerror_r

And for VS, yes I am using Visual Studio 17 2022. But the problem here was CMake. I couldn't even build a basic project with CMake in Windows yet. I am trying to solve CMake issue in Windows.

Hi, did you solve the Cmake issue in Windows? I tried to install MFEM on Windows 10 with Visual Studio 17 2022., but failed.

xujiangping avatar Mar 19 '24 00:03 xujiangping