'Should I be including header files or source files for Google Test?
I'm learning how to use Google Test for one of my projects. When I include a header file I get a LNK2019 unresolved external symbol... error, however when I include the source file instead, it compiles successfully and the test runs. Have I made a mistake setting up my test project (I'm using Visual Studio 2019).
Edit: Sorry for any confusion, should I just have the Google Test project as a library and write my tests inside my actual project, including the gtest header? Right now, I've got my tests inside the Google Test project, with a main function inside it that runs the tests.
My current solution looks like this:
sln
project
src
googleTest project
tests
Should it look like this:
sln
project
src
tests
googleTest project (as library)
Solution 1:[1]
You probably have not linked your test to google test library. Indeed check project settings.
Solution 2:[2]
See this. When you build a solution, each project under the solution gets built separately.
MyConsoleGameSolution
|_GameEngine
|_include
|_src
|_...
|_MediaEngine
|_include
|_src
|_...
|_AsteroidGame (Suppose this has built successfully)
|_include
|_src
|_ship.cpp
|_x64\Debug\ship.obj (Result of successful build)
|_...
|_AsteroidGameTester
|_include
|_src
|_shipTester.cpp (Say this uses a "Ship" class from AsteroidGame/ship.cpp)
|_...
So object files from the AsteroidGame project are not automatically linked when you compile AsteroidGameTester.
You'd get the LNK2019 unresolved external symbol... error if you went to build AsteroidGameTester and the compiler tries to build shipTester.cpp. This is because shipTester.cpp doesn't know where definitions for Ship class are (which is defined in ship.obj).
So you must specify that the compiler should link ship.obj from AsteroidGame with other object files from AsteroidGameTester.
You do this by going into Properties > Linker > Input > Additional Dependencies for the AsteroidGameTester project. Edit Additional Dependencies
to include the fullpath to ship.obj (ie., $(SolutionDir)\MyConsoleGameSolution\AsteroidGame\x64\Debug\ship.obj or use ...\x64\Debug\*.obj for convenience, if appropriate)
Solution 3:[3]
The manual of EXT:numbered_pagination describes:
Copy the pagination partial EXT:numbered_pagination/Resources/Private/Partials/Pagination.html to your extension
So, in your case of using the extension with EXT:news, you have to copy the partial to a partialRootPaths entry you have configured for news - that's it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Åukasz Åšlusarczyk |
| Solution 2 | MTV |
| Solution 3 | Julian Hofmann |
