My situation: I'm writing DLL, it has many classes, but I export only one:
#pragma once
#ifdef APIDLL_EXPORTS
#define APIDLL_API __declspec(dllexport)
#else
#define APIDLL_API __declspec(dllimport)
#endif
class Process; // <-- ApiClient uses pointer to that class, so I forward declare it
class APIDLL_API ApiClient
{
web::http::client::http_client client; // (*) line
public:
void check(Process * p);
}
And In ApiClient.cpp
I have #include "pch.h"
, which is:
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#include "framework.h"
#include <sstream>
#include <iomanip>
#include <cpprest/http_client.h>
#include <cpprest/json.h>
#include <cpprest/asyncrt_utils.h>
#endif //PCH_H
As it is compiling as DLL, it won't compile when I link it to console app. I put in includes
directory ApiClient.h
(because I export and need only this) (path to .lib is correct). I get error in (*) line E0276 name followed by '::' must be a class or namespace name
. It looks like compiler can't see definition of http_client
. So if I add #include <cpprest/http_client.h>
in ApiClient.h
, all is good.
But I'd like to have every needed dependency in 'pch.h'. Should I copy it to includes
directory also? But what if I add some relative paths to pch.h?