View Single Post
Old 04-23-2006, 12:53 AM   #1 (permalink)
jevaly
forum troll
 
jevaly's Avatar
 
Join Date: Apr 2006
Location: home
Posts: 1
jevaly is on a distinguished road
linker problem with wininet

I'm trying to create a function transfer that transfers a file with ftp to an external host. Code is as follows:
Code:
#include "wininet.h"
int transfer(string filenaam,int n){
	char * programmanaam="VOP";
	char * servernaam="1.2.3.4";
	char * username="anonymous";
	char * password="hallo";
	char * directory;
	if(n==1){
		directory="c:/VOP/movies";
	}
	else if(n==2){
		directory="c:/VOP/pictures";
	}
	else{
		return ONGELDIGE_KEUZE_DIRECTORY;
	}
	LPCWSTR direc=(LPCWSTR)directory;
	LPCWSTR user=(LPCWSTR)username;
	LPCWSTR pass=(LPCWSTR)password;
	LPCWSTR server=(LPCWSTR)servernaam;
	LPCWSTR pn=(LPCWSTR)programmanaam;
	LPCWSTR file=(LPCWSTR)filenaam.c_str();
	HINTERNET handle=InternetOpen(pn,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,INTERNET_FLAG_ASYNC);
	HINTERNET ftphandle=InternetConnect(handle,server,INTERNET_DEFAULT_FTP_PORT,user,pass,INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,DW_CONTEXT);
	if(FtpSetCurrentDirectory(ftphandle,direc)){
FtpPutFile(ftphandle,file,file,FTP_TRANSFER_TYPE_BINARY,DW_CONTEXT);
	}
	else{
		FtpCreateDirectory(ftphandle,direc);
		FtpSetCurrentDirectory(ftphandle,direc);
		FtpPutFile(ftphandle,file,file,FTP_TRANSFER_TYPE_BINARY,DW_CONTEXT);
	}
	InternetCloseHandle(ftphandle);
	InternetCloseHandle(handle);
	return 0;
My compiler (visual studio 2005) builds the code but keeps giving the following set of errors:
Quote:
internet.obj : error LNK2019: unresolved external symbol __imp__InternetCloseHandle@4 referenced in function "int __cdecl transfer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?transfer@@YAHV?$basic_string@DU?$char_traits@D@s td@@V?$allocator@D@2@@std@@H@Z)
internet.obj : error LNK2019: unresolved external symbol __imp__FtpCreateDirectoryW@8 referenced in function "int __cdecl transfer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?transfer@@YAHV?$basic_string@DU?$char_traits@D@s td@@V?$allocator@D@2@@std@@H@Z)
internet.obj : error LNK2019: unresolved external symbol __imp__FtpPutFileW@20 referenced in function "int __cdecl transfer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?transfer@@YAHV?$basic_string@DU?$char_traits@D@s td@@V?$allocator@D@2@@std@@H@Z)
internet.obj : error LNK2019: unresolved external symbol __imp__FtpSetCurrentDirectoryW@8 referenced in function "int __cdecl transfer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?transfer@@YAHV?$basic_string@DU?$char_traits@D@s td@@V?$allocator@D@2@@std@@H@Z)
internet.obj : error LNK2019: unresolved external symbol __imp__InternetConnectW@32 referenced in function "int __cdecl transfer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?transfer@@YAHV?$basic_string@DU?$char_traits@D@s td@@V?$allocator@D@2@@std@@H@Z)
internet.obj : error LNK2019: unresolved external symbol __imp__InternetOpenW@20 referenced in function "int __cdecl transfer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?transfer@@YAHV?$basic_string@DU?$char_traits@D@s td@@V?$allocator@D@2@@std@@H@Z)
C:\Documents and Settings\Jeroen\Mijn documenten\Visual Studio 2005\Projects\VOP\Debug\VOP.exe : fatal error LNK1120: 6 unresolved externals
at first I thought my compiler couldn't find the wininet.h file or the related binary, but when I checked I noticed this wasn't the case. Any help?
jevaly is offline   Reply With Quote