I am trying to reference two files which are located outside of my project's directory, a .h
file and it's corresponding .cpp
file. When I add the directory location to the "Additional Include Directories" section of the project it compiles and runs fine. However, when I use anything that is defined within the .cpp
file, it gives me an error either saying that there's an "unresolved external symbol" or that there is a "undefined identifier".
The files are as follows:
// test.h
// external file
#pragma once
#ifndef TEST_H
#define TEST_H
int what();
#endif
// test.cpp
// external file
#include "test.h"
int what() {
return 1;
}
// main.cpp
// project file
#include "test.h"
int main() {
what(); // LNK2019 unresolved external symbol
return 0;
}
Is there any way to link the .cpp
file to the project?
I know that this can be "fixed" by converting the files to a .lib
or .dll
, but I wish to use .cpp
files unless I absolutely cannot.