I am getting a linking error with my two C++ files as seen below. Compile error
It compiles up to the point of two object files then fails on linking.
Below is my code, I commented out most of main in order to isolate the issue.
I am using the boost/JSON library. The duplicates are all from the boost JSON library.
The JSONParser file is going to take in a JSON object and turn it to a C++ object but I don't think anything to do with the actual code is the issue. Just either a library or header file issue.
main.cpp
#include "JSONParser.hpp"
/*
#include <boost/beast/core.hpp>
#include <boost/beast.hpp>
#include <boost/beast/ssl.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <iostream>
#include <string>
#include <thread>
namespace net = boost::asio;
namespace beast = boost::beast;
using namespace boost::beast;
using namespace boost::beast::websocket;
*/
int main (void) {
//net::io_context ioc;
//tcp_stream sock(ioc);
//net::ssl::context ctx(net::ssl::context::tlsv12);
}
JSONParser.hpp
#ifndef JSONPARSER_H
#define JSONPARSER_H
#define BOOST_JSON_STACK_BUFFER_SIZE 1024
#include <boost/json/src.hpp>
class candlestick{
private:
double openPrice;
double closePrice;
double priceHigh;
double priceLow;
double baseVolume;
double quoteVolume;
bool isClosed;
public:
candlestick (double oP, double cP, double pH, double pL, double bV, double qV, bool iC);
void setopenPrice(double p) {
openPrice = p;
}
double getopenPrice(void) {
return openPrice;
}
void setclosePrice(double p) {
closePrice = p;
}
double getclosePrice(void) {
return closePrice;
}
void setpriceHigh(double p) {
priceHigh = p;
}
double getpriceHigh(void) {
return priceHigh;
}
void setpriceLow(double p) {
priceLow = p;
}
double getpriceLow(void) {
return priceLow;
}
void setbaseVolume(double v) {
baseVolume = v;
}
double getbaseVolume(void) {
return baseVolume;
}
void setquoteVolume(double v) {
quoteVolume = v;
}
double getquoteVolume(void) {
return quoteVolume;
}
void setClosed(bool c) {
isClosed = c;
}
bool getClosed(void) {
return isClosed;
}
};
candlestick::candlestick (double oP, double cP, double pH, double pL, double bV, double qV, bool iC) {
openPrice = oP;
closePrice = cP;
priceHigh = pH;
priceLow = pL;
baseVolume = bV;
quoteVolume = qV;
isClosed = iC;
};
candlestick createCandlestickObject ();
#endif
JSONParser.cpp
#include "JSONParser.hpp"
#include <iostream>
#include <sstream>
#include <string>
candlestick createCandlestickObject () {
candlestick c (2, 2, 2, 2, 2, 2, true);
return c;
}
By commenting out the #include "JSONParser.hpp" out of main, I was able to remove the error, therefore definitely a linking issue.
Aucun commentaire:
Enregistrer un commentaire