I want to use SFML and Google test for my project. I tried to set both up in DLL mode. I was able to start the program with SFML and it works, also google test works, at least until I try to test a class from my actual project.
I use VS2013 and have structured my project(s) like that.
If I try to use a class from the "Pacman" project it fails with the following:
1>------ Rebuild All started: Project: Pacman, Configuration: Release Win32 ------
1> Main.cpp
1> TestMe.cpp
1> Generating Code...
1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp
1> LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
1> Pacman.vcxproj -> C:\Users\xxxx\Documents\Git\pacman\Pacman\Release\Pacman.exe
2>------ Rebuild All started: Project: Pacman_Test, Configuration: Release Win32 ------
2> Pacman_Test.cpp
2>Pacman_Test.obj : error LNK2001: unresolved external symbol "public: int __thiscall TestMe::TestMyValue(int)" (?TestMyValue@TestMe@@QAEHH@Z)
2>Pacman_Test.obj : error LNK2001: unresolved external symbol "public: __thiscall TestMe::TestMe(void)" (??0TestMe@@QAE@XZ)
2>C:\Users\xxx\Documents\Git\pacman\Pacman\Release\Pacman_Test.exe : fatal error LNK1120: 2 unresolved externals
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
Can anyone help?
EDIT how should it help to mark it as a duplicate? I can't see where there would be duplicate declarations in my project.
EDIT2 Here is the code for the TestMe class and yes it works in the main.cpp.
#pragma once
class TestMe
{
public:
TestMe();
int TestMyValue(int val);
};
#include "TestMe.h"
TestMe::TestMe(){}
int TestMe::TestMyValue(int val){
return 0;
}
To complete the code here is the main.cpp too:
#include <iostream>
#include <SFML/Graphics.hpp>
#include "TestMe.h"
int main()
{
TestMe testMe;
std::cout << "Value:" << testMe.TestMyValue(3) << std::endl ;
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}