I read all of Microsoft's documentation but their claim is that it should work without any additional libs. An hour of Googling yielded no results. My code:
#include <windows.h>
#include <ras.h>
int main()
{
char* szPhoneNumberToDial = "127.0.0.1";
char* szUserName = "test";
char* szPassword = "test";
RASDIALPARAMS rdParams;
rdParams.dwSize = sizeof(RASDIALPARAMS);
rdParams.szEntryName[0] = '\0';
lstrcpy(rdParams.szPhoneNumber, szPhoneNumberToDial);
rdParams.szCallbackNumber[0] = '\0';
lstrcpy( rdParams.szUserName, szUserName );
lstrcpy( rdParams.szPassword, szPassword );
rdParams.szDomain[0] = '\0';
HRASCONN hRasConn = NULL;
DWORD dwRet = RasDial(NULL, NULL, &rdParams, 0L, NULL, &hRasConn);
}
Error:
undefined reference to 'RasDialA@24'
I tried both a C and C++ implementation (in both VC++ 2010 and MinGW/gcc & g++) but they both resulted in this same error.
Any ideas?
according documentation
, the requirements to RasDial()
usage, also Ras.h
header, is the Rasapi32.lib
library. If this is avaliable on your compiler, pass it to link by using -l
option on
gcc:
gcc foo.c -lRasapi32
EDIT: Thanks to @Mark Wilkins, that has provided the command-line for
Microsoft Compiler:
cl foo.c rasapi32.lib