c++ error LNK2019: unresolved external symbol .obj -


first of all, know there on hundred similar posts out there same error, , entire reason because error given useless can be..

i've searched through on 20 solutions through google , still can't figure out error in code, therefore i'm making question.

here error:

error   2   error lnk1120: 1 unresolved externals   c:\users\kevin cruijssen\documents\visual studio 2013\projects\clientoscpp-trunk\ cpp-and-so-client\clientoscpp\debug\clientoscpp.exe   clientoscpp  error   1   error lnk2019: unresolved external symbol "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall commandsynchandler::filejustrenamed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?filejustrenamed@commandsynchandler@@aae?av?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@v23@@z) referenced in function "private: void __thiscall commandsynchandler::readfilestosync(class socket *)" (?readfilestosync@commandsynchandler@@aaexpavsocket@@@z)    c:\users\kevin cruijssen\documents\visual studio 2013\projects\clientoscpp-trunk\ cpp-and-so-client\clientoscpp\commandsynchandler.obj  clientoscpp 

and here classes error occurring in:

commandsynchandler.h:

#pragma once  #include "commandhandler.h"  class commandsynchandler : public commandhandler { private:     commandsynchandler(void);     commandsynchandler(const char* szcommand);      static commandsynchandler m_csynchandler;     std::string localfolder, remotefolder;      std::string filejustrenamed(std::string filename);      void readfilestosync(socket* socket);  public:     virtual ~commandsynchandler(void);      virtual commandhandler* clone() const;      virtual void handlecommand(socket* socket, std::vector<std::string>& rvparams); }; 

commandsynchandler.cpp:

