(C++)Appending .zip to .exe using Chilkat 9.4.0 - unable to compile/link -


i'm trying "join" .exe file , .zip file method educational purposes. borrowed code here: http://www.chilkatforum.com/questions/2354/how-to-write-a-self-extractor-for-the-windows-os . code:

    #include <windows.h>     #include <ckbytedata.h>     #include <ckfileaccess.h>      int main(int argc, char* argv[])     {         const char *exefile = "c:/program.exe";             ckfileaccess foo;         int exesize = foo.filesize(exefile);         int nzeros = 4 - (exesize % 4);         if (nzeros < 4)         {             ckbytedata zeros;             zeros.appendcharn(0,nzeros);             // append zeros .exe             zeros.appendfile(exefilee);         }      // append .zip .exe          ckbytedata zipdata;         zipdata.loadfile("c:/mine.zip");         zipdata.appendfile(exefile);          return 0;     } 

these header files:

ckbytedata.h:

    // ckbytedata.h: interface ckbytedata class.     //     //////////////////////////////////////////////////////////////////////      #ifndef _ckbytedata_h     #define _ckbytedata_h        #include "ckobject.h"      #include "ckstring.h"      // ckbytedata class convenient class holding block of     // binary data, or non-null terminated text data.      #ifndef __sun__     #pragma pack (push, 8)     #endif         // class: ckbytedata     class ckbytedata : public ckobject     {         public:         ckbytedata();         ~ckbytedata();          ckbytedata(const ckbytedata &);         ckbytedata &operator=(const ckbytedata &);          // begin public interface         bool get_utf8(void) const;         void put_utf8(bool b);           // clears object of data.         void clear(void);          // size in bytes.             unsigned long getsize(void) const;          bool equals2(const void *pbytedata, unsigned long szbytedata) const;         bool equals(const ckbytedata &db) const;          // pointer data.             const unsigned char *getdata(void) const;             const unsigned char *getbytes(void) const;             const unsigned char *getdataat(unsigned long byteindex) const;             const unsigned char *getrange(unsigned long byteindex, unsigned long numbytes);             const char *getrangestr(unsigned long byteindex, unsigned long numansichars);          unsigned char getbyte(unsigned long byteindex) const;         char getchar(unsigned long byteindex) const;         unsigned int getuint(unsigned long byteindex) const;         int getint(unsigned long byteindex) const;         unsigned short getushort(unsigned long byteindex) const;         short getshort(unsigned long byteindex) const;          void appendrandom(int numbytes);          void appendint(int v, bool littleendian);         void appendshort(short v, bool littleendian);         const char *getencodedrange(const char *encoding, unsigned long index, unsigned long numbytes);         void appendrange(const ckbytedata &bytedata, unsigned long index, unsigned long numbytes);         void ensurebuffer(unsigned long numbytes);         // return -1 if not found, otherwise returns index.         int findbytes2(const void *pbytedata, unsigned long szbytedata);         int findbytes(const ckbytedata &bytedata);          bool beginswith2(const void *pbytedata, unsigned long szbytedata);         bool beginswith(const ckbytedata &bytedata);          void removechunk(unsigned long index, unsigned long numbytes);         void byteswap4321(void);         void pad(int blocksize, int paddingscheme);         void unpad(int blocksize, int paddingscheme);         bool is7bit(void) const;         const char *computehash(const char *hashalg, const char *encoding);          // encoding can "base64", "quoted-printable", "hex", or "url"         const char *getencoded(const char *encoding);         const wchar_t *getencodedw(const wchar_t *encoding);          void replacechar(unsigned char c, unsigned char replacement);          // append more data             //void append(const unsigned char *data, unsigned long numbytes);         //void append(const char *bytedata, unsigned long numbytes);         void append2(const void *pbytedata, unsigned long szbytedata);         void append(const ckbytedata &db);          // appends null-terminated sequence of bytes, may characters in multibyte charset.          void appendstr(const char *str);              // appends string, charset must explictly specified because         // unicode string first converted charset (such utf-8) prior         // appending.         void appendstrw(const wchar_t *str, const wchar_t *charset);          void appendchar(char ch);         void appendcharn(char ch, int numtimes);          // encoding can "base64", "quoted-printable", "hex", or "url"         void appendencoded(const char *str, const char *encoding);         void appendencodedw(const wchar_t *str, const wchar_t *encoding);          void encode(const char *encoding, ckstring &str);         void encodew(const wchar_t *encoding, ckstring &str);          // load complete file object.  contents of object         // automatically cleared before file loaded, result         // mirror image (in memory) of bytes in file.             bool loadfile(const char *path);         bool savefile(const char *path);              bool loadfilew(const wchar_t *path);         bool savefilew(const wchar_t *path);          // create new file, or append existing file.         bool appendfile(const char *path);         bool appendfilew(const wchar_t *path);          // discards last numbytes of data.             void shorten(unsigned long numbytes);          // ckbytedata use *your* memory buffer, , not delete         // when object destructed.           void borrowdata(void *pbytedata, unsigned long szbytedata);          // removes data ckbytedata object.  caller receive         // pointer memory buffer, , responsible deleting it.         // (example:          //  unsigned char *data = bytedata.removedata();         //  ... data....         //  delete [] data;         unsigned char *removedata(void);          void preallocate(unsigned long expectednumbytes);          const wchar_t *to_ws(const char *charset);             const char *to_s(void);          const char *getxmlcharset(void);           // bytes_insert_point          // end public interface           private:         // internal implementation.         void *m_impl;         bool m_utf8;    // if true, input "const char *" parameters utf-8, otherwise ansi strings.         void *m_presultdata;    // to_s(), getrange(), getrangestr()          public:         // used internally chilkat.         void *getimpl(void) const;         const void *getimplc(void) const;         void setimpl(void *impl);      };      #ifndef __sun__     #pragma pack (pop)     #endif       #endif 

