How to Create, Compile, And Run a single file in CLion

前端 未结 6 510
情话喂你
情话喂你 2021-01-31 03:07

I am working on some c++ stuff and I hate having to create a whole new project just to run a few things on a file.

I also don\'t like how when you creat

6条回答
  •  悲&欢浪女
    2021-01-31 03:54

    Inside every CLion project there is a file CMakeLists.txt.
    To run a single file you will have to write a single command inside this file and that is:

    add_executable(file_name_without_extension_cpp  file_name_with_extension_cpp)
    

    For example: add_executable(CoinChange CoinChange.cpp)

    Then click reload changes and then go to run option and then select the file you want to run then hit the run button. Your single file will be run.

    How many single files will be in your CLion project you will have to perform this same action for running every single file.

提交回复
热议问题