problem including files or building

Mar 16, 2021 at 11:02am
Hello,

I have recently run into a problem regarding including files or building project in cpp.
To try and solve this problem, i created a basic program to simulate the configuration, and i indeed cannot make it work.

Here is a picture of the 3 files : test.cpp (including main), include.h, include.cpp

https://ibb.co/wpv1tmR

Please let me know if there is a better way of integrating images.

You can notice some code in comments. I have let them as is : any of the two commented parts work, but this is not how I want it to be in the end of course.

You can see that no error is detected, but the build exited with :

undefined reference to `include::print()'

I have seen several post regardind this problem and nothing solved my issue.

Thanks in advance,

PY
Mar 16, 2021 at 11:24am
What compiler are you using? Have you configured this to include test.cpp and include.cpp units in the compilation?
Mar 16, 2021 at 12:13pm
I am using vs code on ubuntu. I have not done any special configuration and it used to work : in theroy, you open the folderin visual studio and it is able to find the files himself (i'm not sure what it does exactly).

I have indeed a launch.json that vs code generated and could maybe force the files but i have no clue how (that is what i am looking for now).

I have had similar configuration in the past and it worked just fine without me doing anything special to include the files. Now that it seems that i need to do it manually, i struggle to find how.

Thanks !
Mar 16, 2021 at 5:35pm
I have to add that i can compile everything using gcc directly on the terminal. So it really looks like my vs configuration is wrong. I tested several changes but nothing seems to work.

I have reinstalled cpp extension, added a few other cpp extension and tested them one by one but it didn't work either.

When i run, it says (as you can see in the first pic) :
> Executing task: C/C++: g++ build active file

The "active file" makes me worried about vs code being set to run the selected code only.

For now, i will compile directly with gcc but it's a pain because i'm new to cpp so I make a lot of mistakes and having to compile manually before running makes me loosing much time.

Thanks again !
Topic archived. No new replies allowed.