Reputation: 18221
I have a.cpp
and a.h
files in separate from the main project directory. I include a.h
header file into main project using absolute path. Hot to tell c++ where it must look for a.cpp
file?
Upvotes: 0
Views: 486
Reputation: 299
Add the a.h to your projects default header file location. Do the same for your a.cpp. Add both the files to your project. You can now successfully build.
When I say add them to the default location, I mean the actual physical location that your main.cpp for the project is located as well as the header files for your project is located. If you put them anywhere else you will need to "Add additional include" directory paths for your header file.
Upvotes: 1
Reputation: 399
Visual studio normally compile all the cpp files included in the project, so you don't need to 'find' it actually. Just drag it into current project.
Upvotes: 1
Reputation: 3509
If your .cpp is in the project, it will find it. If it is not, you might work around that with the include directories, but thats just bad practice.
Upvotes: 1
Reputation: 258648
The best way is to just add the cpp
file to the project.
If it's outside the project or excluded from the build, you could include it in a another source file (#include "othercpp.cpp"
) and specify its path in the additional include directories under project settings.
But the correct approach would be to add it to the project. It doesn't have to be in the same place as other cpp
files for this.
Upvotes: 2