#include "stdafx.h"  #include "commandsynchandler.h" #include "constants.h" #include "filereader.h" #include "filehandler.h" #include "commandfactory.h"  #include <iostream> #include <stdio.h> #include <dirent.h> #include <sys/stat.h> #include <time.h>  commandsynchandler commandsynchandler::m_csynchandler("sync");  commandsynchandler::commandsynchandler(const char* szcommand) : commandhandler(szcommand){}  commandsynchandler::commandsynchandler(void){}  commandsynchandler::~commandsynchandler(void){}  commandhandler* commandsynchandler::clone() const{     return new commandsynchandler; }  std::string filejustrenamed(std::string filename){     std::string result = "";      /*std::string filedir;     const size_t last_slasg_index = filename.rfind(path_separator);     if (std::string::npos != last_slasg_index)         filedir = filename.substr(0, last_slasg_index);     filedir = server_directory + filedir.substr(base_directory.length());      // first check wether file exact same size      // before continueing compare bytes/md5-hashes (which takes longer)     filereader* reader1;     try{         reader1 = new filereader(filename.c_str());     }     catch (const char* e){         (void)e;          std::cout << "cannot open file: " << filename << std::endl;         return result = "";     }     int size1 = reader1->filesize();      // loop through files in server's same directory     filehandler filehandler;     std::vector<std::string> filesindir;     filehandler.getfiles(filedir.c_str(), filesindir);     each (std::string curfile in filesindir) {         bool continueloop = true;          filereader* reader2 = null;         try{             reader2 = new filereader(curfile.c_str());         }         catch (const char* e){             (void)e;              std::cout << "cannot open file: " << filename << std::endl;             continueloop = false;         }          if (continueloop){             int size2 = reader2->filesize();              if (size1 != size2){                 result = "";                 continueloop = false;             }              if (continueloop){                 // if size of both files same, continue check if exact same file                 // comparing byte-blocks of file-buffer                 const int buffer_size = 1024;                  std::ifstream file1(filename.c_str(), std::ios::in | std::ios::binary);                 std::ifstream file2(curfile.c_str(), std::ios::in | std::ios::binary);                  if (!file1.good() || !file2.good()){                     result = "";                     continueloop = false;                 }                  if (continueloop){                     std::streamsize bytescount1 = 0;                     std::streamsize bytescount2 = 0;                     char* buffer1 = new char[buffer_size]();                     char* buffer2 = new char[buffer_size]();                      {                         file1.read(buffer1, buffer_size);                         file2.read(buffer2, buffer_size);                         bytescount1 = file1.gcount();                         bytescount2 = file2.gcount();                          if (bytescount1 != bytescount2 || std::memcmp(buffer1, buffer2, bytescount1) != 0)                             continueloop = false;                     } while (file1.good() || file2.good());                      if (continueloop)                         return curfile;                 }             }         }     }*/      return result = ""; }  void commandsynchandler::handlecommand(socket* socket, std::vector<std::string>& rvparams){     if (rvparams.size() < 3)         throw "not enough parameters specified";      localfolder = rvparams.at(1);     remotefolder = rvparams.at(2);     std::string filepath = base_directory;     filepath.append(localfolder);      rvparams.erase(rvparams.begin() + 1);     std::string command = buildcommand(rvparams);     socket->writeline(command.c_str());      /*| todo     struct stat file_stats;     struct tm* clock;     stat(filepath.c_str(), &file_stats);     clock = gmtime(&(file_stats.st_mtime));     mktime(clock);     */      std::vector<std::string> vfiles;     std::string directory = base_directory;     directory.append(localfolder);      filehandler handler;     handler.getfiles(directory.c_str(), vfiles);      (std::string file : vfiles){          file.erase(0, base_directory.size());         //translate local folder remote folder sync         int index = file.find(localfolder);         if (index >= 0){             file.erase(index, localfolder.size());             file.insert(index, remotefolder);         }         socket->writeline(file.c_str());     }     socket->writeline("");     //std::string file = remotefolder;     //file.append(path_separator);     //file.append(ent->d_name);     //socket->writeline(file.c_str());      readfilestosync(socket); }  void commandsynchandler::readfilestosync(socket* socket){     char* returnfile = new char[maxpath + 1];     char* returnline = new char[maxread + 1];     commandhandler* handler = commandfactory::create("put");      std::vector<std::string> vfiles;     while (socket->readline(returnfile, maxpath) > 0)         vfiles.push_back(std::string(returnfile));      (std::string remotefile : vfiles){         std::string file = remotefile;         //translate remote folder local folder sync         int index = file.find(remotefolder);          std::vector<std::string> vparams;         // check wether file different or renamed         std::string oldfile = filejustrenamed(file);         if (oldfile != "") {             vparams.push_back(std::string("ren"));             vparams.push_back(oldfile);             vparams.push_back(file);         }         else {             // replace file             if (index >= 0){                 file.erase(index, remotefolder.size());                 file.insert(index, localfolder);             }              vparams.push_back(std::string("put"));             vparams.push_back(file);             vparams.push_back(std::string(remotefile));         }          std::cout << "sending " << file << std::endl;         handler->handlecommand(socket, vparams);          // read feedback put command         while (socket->readline(returnline, maxread) > 0)             std::string x = returnline;//std::cout << returnline << std::endl;     }      delete handler;     delete[] returnfile;     delete[] returnline;      throw "sync completed"; } 

anyone has idea? because after more 2 hours want fixed can continue crappy project..

ps: in function filejustrenamed commented out, know error isn't somewhere in code.

pss: ignore bad programming.. i'm kinda new c++.

psss: worked before filejustrenamed part added in both .h , .cpp files , in readfilestosync function.

some things tried:

  • changing order of functions in .h-file
  • checking if have commandsynchandler.h included in .cpp-file
  • uncommenting code in filejustrenamed (see first ps)

i made small mistake order of functions in header/cpp files or small forgotten add (like include), said, after more 2 hours have block-eyes , don't have clue how fix it..

so please help.. in advance.

in "commandsynchandler.cpp", in definition of function filejustrenamed() prepend class-name commandsynchandler function name, this:

std::string commandsynchandler::filejustrenamed(std::string filename){


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -