Skip to content

Question about working directory #166

@cloudy-sfu

Description

@cloudy-sfu

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.

image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions