0

I dragged and dropped two header files from File Explorer to the Solution Explorer and the solution will not compile because it does not have a path to the files.

enter image description here

enter image description here

enter image description here

6
  • You can have files in a project but that doesn't mean they're also in the same folder. Are those 2 files in the same folder as the .cpp you're compiling? Commented Oct 12, 2016 at 18:11
  • @GillBates No, the files are not in the same folder as the solution or project. If I open the directory of the project they are not there. In solution explorer it looks like they are there. Also I don't see the Header folder either though. Commented Oct 12, 2016 at 18:12
  • 1
    Then that's the issue, there's a link in your project to the files, but the files aren't actually there, copy them to your project folder. Commented Oct 12, 2016 at 18:13
  • I don't see the Header Files or Source Files folder either Commented Oct 12, 2016 at 18:15
  • 1
    Because the project filters aren't folders, they're just visually there to help you sort your files. Commented Oct 12, 2016 at 18:16

2 Answers 2

3

If you just type #include "myclass.hh" its expected to be in the same folder as the file you are writing in. check if they are in the same folder, if not you can write the full path or the path from your current folder.

"../other_folder/myclass.hh"

would be if you have a structure like this:
Your .cpp file is in cur_folder, which is in the same folder as other_folder and inside this is your myclass.hh

hope you get my point^^

1

Dragging/droping a file doesn't add it to your current project, they're only opened and showed in the editor.
To add an existing file to your project you just have to right click it and choose

add -> existing file

This may not be the exact words, i'm using the french version of it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.