libnonius / nonius

A C++ micro-benchmarking framework
https://nonius.io
Creative Commons Zero v1.0 Universal
358 stars 47 forks source link

Why referencing boost_unit_test_framework library ? #103

Closed dimarusyy closed 6 years ago

dimarusyy commented 6 years ago

Hello,

Attempt to build example1 :

#define NONIUS_RUNNER
#include <nonius/nonius.h++>

NONIUS_BENCHMARK("to_string(42)", []
                 {
                     return std::to_string(42);
                 })

NONIUS_BENCHMARK("to_string(4.2)", []
                 {
                     return std::to_string(4.2);
                 })

gives error linkage error on windows :

1>------ Rebuild All started: Project: nonius_test, Configuration: Debug Win32 ------ 1>nonius_test.cpp 1>boost_unit_test_framework-vc140-mt-gd.lib(unit_test_main.obj) : error LNK2019: unresolved external symbol "class boost::unit_test::test_suite __cdecl init_unit_test_suite(int,char * const)" (?init_unit_test_suite@@YAPAVtest_suite@unit_test@boost@@HQAPAD@Z) referenced in function __catch$?unit_test_main@unit_test@boost@@YAHP6APAVtest_suite@12@HQAPAD@ZH0@Z$3 1>d:\work\nonius_test\Debug\nonius_test.exe : fatal error LNK1120: 1 unresolved externals 1>Done building project "nonius_test.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

dimarusyy commented 6 years ago

Ok, the issue is related vcpkg integration to VS and missing '#include <nonius/main.h++>' So, the working example should look like this :

define NONIUS_RUNNER

include <nonius/nonius.h++>

NONIUS_BENCHMARK("to_string(42)", [] { return std::to_string(42); })

NONIUS_BENCHMARK("to_string(4.2)", [] { return std::to_string(4.2); })

#include <nonius/main.h++>

rmartinho commented 6 years ago

Please read the second paragraph of the documentation. You're supposed to grab a release from the releases page https://github.com/rmartinho/nonius/releases.