and ckfileaccess.h:

    // ckfileaccess.h: interface ckfileaccess class.     //     //////////////////////////////////////////////////////////////////////      #ifndef _ckfileaccess_h     #define _ckfileaccess_h         class ckbytedata;     class ckdatetime;      #include "ckstring.h"     #include "ckmultibytebase.h"      #ifdef win32     #pragma warning( disable : 4068 )     #pragma unmanaged     #endif       /*         important: objects returned methods non-const pointers must deleted         calling application.         */      #ifndef __sun__     #pragma pack (push, 8)     #endif       // class: ckfileaccess     class ckfileaccess  : public ckmultibytebase     {         public:         ckfileaccess();         virtual ~ckfileaccess();          // may called when finished object free/dispose of         // internal resources held object.          void dispose(void);          // begin public interface               bool readentiretextfile(const char *path, const char *charset, ckstring &outstrfilecontents);              const char *readentiretextfile(const char *path, const char *charset);         // currentdir_begin         void get_currentdir(ckstring &str);         const char *currentdir(void);         // currentdir_end         // endoffile_begin         bool get_endoffile(void);         // endoffile_end         // setcurrentdir_begin         bool setcurrentdir(const char *path);         // setcurrentdir_end         // appendansi_begin         bool appendansi(const char *text);         // appendansi_end         // appendtext_begin         bool appendtext(const char *text, const char *charset);         // appendtext_end         // appendunicodebom_begin         bool appendunicodebom(void);         // appendunicodebom_end         // appendutf8bom_begin         bool appendutf8bom(void);         // appendutf8bom_end         // dirautocreate_begin         bool dirautocreate(const char *path);         // dirautocreate_end         // dircreate_begin         bool dircreate(const char *path);         // dircreate_end         // dirdelete_begin         bool dirdelete(const char *path);         // dirdelete_end         // dirensureexists_begin         bool dirensureexists(const char *filepath);         // dirensureexists_end         // fileclose_begin         void fileclose(void);         // fileclose_end         // filecopy_begin         bool filecopy(const char *existingpath, const char *newpath, bool failifexists);         // filecopy_end         // filedelete_begin         bool filedelete(const char *path);         // filedelete_end         // fileexists_begin         bool fileexists(const char *path);         // fileexists_end         // fileopen_begin         bool fileopen(const char *path, unsigned int accessmode,              unsigned int sharemode, unsigned int createdisp, unsigned int attr);         // fileopen_end         // fileread_begin         bool fileread(int numbytes, ckbytedata &outbytes);         // fileread_end         // filerename_begin         bool filerename(const char *existingpath, const char *newpath);         // filerename_end         // fileseek_begin         bool fileseek(int offset, int origin);         // fileseek_end         // filesize_begin         int filesize(const char *path);         // filesize_end         // filewrite_begin         bool filewrite(const ckbytedata &data);         // filewrite_end         // gettempfilename_begin         bool gettempfilename(const char *dirname, const char *prefix, ckstring &outstr);         const char *gettempfilename(const char *dirname, const char *prefix);         // gettempfilename_end         // readentirefile_begin         bool readentirefile(const char *path, ckbytedata &outbytes);         // readentirefile_end         // treedelete_begin         bool treedelete(const char *path);         // treedelete_end         // writeentirefile_begin         bool writeentirefile(const char *path, const ckbytedata &filedata);         // writeentirefile_end         // writeentiretextfile_begin         bool writeentiretextfile(const char *path, const char *filedata, const char *charset, bool includepreamble);         // writeentiretextfile_end         // splitfile_begin         bool splitfile(const char *filetosplit, const char *partprefix, const char *partextension, int partsize, const char *destdir);         // splitfile_end         // reassemblefile_begin         bool reassemblefile(const char *partsdirpath, const char *partprefix, const char *partextension, const char *reassembledfilename);         // reassemblefile_end         // readbinarytoencoded_begin         bool readbinarytoencoded(const char *path, const char *encoding, ckstring &outstr);         const char *readbinarytoencoded(const char *path, const char *encoding);         // readbinarytoencoded_end         // fileopenerror_begin         int get_fileopenerror(void);         // fileopenerror_end         // fileopenerrormsg_begin         void get_fileopenerrormsg(ckstring &str);         const char *fileopenerrormsg(void);         // fileopenerrormsg_end         // openforread_begin         bool openforread(const char *filepath);         // openforread_end         // openforwrite_begin         bool openforwrite(const char *filepath);         // openforwrite_end         // openforreadwrite_begin         bool openforreadwrite(const char *filepath);         // openforreadwrite_end         // openforappend_begin         bool openforappend(const char *filepath);         // openforappend_end         // replacestrings_begin         int replacestrings(const char *path, const char *charset, const char *existingstring, const char *replacementstring);         // replacestrings_end         // setfiletimes_begin         bool setfiletimes(const char *path, ckdatetime &create, ckdatetime &lastaccess, ckdatetime &lastmodified);         bool setlastmodified(const char *path, ckdatetime &lastmodified);         // setfiletimes_end          // fileaccess_insert_point          // end public interface            // internal use only.         private:         // don't allow assignment or copying these objects.         ckfileaccess(const ckfileaccess &) { }          ckfileaccess &operator=(const ckfileaccess &) { return *this; }         ckfileaccess(void *impl);        };      #ifndef __sun__     #pragma pack (pop)     #endif       #endif 

