Sign in to follow this  
tigmon

Need help with C++

Recommended Posts

Hello everyone I am a noob to C++ but not programming in general. I'm trying to write a program that will close any FTP connection used by my game. The reason I need to do this is because there is a strict limit to the amount of open connections with my web hosts and I need to write a program that will close any FTP connection when it's no longer needed. The reason I am doing this in the first place is because I'm using this FTP DLL for my game (didn't make this dll) and it works but it has no function to close an open connection! this causes great problems for my game. reading online I hear WinInet allows me to do stuff related to FTP so I experimented but unfortunatly I'm stuck at this error. I am using Dev-C++ 4.9.9.2 When I compile the code below I get this error [Linker error] undefined reference to `InternetOpenA@20' ld returned 1 exit status C:\Dev-Cpp\FTP Ender\Makefile.win [Build Error] ["FTP] Error 1 Here is My Source =============================================================================== #include <iostream> #include <WinInet.h> using namespace std; int main() { HINSTANCE hLib = NULL; hLib = LoadLibrary("Wininet.dll"); cout << "Hello FTP!" << endl; cout << "ummm Do Something..." << endl; int b = 0; while (b != 100) { cout << "Testing..."; b++; } cout << "" << endl; cout << "" << endl; cout << "Ok I promise I'm Done With that stupid testing crap :)" << endl; cout << "The End. now close the window." << endl; // EVEYTHING BEFORE THIS WORKS JUST FINE #pragma comment (lib, "WinInet.Lib") HINTERNET hInternet = InternetOpen("TestApp",INTERNET_OPEN_TYPE_PROXY,"prxy.server.com","158.55.255.251",INTERNET_FLAG_ASYNC); // Loop Forever THIS WORKS while (b = b) { } } =============================================================================== Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
#pragma comment(lib, ...) is Micrsoft C++ specific. Are you sure it works in Dev-C++? (I don't know). If it doesn't recognize that pragma, it is supposed to just ignore it, which seems to be the case. Try linking to the WinInet.lib using Dev-C++'s built in way instead of through a pragma.

Cheers
-Scott

Share this post


Link to post
Share on other sites
Apparently adding -lWininet to your command line, or "go to Project-->Project Options or press Alt+P. Under the General tab, add the following options in the input space below Linker Options/Optional Libs or Object files: -lWininet"

Cheers
-Scott

Share this post


Link to post
Share on other sites
Hey thanks! I really appreciate it! it compiled sucessfully and opended a connection! thanks a lot!

And thanks for telling me what #pragma comment(lib, ...) does
I didn't know whaty that meant thanks again!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this