Defining DOCTEST_CONFIG_DISABLE globally causes linking errorsΒ #873
Open
Description
Description
I created a project based on the executable_dll_and_plugin example where I wanted to try doctest and see how it works when tests are implemented alongside library source code. Everything worked fine with my modifications to the example, until I wanted to try defining the DOCTEST_CONFIG_DISABLE globally (for production use case). I got the following linker error.
test_runner.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl doctest::IReporter::~IReporter(void)" (??1IReporter@doctest@@UEAA@XZ) referenced in function "public: virtual void * __cdecl doctest::IReporter::`vector deleting destructor'(unsigned int)" (??_EIReporter@doctest@@UEAAPEAXI@Z) [C:\Users\Niketin\repos\doctest-example\build\dll\test_runner.vcxproj]
C:\Users\Niketin\repos\doctest-example\build\dll\Debug\test_runner.dll : fatal error LNK1120: 1 unresolved externals [C:\Users\Niketin\repos\doctest-example\build\dll\test_runner.vcxproj]
I wasn't able to solve this problem. I assume it is either a user error, or something is wrong in doctest, so I decided to open an issue here.
Steps to reproduce
- Download and extract doctest-example.zip
- Build it with CMake:
a.cmake -B build .
b.cmake --build build
- Build should complete fine. Listing tests show all 4 tests.
PS C:\Users\Niketin\repos\doctest_example> .\build\test\Debug\executable_dll_and_plugin.exe -ltc
[doctest] listing all test case names
===============================================================================
dll
dll utils
test_runner
executable
===============================================================================
[doctest] unskipped test cases passing the current filters: 4
- Now, add
#define DOCTEST_CONFIG_DISABLE
at the beginning of each source file. - Build again. The error should come up.
Extra information
- doctest version: v2.4.11
- Operating System: Microsoft Windows 10 Pro Version 10.0.19045 Build 19045
- Compiler+version: MSVC 19.39.33523.0
Metadata
Assignees
Labels
No labels