build and debug Elmer on VS-Code on Windows

Discussion about building and installing Elmer
Phil13
Posts: 6
Joined: 03 Sep 2023, 19:31
Antispam: Yes

build and debug Elmer on VS-Code on Windows

Post by Phil13 »

Hello

first of all a big thank to the developpers for having make Elmer !
It's impressive.

I use it since years for thermal studies on material. Now I'm trying to develop a new model and solver. I'm working on windows 10.
I'm able to compile the model and solver as per instruction in the documentation but I need to debug them.

I would like to use VS-Code. I was able to install a Fortran compiler and debugger in VS-Code, but now I don't know how to write the script to compile and debug all the files of Elmer solver.

Any hint would be appreciated :)

Phil
Rich_B
Posts: 423
Joined: 24 Aug 2009, 20:18

Re: build and debug Elmer on VS-Code on Windows

Post by Rich_B »

Hello,

Having never used VS Code with Elmer, not much to contribute. With that said, it would be useful to learn how to use VS Code.

Which Fortran compiler have you installed? The GCC version in MSYS2? Cmake can create MSYS2 makefiles, which might work with VS Code?

Rich.
Phil13
Posts: 6
Joined: 03 Sep 2023, 19:31
Antispam: Yes

Re: build and debug Elmer on VS-Code on Windows

Post by Phil13 »

Hi Rich

thank for your reply.

I made different tests and installed MSYS2, TDM-GCC, mingw32, dgb. They all work with VS Code . I succeed to compile, run and debug a single Fortran .f90 file.

But I've no idea how to use CMAKE to create the compile/link list as I'm not familiar with it.
I tried to have a look on those scripts https://www.nic.funet.fi/pub/sci/physic ... s/scripts/ but I'm not able use them with VS Code neither for a simple build nor for debug purpose. May be because I'm not able to use CMAKE with VS Code.
So any hint would be appreciated.

If you are interested in VS Code on Windows, just install it and then install the following extensions:
C/C++ IntelliSense
Code Runner
fortran by Xavier Hahn
Fortran Breakpoint Support
Native Debug

and MSYS32

Phil
kevinarden
Posts: 2315
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: build and debug Elmer on VS-Code on Windows

Post by kevinarden »

You can clone the Elmer repository.
Start VS without code
Then there is an open CMAKE project option under file. It will check for any configuration errors
and send you to this
https://learn.microsoft.com/en-us/cpp/b ... om=vs-2019
Phil13
Posts: 6
Joined: 03 Sep 2023, 19:31
Antispam: Yes

Re: build and debug Elmer on VS-Code on Windows

Post by Phil13 »

hi Kevinarden

thank but I will continue on VS-Code a little bit before to jump to another IDE.

I made some progress: now CMAKE is runing, my mistake was that I didn't open the root file CMakeLists.txt but the one under fem.
Now opening the whole Elmer project CMAKE is runing and giving this error

[cmake] CMake Error at cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
[cmake] Could NOT find MPI_C (missing: MPI_C_LIBRARIES MPI_C_INCLUDE_PATH)

Anybody knows how to install MPI on Windows 10 and let CMAKE knows where it is ?

Thank a lot in advance
Phil
Rich_B
Posts: 423
Joined: 24 Aug 2009, 20:18

Re: build and debug Elmer on VS-Code on Windows

Post by Rich_B »

Hello,

If you search the forum for compiling Elmer with MPI = True in Windows, you will find a lack of success by others. The simplest approach to successfully compile Elmer in Windows is to disable MPI, such as setting
WITH_MPI FALSE
in Cmake.

Rich.

Edit: If one compiles Elmer in the Elmer Virtual Machine, Ubuntu 20, then compiling WITH_MPI to True works as expected. The issue with MPI is strictly a Windows compilation issue.
Last edited by Rich_B on 05 Sep 2023, 21:44, edited 1 time in total.
kevinarden
Posts: 2315
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: build and debug Elmer on VS-Code on Windows

Post by kevinarden »

The PPA in windows works with MPI, so somebody is successfully compiling it with MPI. However, a good start is in steps, compile with one option at a time, then work on the options that do not work.
Phil13
Posts: 6
Joined: 03 Sep 2023, 19:31
Antispam: Yes

Re: build and debug Elmer on VS-Code on Windows

Post by Phil13 »

hello

I set the option to FALSE at line 93 of C:\temp\elmerfem-release-9.0\CMakeLists.txt
SET(WITH_MPI FALSE CACHE BOOL "Use MPI parallelization")

but get the same message

[main] Configuring project: elmerfem-release-9.0
[proc] Executing command: D:\msys64\mingw64\bin\cmake.exe --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\msys64\mingw64\bin\g++.exe -DCMAKE_f90_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gfortran.exe -SC:/temp/elmerfem-release-9.0 -Bc:/temp/elmerfem-release-9.0/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Checking whether GFortran version >= 4.8 -- yes
[cmake] CMake Error at cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
[cmake] Could NOT find MPI_C (missing: MPI_C_LIBRARIES MPI_C_INCLUDE_PATH)
[cmake] Call Stack (most recent call first):
[cmake] cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
[cmake] cmake/Modules/FindMPI.cmake:615 (find_package_handle_standard_args)
[cmake] CMakeLists.txt:240 (FIND_PACKAGE)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: D:\msys64\mingw64\bin\cmake.exe --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\msys64\mingw64\bin\g++.exe -DCMAKE_f90_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gfortran.exe -SC:/temp/elmerfem-release-9.0 -Bc:/temp/elmerfem-release-9.0/build -G "MinGW Makefiles" exited with code: 1


At this point I'm stuck

Phil
Rich_B
Posts: 423
Joined: 24 Aug 2009, 20:18

Re: build and debug Elmer on VS-Code on Windows

Post by Rich_B »

Hello,

Just to check the easy stuff, we deleted the cmake cache and deleted the previous build folder, followed by configure and generate, before rerunning make?

Sorry in advance, in case you already did those steps.

Rich.
Phil13
Posts: 6
Joined: 03 Sep 2023, 19:31
Antispam: Yes

Re: build and debug Elmer on VS-Code on Windows

Post by Phil13 »

Hello

many thank for your hint Rich, I did some progress.

I've updated the file C:\temp\elmerfem-release-9.0\CMakeLists.txt with the following lines (file is attached too)
1st lines:
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
PROJECT(Elmer Fortran C CXX)
set(CMAKE_CURRENT_SOURCE_DIR "C:/temp/elmerfem-release-9.0")


and line 95:
SET(WITH_MPI FALSE) # CACHE BOOL "Use MPI parallelization")

then deleted the build directory, but don't find the cache.

Then when CMakeLists.txt is saved CMAKE execute automaticaly and returns the following:


