OS version XP
gcc version 3.4.5
ld version ( GNU ld version 2.17.50 20060824 )
mingw version ( MinGW-5.1.3.exe )
build environment ( PATH=c:\MinGW\bin;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;
)
mingw-runtime version ( #define __MINGW32_VERSION 3.12 )
w32api version ( #define __W32API_VERSION 3.9 )
cat > net.cpp <<EOF
#include <windows.h>
#include <winnetwk.h>
#include <iostream>
#pragma comment( lib, "Mpr" )
using namespace std;
int main()
{
char *res = "\\\\THEBOX\\ADMIN$";
NETRESOURCE nr;
nr.dwType = RESOURCETYPE_DISK;
nr.lpLocalName = NULL;
nr.lpRemoteName = res;
nr.lpProvider = NULL;
char *passw = "pass", *usern = "Chris";
int ret = WNetAddConnection2(&nr, passw, usern, 0);
if (ret == NO_ERROR)
cout << "WORKS!";
WNetCancelConnection2(res, 0, true);
cin.ignore();
return 0;
}
EOF
C:\WINDOWS\system32\> g++ -lmpr net.cpp
OUTPUT
C:\DOCUME~1\katsert\LOCALS~1\Temp/ccG2baaa.o:net.cpp:(.text+0x175): undefined reference to `WNetAddConnection2A@16'
C:\DOCUME~1\katsert\LOCALS~1\Temp/ccG2baaa.o:net.cpp:(.text+0x1b0): undefined reference to `WNetCancelConnection2A@12'
collect2: ld returned 1 exit status
I've tried may things but I can not get past this linking problem.
Logged In: YES
user_id=11494
Originator: NO
You did this;
C:\WINDOWS\system32\> g++ -lmpr net.cpp
Do this instead:
C:\WINDOWS\system32\> g++ net.cpp -lmpr
hey, cis trans boom la la search for "order matters" in FAQ