fortran-plugin
fortran-plugin copied to clipboard
Question about working directory
I'm installing Fortran 90 environment in Windows, with JetBrains CLion and your plugin, with "mingw-w64".
With default "Run/debug configurations" in CLion, building and running a "Hello world" example will raise an error: cannot find libgfortran-5.dll ... It means "CMake" file only recognizes gfortran.exe itself, but cannot recognize any DLL in the same folder.
My "CMake" file is:
cmake_minimum_required(VERSION 3.29)
set(CMAKE_Fortran_COMPILER "C:\\Users\\username\\Desktop\\tech\\mingw64\\bin\\gfortran.exe")
project(learn_f Fortran)
enable_language(Fortran)
add_executable(learn_f main.f90)
I tried to include the .../mingw64/bin folder with link_directories or link_module or link_libraries in CMake file, but none of them works. I also tried to include .../mingw64/bin in environment variable PATH. I tried three places of PATH: CLion "Run/debug configurations", system settings, and CMake file. However, still none of them works.
Finally, I found a solution: I set the "working directory" to .../mingw64/bin in "Run/debug configurations" and this error is resolved.
However, set the "working directory" means cd to .../mingw64/bin in terminal. I'm worried if it will break the relative path in the program. For example, if I import package.f in main.f, I'm not sure if it can correctly locate package.f. (Please allow me to use Python term, because I'm a beginner of Fortran, I don't know how "import" works in Fortran.)
Is my practice of setting the "working directory" to .../mingw64/bin the correct way?
Thanks for answering my question.