0

Hi,
I am working on a VC++ (Visual Studio 2008) Module and i am new on this module. This module is working on 32bit fine, i need to convert this in 64 bit. I installed x64 bit compiler and select 64 bit in Project Properties.

I got following error while i try to convert 32 bit code in 64 bit:

Error 2 error LNK2001: unresolved external symbol BZ2_bzopen jdefile.obj
Error 3 error LNK2001: unresolved external symbol BZ2_bzread jdefile.obj
Error 4 error LNK2001: unresolved external symbol BZ2_bzstat64 jdefile.obj
Error 5 error LNK2001: unresolved external symbol BZ2_bzwrite jdefile.obj
Error 6 error LNK2001: unresolved external symbol BZ2_bzgetpos64 jdefile.obj
Error 7 fatal error LNK1120: 6 unresolved externals C:\Documents and Settings\ns553t\My Documents\Updated BARTSO\x64\Release\BARTSO.exe BARTSO


I attached both file (jdefile.h and jdefile.cpp)

Thanks in advance

Attachments
#include "stdafx.h"
#include <windows.h>
#include <share.h>
#include <sys\stat.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <string.h>
#include <memory.h>
#include <io.h>
#include <errno.h>
#include <time.h>
#include <stdio.h>
#include "jdefile.h"
#include "hlib.h"
//#include "e2a.h"
#include <Winioctl.h>


#pragma warning( push )
#pragma warning( disable : 4996 )
#pragma warning( disable : 4244 ) //warning C4244: conversion from 'intptr_t' to 'long', possible loss of data
#pragma warning( disable : 4267 ) //warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data

#define BZMAGIC_SIZE 10
unsigned char bzmagic[BZMAGIC_SIZE] =
	{ 0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59 };


#define GZMAGIC_SIZE 2
unsigned char gzmagic[GZMAGIC_SIZE] =
	{ 0x1F, 0x8B };

#define PKMAGIC_SIZE 4
unsigned char pkmagic[PKMAGIC_SIZE] =
	{0x04,0x03,0x4b,0x50};

#ifdef _USE_PKZIP
typedef struct{
	unsigned char magic[4];
	unsigned char version[2];
	unsigned char bitflag[2];
	unsigned char method[2];
	unsigned char lastmodfiletime[2];
	unsigned char lastmodfiledate[2];
	unsigned char crc[4];
	unsigned char compressedsize[4];
	unsigned char uncompressedsize[4];
	unsigned char filenamelength[2];
	unsigned char extrafieldlength[2];
    char filename[64*1024];
    char extrafield[64*1024];
}pk_localfile_header;



#endif



typedef struct{
	char name[100];
	char mode[8];
	char uid[8];
	char gid[8];
	char size[12];
	char mtime[12];
	char chksum[8];
	char type;
	char linkname[100];
	char magic[6];
	char version[2];
	char uname[32];
	char gname[32];
	char devmajor[8];
	char devminor[8];
	char prefix[155];
}tar_header;




jdefile::jdefile ()
{
	setprocessingstring ("");
	setcompletestring ("");
	m_callback = NULL;
	construct ();
}

jdefile::jdefile (int displayfreq)
{
	construct ();
	m_displayfreq = displayfreq;
}

jdefile::~jdefile ()
{
	if (m_method) {
		free (m_method);
	}
	if (m_curfile) {
		fclose (m_curfile);
	}
#ifdef _BZLIB_H
	if (m_compression == JDE_BZIP2) {
		if (m_BZcurfile) {
			BZ2_bzclose (m_BZcurfile);
		}
	}
#endif
}

int
jdefile::get_safe (void)
{
	return m_safe;
}

void
jdefile::set_safe (int safe)
{
	m_safe = safe;
}

