jeudi 17 juin 2021

C++ already defined in Main.obj [duplicate]

I added a header with some funtions. But im having LNK2005 errors saying the variables declared in main.h are already defined in main.obj. How could i fix this?

My main.cpp

#include "Main.h"
//#include "Service.h"


int main(int argc, char* argv[])
{
...

My Main.h

#include ...
...
namespace fs = std::filesystem;
using std::filesystem::current_path;
using namespace std;
int is_receiving = 0;
bool sqlserver = false;
std::string opt_host_name1; /* HOST */
std::string opt_user_name1; /* USERNAME */
std::string opt_password1; /* PASSWORD */
const unsigned int opt_port_num = 3306; /* PORT */
const char* opt_socket_name = NULL; /* SOCKET NAME, DO NOT CHANGE */
std::string opt_db_name1; /* DATABASE NAME */
unsigned int opt_flags = 0; /* CONNECTION FLAGS, DO NOT CHANGE */
#define BUFSIZE 512

string aetitle(string called, string calling);
bool is_older_than(const fs::path& path, int hrs);

My Service.cpp


#include "Main.h"

string aetitle(string called, string calling)
{
...
}
bool is_older_than(const fs::path& path, int hrs)
{
...
}

Aucun commentaire:

Enregistrer un commentaire