[main] Configuring project: elmerfem-release-9.0
[proc] Executing command: D:\msys64\mingw64\bin\cmake.exe --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\msys64\mingw64\bin\g++.exe -DCMAKE_f90_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gfortran.exe -SC:/temp/elmerfem-release-9.0 -Bc:/temp/elmerfem-release-9.0/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The Fortran compiler identification is GNU 10.3.0
[cmake] -- The C compiler identification is GNU 13.2.0
[cmake] -- The CXX compiler identification is GNU 13.2.0
[cmake] -- Detecting Fortran compiler ABI info
[cmake] -- Detecting Fortran compiler ABI info - done
[cmake] -- Check for working Fortran compiler: D:/TDM-GCC-64/bin/gfortran.exe - skipped
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: D:/msys64/mingw64/bin/gcc.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: D:/msys64/mingw64/bin/g++.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Checking whether GFortran version >= 4.8 -- yes
[cmake] CMake Deprecation Warning at cmake/Modules/FindMKL.cmake:2 (CMAKE_MINIMUM_REQUIRED):
[cmake] Compatibility with CMake < 3.5 will be removed from a future version of
[cmake] CMake.
[cmake]
[cmake] Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake] CMake that the project does not need compatibility with older versions.
[cmake] Call Stack (most recent call first):
[cmake] CMakeLists.txt:299 (FIND_PACKAGE)
[cmake]
[cmake]
[cmake] -- ------------------------------------------------
[cmake] -- Mesh adaptation 2D/3D looking for [Mmg] tools
[cmake] CMake Deprecation Warning at cmake/Modules/FindMMG.cmake:14 (CMAKE_MINIMUM_REQUIRED):
[cmake] Compatibility with CMake < 3.5 will be removed from a future version of
[cmake] CMake.
[cmake]
[cmake] Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake] CMake that the project does not need compatibility with older versions.
[cmake] Call Stack (most recent call first):
[cmake] CMakeLists.txt:364 (FIND_PACKAGE)
[cmake]
[cmake]
[cmake] -- Library not found: >MMG_FOUND<
[cmake] -- Missing: >MMG_INCLUDE_DIR< , >MMG_LIBRARY<, to compile MMG3DSolver
[cmake] -- ------------------------------------------------
[cmake] -- Looking for Fortran sgemm
[cmake] -- Looking for Fortran sgemm - not found
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
[cmake] -- Found Threads: TRUE
[cmake] -- Looking for Fortran sgemm
[cmake] -- Looking for Fortran sgemm - found
[cmake] -- Found BLAS: D:/msys64/mingw64/lib/libopenblas.dll.a
[cmake] -- Looking for Fortran cheev
[cmake] -- Looking for Fortran cheev - found
[cmake] -- Found LAPACK: D:/msys64/mingw64/lib/libopenblas.dll.a
[cmake] -- Checking whether D:/TDM-GCC-64/bin/gfortran.exe supports PROCEDURE POINTER
[cmake] -- Checking whether D:/TDM-GCC-64/bin/gfortran.exe supports PROCEDURE POINTER -- yes
[cmake] -- Checking whether D:/TDM-GCC-64/bin/gfortran.exe supports CONTIGUOUS
[cmake] -- Checking whether D:/TDM-GCC-64/bin/gfortran.exe supports CONTIGUOUS -- yes
[cmake] -- Checking whether D:/TDM-GCC-64/bin/gfortran.exe supports EXECUTE_COMMAND_LINE
[cmake] -- Checking whether D:/TDM-GCC-64/bin/gfortran.exe supports EXECUTE_COMMAND_LINE -- yes
[cmake] CMake Warning (dev) at D:/msys64/mingw64/share/cmake/Modules/CheckIncludeFiles.cmake:116 (message):
[cmake] Policy CMP0075 is not set: Include file check macros honor
[cmake] CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy
[cmake] details. Use the cmake_policy command to set the policy and suppress this
[cmake] warning.
[cmake]
[cmake] CMAKE_REQUIRED_LIBRARIES is set to:
[cmake]
[cmake] D:/msys64/mingw64/lib/libopenblas.dll.a;D:/msys64/mingw64/lib/libopenblas.dll.a
[cmake]
[cmake] For compatibility with CMake 3.11 and below this check is ignoring it.
[cmake] Call Stack (most recent call first):
[cmake] matc/CMakeLists.txt:4 (CHECK_INCLUDE_FILES)
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] -- Looking for include file inttypes.h
[cmake] -- Looking for include file inttypes.h - found
[cmake] -- Looking for sys/types.h
[cmake] CMake Warning (dev) at D:/msys64/mingw64/share/cmake/Modules/CheckIncludeFile.cmake:77 (message):
[cmake] Policy CMP0075 is not set: Include file check macros honor
[cmake] CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy
[cmake] details. Use the cmake_policy command to set the policy and suppress this
[cmake] warning.
[cmake]
[cmake] CMAKE_REQUIRED_LIBRARIES is set to:
[cmake]
[cmake] D:/msys64/mingw64/lib/libopenblas.dll.a;D:/msys64/mingw64/lib/libopenblas.dll.a
[cmake]
[cmake] For compatibility with CMake 3.11 and below this check is ignoring it.
[cmake] Call Stack (most recent call first):
[cmake] D:/msys64/mingw64/share/cmake/Modules/CheckTypeSize.cmake:250 (check_include_file)
[cmake] fem/CMakeLists.txt:47 (CHECK_TYPE_SIZE)
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] -- Looking for sys/types.h - found
[cmake] -- Looking for stdint.h
[cmake] -- Looking for stdint.h - found
[cmake] -- Looking for stddef.h
[cmake] -- Looking for stddef.h - found
[cmake] -- Check size of long
[cmake] -- Check size of long - done
[cmake] -- Found 125 modules from C:/temp/elmerfem-release-9.0/fem/src/modules
[cmake] CMake Deprecation Warning at fem/tests/CMakeLists.txt:2 (CMAKE_MINIMUM_REQUIRED):
[cmake] Compatibility with CMake < 3.5 will be removed from a future version of
[cmake] CMake.
[cmake]
[cmake] Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake] CMake that the project does not need compatibility with older versions.
[cmake]
[cmake]
[cmake] -- Found 676 tests
[cmake] CMake Deprecation Warning at elmergrid/CMakeLists.txt:1 (cmake_minimum_required):
[cmake] Compatibility with CMake < 3.5 will be removed from a future version of
[cmake] CMake.
[cmake]
[cmake] Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake] CMake that the project does not need compatibility with older versions.
[cmake]
[cmake]
[cmake] CMake Deprecation Warning at elmergrid/src/metis-5.1.0/CMakeLists.txt:1 (cmake_minimum_required):
[cmake] Compatibility with CMake < 3.5 will be removed from a future version of
[cmake] CMake.
[cmake]
[cmake] Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake] CMake that the project does not need compatibility with older versions.
[cmake]
[cmake]
[cmake] -- Looking for execinfo.h
[cmake] CMake Warning (dev) at D:/msys64/mingw64/share/cmake/Modules/CheckIncludeFile.cmake:77 (message):
[cmake] Policy CMP0075 is not set: Include file check macros honor
[cmake] CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy
[cmake] details. Use the cmake_policy command to set the policy and suppress this
[cmake] warning.
[cmake]
[cmake] CMAKE_REQUIRED_LIBRARIES is set to:
[cmake]
[cmake] D:/msys64/mingw64/lib/libopenblas.dll.a;D:/msys64/mingw64/lib/libopenblas.dll.a
[cmake]
[cmake] For compatibility with CMake 3.11 and below this check is ignoring it.
[cmake] Call Stack (most recent call first):
[cmake] elmergrid/src/metis-5.1.0/GKlib/GKlibSystem.cmake:97 (check_include_file)
[cmake] elmergrid/src/metis-5.1.0/CMakeLists.txt:21 (include)
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] -- Looking for execinfo.h - not found
[cmake] -- Looking for getline
[cmake] -- Looking for getline - not found
[cmake] -- checking for thread-local storage - found
[cmake] -- ------------------------------------------------
[cmake] -- BLAS library: D:/msys64/mingw64/lib/libopenblas.dll.a
[cmake] -- LAPACK library: D:/msys64/mingw64/lib/libopenblas.dll.a
[cmake] -- ------------------------------------------------
[cmake] -- Fortran compiler: D:/TDM-GCC-64/bin/gfortran.exe
[cmake] -- Fortran flags: -fallow-argument-mismatch -O3 -DNDEBUG -O3
[cmake] -- ------------------------------------------------
[cmake] -- C compiler: D:/msys64/mingw64/bin/gcc.exe
[cmake] -- C flags: -O3 -DNDEBUG
[cmake] -- ------------------------------------------------
[cmake] -- CXX compiler: D:/msys64/mingw64/bin/g++.exe
[cmake] -- CXX flags: -O3 -DNDEBUG
[cmake] -- ------------------------------------------------
[cmake] -- ------------------------------------------------
[cmake] -- Package filename: elmerfem-9.0--20230906_Windows-AMD64
[cmake] -- Patch version: 9.0-
[cmake] -- Configuring done (68.5s)
[cmake] CMake Error at cmake/Modules/AddModules.cmake:27 (ADD_LIBRARY):
[cmake] No SOURCES given to target: CMakeFiles
[cmake] Call Stack (most recent call first):
[cmake] cmake/Modules/AddModules.cmake:64 (ADD_ELMER_MODULE)
[cmake] fem/src/modules/CMakeLists.txt:5 (ADD_ELMER_MODULES)

[cmake]
[cmake]
[cmake] CMake Generate step failed. Build files cannot be regenerated correctly.
[proc] The command: D:\msys64\mingw64\bin\cmake.exe --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\msys64\mingw64\bin\g++.exe -DCMAKE_f90_COMPILER:FILEPATH=D:\msys64\mingw64\bin\gfortran.exe -SC:/temp/elmerfem-release-9.0 -Bc:/temp/elmerfem-release-9.0/build -G "MinGW Makefiles" exited with code: 1


May be you can help me again
Phil
Attachments
CMakeLists.txt
(21.78 KiB) Downloaded 38 times
Post Reply