From C/C++ to native development: Rust and Fortran plugins in CLion

While CLion’s main focus is on C and C++, it also provides extensive support for other languages that supplement the C/C++ ecosystem:

  • Python (interesting fact: according to feature usage statistics, Python is used in 30% of projects opened in CLion!)
  • JavaScript, HTML, and other web technologies
  • Objective-C / Objective-C++ as supported for the first time in CLion 2018.1 EAP

Support for these languages is included in CLion by default, along with C and C++.

We also offer multiple plugins that expand CLion’s focus and make it a viable IDE for native development. We’ve recently announced support for Kotlin/Native, our technology that compiles Kotlin directly to machine code and produces executables that can run without a virtual machine.

Today, we are happy to tell you about two new language plugins that can be installed on top of your CLion (the latest improvements are available in 2018.1 EAP):

Both plugins are on their early stage of development, so issues are possible and some functionality might be missing. Your feedback and bug reports are welcome (feedback on the Fortran plugin, feedback on the Rust plugin).

Fortran

GNU Fortran compiler is provided as part of the GCC installation. The Fortran plugin is compatible with all IntelliJ-based IDEs. However, to work with Fortran project in CLion, you need to have a CMake-based project. Find a sample Fortran project build with CMake in this wiki.

The plugin supports FORTRAN 77, FORTRAN 90, FORTRAN 95, FORTRAN 2003, and FORTRAN 2008 source code. It parses Fortran code and highlights it for you. In addition, it offers many smart actions:

  • For editing code:
    • Code formatting (available for free source form files only for now)
      fortran_format
    • Add a line comment (Ctrl+Slash for Windows/Linux, ⌘/ on macOS)
    • Code folding
    • Brace matching
  • For navigation:
    • Find Usages
      fortran_usages
    • Go to Definition
    • Structure view
  • For analyzing code, a set of useful code inspections to catch potential errors:
    fortran_inspections
  • A debugger (switch to GDB in CLion):
    fortran_debugger

Rust

Like the Fortran plugin, the Rust plugin is also compatible with all IntelliJ-based IDEs. However, as we’ve already mentioned in our company blog, the debugging feature is available only in CLion for now.

If you’ve already tried the Rust plugin in CLion, your next question may be, Does it work without CMake? Well, now the answer is a resounding Yes! The Rust plugin for CLion comes with Cargo support on board!

To start a new project, use the New Project wizard, select Rust, and provide paths to the toolchain and standard library. CLion will do its best to detect it automatically if you already have it installed on your machine; the standard library can be downloaded via rustup right from the wizard:
rust_new_prj
A new Cargo project will be created for you by CLion.

To learn more about how to get Rust, configure CLion, and start a new project or work with an existing one, check out the IntelliJ Rust Quick Start Guide.

The plugin’s capabilities include:

  • plenty of smart editing features,
  • on-the-fly code analysis:
    rust_analysis
  • lots of navigation actions (like Find Usage, Go to Class, Go to Super, a File Structure view, and others),
  • options for code generation and some important refactorings,
  • Quick Documentation popup (including documentation for library functions):
    rust_quick_doc
  • and even more.

Find more details about all of the plugin’s features on its site.

Now, if you are using the Rust plugin in CLion, you can debug your Rust application right from the IDE!
Rust Debug

So, get the latest CLion 2018.1 EAP, check out one or both plugins from the plugin repository (you can do this right from the IDE in Settings/Preferences | Plugins | Browse repositories…), and enjoy!

Your CLion Team
JetBrains
The Drive to Develop

This entry was posted in Announcement, Early Access Preview and tagged , , , , , , . Bookmark the permalink.