bool jdefile::safe_open (const char *name)
{								//returns true no error false otherwise
	FILE *f;
	int mode;
	int pmode;
	int fd;
	time_t local_time;
	f = NULL;

#ifdef PKZIP
	if (m_compression==JDE_PKZIP){
		if(m_method[0]== 'r'){
			
			//get file size 
			char command [MAX_PKZIP_FILES*128+256] ="unzip.exe -l \"";
			strcat(command,name);
			strcat(command,"\" ");
			
			for( int i = 0;i<m_inner_file_count;i++){
				strcat(command,"\"");
				strcat(command,m_inner_file_names[i]);
				strcat(command,"\" ");
			}
			m_curfile = _popen(command,m_method);
			
			int size =0;
			char line[512];
			while(fgets(line,sizeof(line),m_curfile)){
				size=atoi(line+1);
			}

			m_finfo.size=size;
			if(_pclose(m_curfile)){//error opening file
				return false;
			}

			//open file with popen
			strcpy(command,"unzip.exe -p \"");
			strcat(command,name);
			strcat(command,"\" ");
			for( int i = 0;i<m_inner_file_count;i++){
				strcat(command,"\"");
				strcat(command,m_inner_file_names[i]);
				strcat(command,"\" ");
			}
			m_curfile = _popen(command,m_method);
			return true;
		}else if (m_method[0]=='w'){
			//open file
			char command [MAX_PKZIP_FILES*128+128] ="zip.exe -O \"";
			strcat(command,m_inner_file_names[0]);
			strcat(command,"\" \"");
			strcat(command,name);
			strcat(command,"\" -");
			m_curfile = _popen(command,"wb");
			fwrite("testing",strlen("testing")+1,1,m_curfile);
			if(_pclose(m_curfile)){
				return false;
			}
			m_curfile = _popen(command,m_method);

			return true;
		}else{
			return false;
		}

	}

#endif

	if ((m_usemagic) && (m_method[0] == 'r')) {

#if defined(_BZLIB_H)||defined(ZLIB_H) 
		f = fopen (name, "rb");
#if (BZMAGIC_SIZE > GZMAGIC_SIZE)
		unsigned char magic[BZMAGIC_SIZE];
#else
		unsigned char magic[GZMAGIC_SIZE];
#endif
		if (f == NULL) {
			return false;
		}
		fread (magic, 1, max(BZMAGIC_SIZE,GZMAGIC_SIZE), f);
		m_compression = JDE_DEFAULT_COMP;
		fclose (f);
		f = NULL;
#ifdef _BZLIB_H
		if (!memcmp (magic, bzmagic, 3)) {	//check for "BZh"
			if ((magic[3] <= '9') && (magic[3] >= '1')) {
				if (!memcmp (magic + 4, bzmagic + 4, 6)) {
					m_compression = JDE_BZIP2;
				}
			}
		}
#endif

#ifdef ZLIB_H
		if(!memcmp(magic,gzmagic,GZMAGIC_SIZE)){
			m_compression = JDE_GZIP;
		}
#endif

#endif //_BZLIB_H or ZLIB_H

	}
	
	if(m_method[0]=='w'){	//turn ntfs compression on or off
		if(m_compression==JDE_NTFS_COMP){
			static unsigned short in_buffer = COMPRESSION_FORMAT_LZNT1;
			static unsigned long bytes_returned;			
			int fd2 =_creat(name, _S_IREAD | _S_IWRITE);
			if(fd2 < 0) {
				//	Create failed.
				fprintf(stderr, "Could not create %s. errno = %d\n", name, errno);
				return false;
			}
			_setmode(fd2, _O_BINARY);
			int status = DeviceIoControl(
				(HANDLE)_get_osfhandle(fd2),	// handle to file 
				FSCTL_SET_COMPRESSION,      // dwIoControlCode
				&in_buffer,			        // input buffer
				sizeof(in_buffer),			// size of input buffer
				NULL,                       // lpOutBuffer
				0,                          // nOutBufferSize
				&bytes_returned,			// number of bytes returned
				NULL);						// OVERLAPPED structure
				
			if(status == 0) {
				//	Compression request failed.
				status = GetLastError();
				fprintf(stderr,"Could not set %s to uncompressed. GetLastError() returned %d\n",name, status);
			}
			_close(fd2); // done creating uncompressed file
		}else if(m_compression==JDE_UNCOMPRESSED){
			static unsigned short in_buffer = COMPRESSION_FORMAT_NONE;
			static unsigned long bytes_returned;			
			int fd2 =_creat(name, _S_IREAD | _S_IWRITE);
			if(fd2 < 0) {
				//	Create failed.
				fprintf(stderr, "Could not create %s. errno = %d\n", name, errno);
				return false;
			}
			_setmode(fd2, _O_BINARY);
			int status = DeviceIoControl(
				(HANDLE)_get_osfhandle(fd2),	// handle to file 
				FSCTL_SET_COMPRESSION,      // dwIoControlCode
				&in_buffer,			        // input buffer
				sizeof(in_buffer),			// size of input buffer
				NULL,                       // lpOutBuffer
				0,                          // nOutBufferSize
				&bytes_returned,			// number of bytes returned
				NULL);						// OVERLAPPED structure
				
			if(status == 0) {
				//	Compression request failed.
				status = GetLastError();
				fprintf(stderr,"Could not set %s to uncompressed. GetLastError() returned %d\n",name, status);
			}
			_close(fd2); // done creating uncompressed file			
		}
	}
	if ((m_compression == JDE_DEFAULT_COMP)||
		(m_compression == JDE_UNCOMPRESSED)||
		(m_compression == JDE_NTFS_COMP) ){
		if (m_safe) {
			m_current_retries = 0;
			while (1) {
				if ((m_max_retries > 0) && (m_current_retries >= m_max_retries)) {
					fprintf (stderr,
							 "Unable to open file %s in share denied write mode.\n"
							 "Maximum number of retries (%d)has been met\n",
							 name, m_max_retries);
					break;
				}
				pmode = 0;
				if (m_method[0] == 'r') {
					mode = _O_RDONLY;
				} else if (m_method[0] == 'w') {
					mode = _O_WRONLY | _O_CREAT;
					pmode = _S_IREAD | _S_IWRITE;
				} else if (m_method[0] == 'a') {
					mode = _O_WRONLY | _O_APPEND | _O_CREAT;
					pmode = _S_IREAD | _S_IWRITE;
				} else {
					fprintf (stderr, "Unknown mode %s\n", m_method);
				}
				if (m_method[1] == 'b') {
					mode |= _O_BINARY;
					if (m_method[2] != 0) {
						fprintf (stderr, "Unknown mode %s\n", m_method);
					}
				} else if (m_method[1] == 0) {
					mode |= _O_TEXT;
				} else {
					fprintf (stderr, "Unknown mode %s\n", m_method);
				}
				fd = sopen (name, mode, _SH_DENYWR, pmode);
				if (fd < 0) {
					//              if(errno == ENOENT ){
					//
					//              }
					if (m_safe < 0) {
						fprintf (stderr,
								 "Unable to open file %s in share denied write mode.\n",
								 name);
						break;
					} else {
						m_current_retries++;

						time (&local_time);
						fprintf (stderr,
								 "Unable to open file %s in share denied write mode.  \n"
								 "System time is %s"
								 "Sleeping for %d seconds before retry %d\n",
								 name, ctime (&local_time), m_safe,
								 m_current_retries);

						Sleep (m_safe * 1000);
					}
				} else {
					m_curfile = fdopen (fd, m_method);
					break;
				}
			}
		} else {
			m_curfile = fopen (name, m_method);
		}
		if (m_curfile) {
			if(m_callback){
				m_callback(this);
			}
#ifdef _USE_TAR
			if(m_tarred){
				return tar_open_next();
			}
#endif
			return true;
		} else {
			return false;
		}
	}
#ifdef _BZLIB_H
	else if (m_compression == JDE_BZIP2) {
		if (m_safe) {
			m_current_retries = 0;
			while (1) {
				if ((m_max_retries > 0) && (m_current_retries >= m_max_retries)) {
					fprintf (stderr,
							 "Unable to open file %s in share denied write mode.\n"
							 "Maximum number of retries (%d)has been met\n",
							 name, m_max_retries);
					break;
				}
				int
				  mode;
				int
				  pmode = 0;
				if (m_method[0] == 'r') {
					mode = _O_RDONLY;
				} else if (m_method[0] == 'w') {
					mode = _O_WRONLY | _O_CREAT;
					pmode = _S_IREAD | _S_IWRITE;
				} else if (m_method[0] == 'a') {
					mode = _O_WRONLY | _O_APPEND | _O_CREAT;
					pmode = _S_IREAD | _S_IWRITE;
				} else {
					fprintf (stderr, "Unknown mode %s\n", m_method);
				}
				if (m_method[1] == 'b') {
					mode |= _O_BINARY;
					if (m_method[2] != 0) {
						fprintf (stderr, "Unknown mode %s\n", m_method);
					}
				} else if (m_method[1] == 0) {
					mode |= _O_TEXT;
				} else {
					fprintf (stderr, "Unknown mode %s\n", m_method);
				}
				fd = sopen (name, mode, _SH_DENYWR, pmode);
				if (fd < 0) {
					//              if(errn
#ifndef _JDEFILE_H_
#define _JDEFILE_H_
#ifdef DOXYGEN
namespace DataLibC{
#endif

#pragma once
// "jdefile.cpp"
#include <stdlib.h>
#include <stdio.h>
#include <sys/timeb.h>
#include <io.h>
#include <time.h>


#ifdef WIN32
#include <basetsd.h>
#endif

#ifdef __CYGWIN__
#define _MAX_PATH   260 /* max. length of full pathname */
#define _MAX_DRIVE  3   /* max. length of drive component */
#define _MAX_DIR    256 /* max. length of path component */
#define _MAX_FNAME  256 /* max. length of file name component */
#define _MAX_EXT    256 /* max. length of extension component */

struct _finddatai64_t {
        unsigned    attrib;
        time_t      time_create;    /* -1 for FAT file systems */
        time_t      time_access;    /* -1 for FAT file systems */
        time_t      time_write;
        __int64     size;
        char        name[260];
};

#endif	//cygwin


//if you wish to read and write bzip files natively from jdefile you need to
//set _USE_BZIP2 flag true
//in VC++ .net go to project...properties...c/c++...preprocessor...
//and paste ;_USE_BZIP2 on to end of Preprocessor Definitions
#ifdef _USE_BZIP2
#include "bzlib.h"
#endif	//_USE_BZIP2

#ifdef _USE_GZIP
#include "zlib.h"
#endif


/// The maxinum line size for functions like getargv
#ifndef JDE_MAX_LINE_SIZE
#define JDE_MAX_LINE_SIZE (64*1024)
#endif

/*#define ERRORLEN 60
struct ERROR {
	char errortext[ERRORLEN];
	int msglen;
	int count;
	int errornum;
	int order;
	ERROR *prev;
	ERROR *next;
};*/


/// Types of compression built into JDEfile.
typedef enum {
	JDE_UNCOMPRESSED,	///< Use no compression
#ifdef _BZLIB_H
	JDE_BZIP2,			///< Use bzip2 compression
#endif
#ifdef ZLIB_H
	JDE_GZIP,			///< Use gzip compression
#endif
	JDE_NTFS_COMP,		///< Use NTFS compression
	JDE_DEFAULT_COMP,	///< Use filesystem default
#ifdef PKZIP
	JDE_PKZIP,
#endif
}JDE_FILE_COMPRESSION;

#ifdef PKZIP
#define MAX_PKZIP_FILES 128
#endif

struct FSTRUCT {
	FILE *f;
	INT64 flen;
	fpos_t pos;
	_timeb time_started;
	time_t time_started_timet;
};


/** A class for reading a writing a variety files.
    jdefile allows a program to open, read, and write files while showing status.
    jdefile can also be used to read and write files compressed using the bzip2,gzip,
	or PKZIP libraries.
*/

class jdefile {
public:
	/// Simple Constructor
	jdefile();
	/// Other Constructor
	jdefile(int displayfreq);
	/// Destructor
	~jdefile();

	/** Open a file
	    @param file_name name of file to open if allowwildcards true then wildcards are accepted
	    @param method method string for opening file ("rb","r","w",..)
	    @param safe open file in write protected mode? seconds to sleep between retries
	    @param max_retries maximum number of retries in safe mode, -1 = infinity
		@author JDE
	*/
	bool open(	const char *file_name,
				char *method="r",
				int safe=0,
				int max_retries=0);


	/// Sets m_curfile to stdin for reading from standard in
	bool openstdin();

	/// Sets m_curfile to stdout for writing to standard out
	bool openstdout();

	/// closes a file
	bool close();

	/**	reads a line of text from current file, returns the number of bytes read
		@param buf  The buffer in which to place read data
		@param size  The max number of bytes to read
		@author JDE
		@param ebcdic  Is data ebcdic? If so do you want to translate it to ascii?
	*/
	int gets(char *buf,size_t size,bool ebcdic=false);

	/**	prints a line of text to current file, returns the number of bytes written
		@author JDE
		@return Number of bytes written
		@param format  Format string that defines rest of parameters
	*/
	int printf(const char *format, ...);

	/**	prints a line of text to current file, returns the number of bytes written
		@author JDE
		@return Number of bytes written
		@param format  Format string that defines rest of parameters
	*/
	//int printf(int stdout, const char *format, ...);
	int printf(int printToStdoutStdErr, const char *format, ...);

	/** Write a string to the file
		@author JDE
		@return Number of bytes written
		@param out Null terminited string to write
	*/
	int puts(const char *out);

	/** get the size of current file in bytes
		@return Number of bytes
	*/
	INT64 size();

	/**	get name of current file
		@return the name of the current file
		@author JDE
	*/
	char *name();


	/** get name of file
		@return the fully-qualified path name of the current file
		@author JDE
	*/
	char *fullname();

	/** get current line count
		@return the current line count of the current file
		@author JDE
	*/
	int linecount();


	/** get the current offset
		@return the offset into the current file, in bytes
		@author JDE
	*/
	INT64 curpos();

	/** reads data from the current file
		@return number of bytes read or 0 if eof or error
		@param buf buffer to read data to
		@author JDE
		@param num number of bytes to read
	*/
	size_t read(void *buf,size_t num);

	/** writes num bytes to the current file
		@return number of bytes written
		@param buf data to write
		@param num number of bytes to write
		@author JDE
	*/
	int write(void *buf, size_t num);

	/**	sets the display frequency
		@return true for success / false for failure
		@author JDE
		@param  count The number of lines or read between refreshes (0 = off)
	*/
	bool setdisplayfreq(int count);

	/** Get total lines read
		@author JDE
		@return the total number of lines read from all files
	*/
	int totallines();

	/** Get total bytes read
		@author JDE
		@return the total number of bytes read from all files
	*/
	INT64 totalbytes();


	/** Turn on or off display all files
		@author JDE
		@param displayall true=display file progress relative all ALL files that match wildcard. false=display file progress relative to only the CURRENT file
	*/
	void displayallfiles(bool displayall);

	/** Turn on or off wildcard opening
		@author JDE
		@param b true=allow wildcard matching when opening/reading from files,
		false=do not allow wildcard matching
	*/
	void allowwildcards(bool);

	/// flushes current file
	void flush();

	operator FILE *() const;

	/** Reads a single line and splits it up into fields
		@return Number of fields returned
		@param  argv  vector to place field address into
		@param  maxargs  the maximum number of fields to return
		@author JDE
		@param  c  Charactor that divides fields
		@param  ebcdic  Is the data in EBCDIC or not
	*/
	int getargv(char **argv,int maxargs,char c,bool ebcdic=false);

	/// resets the file
	void reset();

	/** Is the file open?
		@author JDE
		@return true=file is currently open, false=file is not open
	*/
	bool isopen();

	/** Turn on or off flushing after every line
		@param flush On = true, Off = false
	*/
	void flusheachline(bool f);

	/** Is safe open on or off
		@return Seconds waited between retries
		@author ASE
	*/
	int get_safe(void);

	/** Turns safe file opening on or off and sets the number of seconds before retrying.
		Safe mode does not allow the file to be opened in write mode by any other program
		@author ASE
		@param  safe  number of seconds to wait between retries (0 disables safe mode)
	*/
	void set_safe(int safe);


	/** Sets the string that will be displayed as file is processed.
		@author JDE
		@param format String describing output
	*/
	void setprocessingstring(const char *format);

	/** extends string that will be displayed as file is processed
		@author JDE
		@param format String describing output to append to existing string
	*/
	void addtoprocessingstring(const char *format);

	/** Sets the string that will be displayed when file is done reading
		@author JDE
		@param  format String describing output
	*/
	void setcompletestring(const char *format);

	/** extends string that will be displayed when file is done reading
		@param format String describing output to append to existing string
		@author JDE
	*/
	void addtocompletestring(const char *format);

	/** Get string that describes processing output
		@return String representing output displayed while file is processing
		@author JDE
	*/
	const char *getprocessingstring();

	/** Get string that describes complete output
		@return String representing output displayed when file complete
		@author JDE
	*/
	const char *getcompletestring();

	/** Set the callback function for openening files
		@param callback Function to be called whenever another file is opened
		@author JDE
	*/
	void setcallback(void (*callback)(jdefile *));

	/** Set the compression type for the next file to be opened
		@param compression 	JDE_UNCOMPRESSED,JDE_BZIP2,JDE_NTFS_COMP,JDE_DEFAULT or JDE_GZIP
		@author ASE
	*/
	void setcompression(JDE_FILE_COMPRESSION compression);

	/**	Turn magic compression detection on.
		When a file is opened for read jdefile can try to determine if it is compressed or not.
		This is done by looking at the "magic number" at the beginning of the file.
		If the file begins with { 0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59 } it is
		opened as a bzip2 file.
		@author ASE
	*/
	void magic_on(void);
	/** Turn magic compression detection off .
		@see magic_on
		@author ASE
	*/
	void magic_off(void);
//	int error(const char *data,const char *format,...);
//	void setdetailerrorfile(jdefile *detailerrorfile);
//	void setsummaryerrorfile(jdefile *summaryerrorfile);
//	void jdefile::printerrorlegend();
//	void jdefile::summarizeerrors();

	bool opennext();

#if _USE_TAR
	void tarfile(int on);
#endif

private:

	FILE *m_curfile;
#ifdef _BZLIB_H
	BZFILE *m_BZcurfile;
#endif
#ifdef ZLIB_H
	gzFile m_gzcurfile;
#endif

#ifdef _USE_TAR
	int m_tarred;
	int tar_open_next();
	int m_tar_file_read;
	int m_tar_file_size;
#endif

	FILE *m_filelist;
	int m_safe;
	int m_max_retries;
	int m_current_retries;
	int m_compression;
	bool safe_open(const char *name);

	char m_drivestr[_MAX_DRIVE];
	char m_pathstr[_MAX_DRIVE+_MAX_DIR];
	char m_filestr[_MAX_FNAME];
	char m_extstr[_MAX_EXT];
	char m_fname[_MAX_DRIVE+_MAX
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

Those functions are not defined in the files you posted so they must be in another file or library that you need to add to the solution. Look in your 32-bit project and find out where those function are found.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.