Government Security
Network Security Resources

Jump to content

Photo

Help With Linker Problems

- - - - - windows c++
  • Please log in to reply
5 replies to this topic

#1 zlim00

zlim00

    Private

  • Members
  • 16 posts

Posted 14 January 2007 - 08:39 AM

i dont know if the code is completely bs as it is my first time trying to do something like this (i am the h4xx0r at dos games lol :lol: ).
please have patience with my coding
[codebox]
#include <windows.h>
#include <wininet.h>

int main()
{
HINTERNET hOpen, hIp, hFile, hWrite;
FILE *fp;
char file[99];
unsigned long write, bytes;

hOpen = InternetOpen("WebReader", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
hIp = InternetConnect(hOpen, "myhost.com ", INTERNET_DEFAULT_FTP_PORT, UN, PW,INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0 );
hFile = FtpOpenFile(hIp, "myfile.txt", GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0 );

fp = fopen("c:\\myfile.txt" , "r");
bytes = fseek(fp, 0, 2);
fseek(fp, 0, 2);
do
{
fread( file, bytes, sizeof( char ), fp );
InternetWriteFile(hFile, file, sizeof( char ), &write);
}while(write!=0);
return(0);
}[/codebox]
Errors:
g:\ny mapp (2)\testet1.o(.text+0x63):testet1.cpp: undefined reference to `InternetOpenA@20'
g:\ny mapp (2)\testet1.o(.text+0x8e):testet1.cpp: undefined reference to `InternetConnectA@32'
g:\ny mapp (2)\testet1.o(.text+0xad):testet1.cpp: undefined reference to `FtpOpenFileA@20'
g:\ny mapp (2)\testet1.o(.text+0x131):testet1.cpp: undefined reference to `InternetWriteFile@16'

in the project i have included windows.h, stdio.h and wininet.h. im using Devc++ 4 with the included headers and libs (windows sdk pack hs/libs get loads of errors).
help much appreciated

#2 Guest_Paul_*

Guest_Paul_*
  • Guests

Posted 14 January 2007 - 09:22 AM

1: Remove your sensitive information like server and login

2: Try to add this after the includes:
#pragma comment(lib, "Wininet.lib")
#pragma comment(lib, "ws2_32")


#3 zlim00

zlim00

    Private

  • Members
  • 16 posts

Posted 14 January 2007 - 09:59 AM

thx, ill try that

edit: doesnt work same error.
any other ideas?

#4 Guest_Paul_*

Guest_Paul_*
  • Guests

Posted 14 January 2007 - 12:21 PM

Add the libs to your project settings, i can compile the source with the pragmas fine in MS VS 2k3.NET

#5 Serhat

Serhat

    Second Lieutenant

  • Members
  • 803 posts

Posted 14 January 2007 - 01:13 PM

1: Remove your sensitive information like server and login

Done for him
And idd.. adding the libs via the project settings should work..

- Serhat

#6 zlim00

zlim00

    Private

  • Members
  • 16 posts

Posted 14 January 2007 - 02:37 PM

downloaded v.5 of dev and got it to work.
thanks for the help anyways!





Also tagged with one or more of these keywords: windows, c++