24 Responses to From C/C++ to native development: Rust and Fortran plugins in CLion

  1. Tano says:

    Hi Anastasia, is “Typeahead timeout is exceeded” bug in “Find in Files” fixed?
    I hope it’s fixed before releasing 2018.1, Find in Files is very hard to use with this bug.
    Thanks

  2. I can attest that the Rust support is most excellent. Especially the debugging. Although I have stopped using C and C++ entirely, I shall be using CLion for a long while – unless JetBrains issue a Rust specific IDE.

  3. Graham Nash says:

    Got yourself a CLion customer with this update. Thanks!

  4. Andreas says:

    I like the Fortran plugin but unfortunately I cannot compile my Fortran project with cmake. I can compile it with a single gfortran line but cmake gives me weird errors. That is a pitty because of this I cannot use the debugger. :(

    • Anastasia Kazakova says:

      What is the issue with CMake?

      The team plans to add Fortran/CMake project template. Meanwhile, you can add simple CMake to your project. You need to include “enable_language (Fortran)” into your CMakeLists.txt file.

      • Andreas says:

        I have quite a simple CMake file like this:

        project(ALYA)
        cmake_minimum_required(VERSION 3.9)
        enable_language(Fortran)

        set(SOURCE “here are some source files”)

        set(CMAKE_Fortran_FLAGS “-ffree-line-length-none -fimplicit-none -fno-automatic -fbounds-check -Wall -fbacktrace -ftrapv -x f95-cpp-input -DI_AM_NOT_ALYA”)
        add_executable(“andreas.x” “${SOURCE}”)

        I can compile it normally with a single gfortran line:
        “gfortran -ffree-line-length-none -fimplicit-none -fno-automatic -fbounds-check -Wall -fbacktrace -ftrapv -x f95-cpp-input -DI_AM_NOT_ALYA -o andreas.x src/*”

        But when I compile it via cmake (either in CLion or with cmake/make on its own) I get one million error messages. I am showing only the last ones:
        “Error: Invalid character in name at (1)
        CMakeFiles/andreas.x.dir/src/andreas.f90.o:103:0:

        Error: Unclassifiable statement at (1)
        make[3]: *** [CMakeFiles/andreas.x.dir/build.make:277: andreas.x] Error 1
        make[2]: *** [CMakeFiles/Makefile2:69: CMakeFiles/andreas.x.dir/all] Error 2
        make[1]: *** [CMakeFiles/Makefile2:81: CMakeFiles/andreas.x.dir/rule] Error 2
        make: *** [Makefile:118: andreas.x] Error 2”

        • Semyon Atamas says:

          1) Flag that causes problems: -x f95-cpp-input
          2) Problem can reproduced with gfortran if you will compile project with -c option and then will try to link .o files with provided flags (exactly what CMake does)
          3) It can be fixed by changing CMAKE_Fortran_LINK_EXECUTABLE option. See this [question](https://stackoverflow.com/questions/1867745/cmake-use-a-custom-linker) for example

          • Andreas says:

            I think I got further but problems still remain. I used this line “set(CMAKE_Fortran_LINK_EXECUTABLE ” -o “)”

            and cmake says “/usr/bin/ld: unrecognized option ‘-Wall'”
            So I removed from the LINK_EXECUTABLE line because they are compiler and no linker flags, right?

            But then I get uncountable number of error messages like:
            “path/to/file/andreas.f90:2:undefined reference to _gfortran_set_args'
            path/to/file/andreas.f90:2: undefined reference to
            _gfortran_set_options'”
            Do I have to set another flag or variable in cmake or what am I missing here?

          • Semyon Atamas says:

            CMAKE_Fortran_LINK_EXECUTABLE is not flags, it’s executable, that’s your problem. I didn’t found any better way to set compiler-only flags for fortran, so I proposed this as solution, maybe there is better one.
            You can find command that will be called in file ./cmake-build-debug/CMakeFiles/andreas.x.dir/link.txt or something similar. Without CMAKE_Fortran_LINK_EXECUTABLE variable it’s /usr/bin/gfortran.exe -ffree-line-length-none -fimplicit-none -fno-automatic -fbounds-check -fbacktrace -ftrapv -DI_AM_NOT_ALYA -x f95-cpp-input -g -Wl,–enable-auto-import CMakeFiles/andreas.x.dir/f.f95.o -o andreas.x.exe -Wl,–out-implib,libandreas.x.dll.a -Wl,–major-image-version,0,–minor-image-version,0 .
            You have to generate something similar with this variable. For simple linking set(CMAKE_Fortran_LINK_EXECUTABLE ” -o “) will be fine

          • Semyon Atamas says:

            Looks like real values of this variable were corrupted in our comments. My proposal was set(CMAKE_Fortran_LINK_EXECUTABLE "<CMAKE_Fortran_COMPILER> <OBJECTS> -o <TARGET>")

          • Andreas says:

            Thank you very much! That was it. Now it compiles! That is awesome!

            But one last thing. I added the “-g” flag for debugging and set a breakpoint. But if I then start the debugging it goes directly through the program without stopping.
            Do I have to set more than that?
            I tried it with the bundled gdb and with the current gdb version 8.1.1 on Arch Linux.

            Again thank you very much for your help.

          • Semyon Atamas says:

            As far as I know, -g flag will be added automatically when you compile program for debug.
            Are you using CLion eap, or stable? If you are using stable version of CLion then you have to use “Fortran” run configuration to debug your program.

          • Andreas says:

            I am using stable. The Fortran Run Configuration works. Thank you for the great support!

  5. Olzhas says:

    are there any plans on adding dlang?

  6. Pedro N. Rodriguez says:

    Hi,

    Great news!

    Quick question: is there a way to leverage OpenCoarrays “caf” and “cafrun” scripts from the Fortran plugin?

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *