Errors:
LNK2005 "private: static char const * const boost::json::key_value_pair::empty_" (?empty_@key_value_pair@json@boost@@0QBDB) already defined in B_calculating.obj
LNK2005 "private: static struct boost::json::object::table boost::json::object::empty_" (?empty_@object@json@boost@@0Utable@123@A) already defined in B_calculating.obj
LNK2005 "private: static struct boost::json::array::table boost::json::array::empty_" (?empty_@array@json@boost@@0Utable@123@A) already defined in B_calculating.obj
And so on... There are about a hundred of these errors and they are all related to boost json
before asking this question, I spent almost the whole day reading and searching for materials on this topic. It seems that I have already tried everything, but the error remains. I have a few files:
main.cpp:
#include <stdlib.h>
#include <iostream>
#include <mysql/jdbc.h>
#include <boost/json/src.hpp>
#include <boost/json.hpp>
#include <typeinfo>
#include <string>
#include <vector>
#include <math.h>
#include <B_calculating.h>
#include <Level.h>
#include <string>
using namespace std;
//here using B_calculating
//Unfortunately, you won't be able to fully reproduce the example, as it requires data from the database and so on.
....
B_calculating.h:
#pragma once
#include <vector>
#include <boost/json/src.hpp>
#include <boost/json.hpp>
#include <mysql/jdbc.h>
#include <Level.h>
class B_calculating
{
public:
std::vector<Level> depth;
sql::ResultSet* sql_result_query;
const int parameter_value;
const float step;
B_calculating(sql::ResultSet* sql_result, int parameter, float input_step);
void start_processing();
private:
void request_processing(boost::json::value const& jv);
void set_level_and_custom_size(Level& l, float zero_level_price);
void calculate_levels_and_custom_size();
};
B_calculating.cpp:
#include <Q_calculating.h>
using namespace std;
// here I define functions from .h file
Level.h have similar structure and it works fine.
There is a clue in the boost/json/src.hpp
header:
This file is meant to be included once, in a translation unit of the program.
You should only include boost/json/src.hpp
in one cpp file. You should remove it from B_calculating.h
and only include it in main.cpp
.