building solution these gives me following error:

    1>------ build started: project: general, configuration: debug win32 ------     1>  silent.cpp     1>silent.obj : error lnk2019: unresolved external symbol "public: virtual __thiscall ckfileaccess::~ckfileaccess(void)" (??1ckfileaccess@@uae@xz) referenced in function _main     1>silent.obj : error lnk2019: unresolved external symbol "public: bool __thiscall ckbytedata::loadfile(char const *)" (?loadfile@ckbytedata@@qae_npbd@z) referenced in function _main     1>silent.obj : error lnk2019: unresolved external symbol "public: virtual __thiscall ckbytedata::~ckbytedata(void)" (??1ckbytedata@@uae@xz) referenced in function _main     1>silent.obj : error lnk2019: unresolved external symbol "public: bool __thiscall ckbytedata::appendfile(char const *)" (?appendfile@ckbytedata@@qae_npbd@z) referenced in function _main     1>silent.obj : error lnk2019: unresolved external symbol "public: void __thiscall ckbytedata::appendcharn(char,int)" (?appendcharn@ckbytedata@@qaexdh@z) referenced in function _main     1>silent.obj : error lnk2019: unresolved external symbol "public: __thiscall ckbytedata::ckbytedata(void)" (??0ckbytedata@@qae@xz) referenced in function _main     1>silent.obj : error lnk2019: unresolved external symbol "public: int __thiscall ckfileaccess::filesize(char const *)" (?filesize@ckfileaccess@@qaehpbd@z) referenced in function _main     1>silent.obj : error lnk2019: unresolved external symbol "public: __thiscall ckfileaccess::ckfileaccess(void)" (??0ckfileaccess@@qae@xz) referenced in function _main     1>c:\users\simboyd\documents\visual studio 2010\projects\general\debug\general.exe : fatal error lnk1120: 8 unresolved externals     ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

can tell me should changed here? understand error in header files, right? in advance :d


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -