[Solved] undefined reference to `RasDialDlgW@16'

  • hi ,
    i'm trying to execute some RAS commands in Windows everything works fine in QT Creator but when i want to compile the app this error occurs :

    undefined reference to `RasDialDlgW@16'

    Headers :

    #include <windows.h>
    #include <stdio.h>
    #include <ras.h>
    #include <rasdlg.h>
    #include <tchar.h>

    here is my code :

    QString src = QCoreApplication::applicationDirPath() + "/ras.pbk";
      LPTSTR dest=(LPTSTR)src.utf16();
      LPTSTR addr=(LPTSTR)QString("").utf16();
      LPTSTR entry=(LPTSTR)QString("RasEntry").utf16();
    // LPRASDIALDLG lpInfo = (LPRASDIALDLG) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RASDIALDLG));
      RasDialDlg(dest, entry, addr, NULL);

    I'm Using QT 5.7.1 Mingw on windows 10

  • Qt Champions 2017

    You need to link whatever library provides RasDialDlgW (I'm assuming one of the windows system libs).
    As a side note, this code can't work as you're returning pointers from temporary objects, you'll get segfault in these two places:

    LPTSTR addr=(LPTSTR)QString("").utf16(); //< The pointer returned from utf16 is valid as long as the string is not modified
    LPTSTR entry=(LPTSTR)QString("RasEntry").utf16();

  • @kshegunov in msdn sample it just used these headers : ras , rasdlg , windows , tchar

  • Qt Champions 2017

    you must also link to
    Rasdlg.dll/lib ( if vs)

  • in your .pro file add
    LIBS += -lRasdlg

  • @VRonin it works , thanks

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.