Menu

#1041 functions in winnetwk.h will not link using ld

OTHER
closed
binutils (105)
rejected
User_Error
2014-08-25
2007-05-30
Tkatseres
No

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\&gt; 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.

Discussion

  • Danny Smith

    Danny Smith - 2007-05-31

    Logged In: YES
    user_id=11494
    Originator: NO

    You did this;

    C:\WINDOWS\system32\&gt; g++ -lmpr net.cpp

    Do this instead:

    C:\WINDOWS\system32\&gt; g++ net.cpp -lmpr
    hey, cis trans boom la la search for "order matters" in FAQ

     
  • Danny Smith

    Danny Smith - 2007-05-31
    • status: open --> closed-rejected
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-25
    • labels: ld --> binutils
    • status: closed-rejected --> closed
    • resolution: --> rejected
    • category: --> User_Error
    • milestone: --> OTHER