[mingw - Windows API] Solution discovered, but not the "why"!

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[mingw - Windows API] Solution discovered, but not the "why"!

SourceForge.net

Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=3212700
By: aedgsilva

Reading the archives I found the solution, but I didn't understand why...

If I compile and link in one command, and the source file appears before the
library name, it works!

C:\> g++ -o ftp ftp.cpp -lwininet

If the library appears before the source code, the error persists...

C:\> g++ -o ftp -lwininet ftp.cpp
ftp.o(.text+0x166):ftp.cpp: undefined reference to `InternetOpenA@20'
ftp.o(.text+0x1c3):ftp.cpp: undefined reference to `InternetConnectA@32'
ftp.o(.text+0x1f0):ftp.cpp: undefined reference to `FtpSetCurrentDirectoryA@8'
ftp.o(.text+0x232):ftp.cpp: undefined reference to `FtpPutFileA@20'
ftp.o(.text+0x254):ftp.cpp: undefined reference to `InternetCloseHandle@4'
ftp.o(.text+0x262):ftp.cpp: undefined reference to `InternetCloseHandle@4'
collect2: ld returned 1 exit status

Someone knows why? Or someone could direct me to another forum were a should
discuss this topic?

Thnaks!

--
Andre

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=286641


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: [mingw - Windows API] Solution discovered, but not the "why"!

Neil Brown-2
SourceForge.net wrote:

>If I compile and link in one command, and the source file appears before the
>library name, it works!
>
>C:\> g++ -o ftp ftp.cpp -lwininet
>
>If the library appears before the source code, the error persists...
>
>C:\> g++ -o ftp -lwininet ftp.cpp
>
>Someone knows why? Or someone could direct me to another forum were a should
>discuss this topic?
>
>  
>

I think it is because with the second (erroneous) version, g++ links the
library in (but doesn't find anything in that library that is needed),
then compiles the source, then looks at the finished executable and
finds things missing.  Whereas with the first version, it compiles
ftp.cpp, finds things are missing, but then satisfies them when it links
in wininet.  That make sense?

Neil.


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users