json
json copied to clipboard
Document the need to disable autolinking for header-only on msvc
PLEASE DON'T FORGET TO "STAR" THIS REPOSITORY :)
When reporting a bug please include the following:
Version of Boost
107800
Steps necessary to reproduce the problem
I want to use the header-only version of boost/json, following the documentation at https://www.boost.org/doc/libs/1_75_0/libs/json/doc/html/json/quick_look.html:
n order to link your program you will need to link with a built library. Alternatively you can use the header-only configuration simply by including this header file in any one of your new or existing source files:
#include <boost/json/src.hpp>
Note | |
---|---|
Sample code and identifiers used throughout are written as if the following declarations are in effect:#include <boost/json.hpp> using namespace boost::json; |
I am using the following simple code:
#include
#include <boost/json.hpp> #include <boost/json/src.hpp>
using namespace boost::json;
int main() { object MyObject; MyObject["Hello"] = "World"; std::cout << serialize(MyObject) << "\n"; }
All relevant compiler information
Using Visual Studio 2022. Output is:
Build started... 1>------ Build started: Project: JsonTest, Configuration: Debug x64 ------ 1>JsonTest.cpp 1>LINK : fatal error LNK1104: cannot open file 'libboost_json-vc143-mt-gd-x64-1_78.lib' 1>Done building project "JsonTest.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The more information you provide the sooner your issue can get resolved!
I suspect, the issue is that Boost autolinking is enabled.
Actually, try putting src.hpp include before the other one.
Thanks for your speedy response, @grisumbras. I had already tried changing the order of the #defines and it made no difference; but disabling autolinking worked immediately. Would it be possible to include that in the documentation where it refers to header-only inclusion? Thanks very much for your help.
Good idea.