I have a header file A.h
namespace DIV
{
int Fun();
}
A source file A.cpp
namespace DIV
{
class A
{
public:
A(){}
~A(){}
int Fun();
};
int A::Fun()
{
return 0;
}
}
Now I have another source file B.cpp in another project of the same solution.
This source uses google's GTest framework. Inside the test function I use
#include "gtest/gtest.h"
#include "A.h"
TEST(FunTest, Param)
{
int value = DIV::Fun();
}
Because of the DIV::Fun()
call I get linker error. I don't understand the reason behind the linker error.
EDIT: B.cpp is in an .exe project and A.h/cpp is in a lib project.
Problem is solved. I have got the answer from here. To summarize I needed to link my exe project with the lib project which contains the function fun()
. Now the simplest way to make the .exe project link against .lib project probably is by adding a reference:
After that the linker error was gone.