How to build a CLion project which consists of multiple directories?

Completed

Hi CLion Community,

 

I am a newbie to using CLion installed it couple of days ago and now I want to get my hands dirty using this awesome editor. As a first step when I created a new project I see that there is a default "main.cpp" file that comes along with the new project. I created the following directory structure inside my project :

 

A

  - B

  - C

main.cpp

 

hence B and C are the sub-directories inside this project. I included a source file with the name "test.cpp" inside B sub-directory where in put the following code snippet shown below, but now when I try to build the project I get a linker error that you see below the code. Can someone tell me as to how to remedy this situation?

#include <iostream>

using namespace std;

int main() {

}

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [A] Error 1
make[2]: *** [CMakeFiles/A.dir/all] Error 2
make[1]: *** [CMakeFiles/A.dir/rule] Error 2
make: *** [A] Error 2
0
2 comments
Avatar
Permanently deleted user

The way I was able to build the project was by editing the CMakeLists.txt and adding in the line :  

set(SOURCE_FILES B/test.cpp)

Is this the correct way to go about it?
0
Avatar
Permanently deleted user

I think I got the answer to this. I installed the Single source plugin available for CLion and that served the purpose to test and execute a single source file :)

0

Please sign in to leave a comment.