Linking into dll

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

Linking into dll

Hehl, Thomas

It’s been a few years since I worked in C, but I needed to create a DLL for a java project I’m working on and writing it in C seemed to be the way to go.

 

I’m following the directions from: http://www.adp-gmbh.ch/win/misc/mingw/dll.html which led me to find MinGW.

 

I think I’m ready to go here, but when I run the build I get told:

 

C:\DOCUME~1\40860205\LOCALS~1\Temp\ccLfKDsB.o:agile-api-interface.c:(.text+0x1f): undefined reference to `WSAStartup@8'

C:\DOCUME~1\40860205\LOCALS~1\Temp\ccLfKDsB.o:agile-api-interface.c:(.text+0x3e): undefined reference to `socket@12'

(repeats a few times.)

 

If I look at winsock2.h provided by MinGW I find:

 

WINSOCK_API_LINKAGE int PASCAL WSAStartup(WORD,LPWSADATA);

 

So, I think, I need to include the library from MinGW on my build. So I run the command:

 

C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lC:\MinGW\lib\libwsock32.a agile-api-interface.c -o agileapi.dll

 

Which returns me:

 

c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\MinGW\lib\libwsock32.a

collect2: ld returned 1 exit status

 

I’ve now run out of c knowledge and need further assistance. Please help?

 

Thanks.


------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Tor Lillqvist
C knowledge has little to do with this. Try adding -lws2_32 at the
*end* of your FCC command line.

--tml

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Hehl, Thomas
Thanks for the assist!

This appears to have fixed that problem. Now I'm back to the original
reason why I included the library in the first place.

C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lws2_32
agile-api-int
rface.c -o agileapi.dll
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x1f
: undefined reference to `WSAStartup@8'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x3e
: undefined reference to `socket@12'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x6b
: undefined reference to `htons@4'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x80
: undefined reference to `gethostbyname@4'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0xc3
: undefined reference to `connect@12'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x28
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x2a
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x2d
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x2f
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x32
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x37
): more undefined references to `send@16' follow
C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
xt+0x54
): undefined reference to `recv@16'
collect2: ld returned 1 exit status

If I'm linking in winsock, why do these errors persist?


-----Original Message-----
From: Tor Lillqvist [mailto:[hidden email]]
Sent: Wednesday, November 10, 2010 3:48 PM
To: MinGW Users List
Subject: Re: [Mingw-users] Linking into dll

C knowledge has little to do with this. Try adding -lws2_32 at the
*end* of your FCC command line.

--tml

------------------------------------------------------------------------
------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list
etiquette may cause your account to be moderated.

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

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

d3x0r
-lwsock32
ws2_32  is for other extended functions...

On Wed, Nov 10, 2010 at 1:03 PM, Hehl, Thomas <[hidden email]> wrote:

> Thanks for the assist!
>
> This appears to have fixed that problem. Now I'm back to the original
> reason why I included the library in the first place.
>
> C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lws2_32
> agile-api-int
> rface.c -o agileapi.dll
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x1f
> : undefined reference to `WSAStartup@8'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x3e
> : undefined reference to `socket@12'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x6b
> : undefined reference to `htons@4'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x80
> : undefined reference to `gethostbyname@4'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0xc3
> : undefined reference to `connect@12'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x28
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x2a
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x2d
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x2f
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x32
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x37
> ): more undefined references to `send@16' follow
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x54
> ): undefined reference to `recv@16'
> collect2: ld returned 1 exit status
>
> If I'm linking in winsock, why do these errors persist?
>
>
> -----Original Message-----
> From: Tor Lillqvist [mailto:[hidden email]]
> Sent: Wednesday, November 10, 2010 3:48 PM
> To: MinGW Users List
> Subject: Re: [Mingw-users] Linking into dll
>
> C knowledge has little to do with this. Try adding -lws2_32 at the
> *end* of your FCC command line.
>
> --tml
>
> ------------------------------------------------------------------------
> ------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list
> etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Tor Lillqvist
In reply to this post by Hehl, Thomas
I said at the *end*. The order of arguments on the gcc command line
does matter. (On Windows.)

--tml

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Keith Marshall
On Wednesday 10 November 2010 21:31:51 Tor Lillqvist wrote:
> I said at the *end*. The order of arguments on the gcc command line
> does matter. (On Windows.)

On Linux (and just about every other *nix) too!  The Linux ELF linker
may be forgiving of the incorrect order, when linking with a shared
library, (but it's still an error not caught); it will punish you just
as severely as the Windows PE linker, if you misplace a static library
reference.

--
Regards,
Keith.

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Hehl, Thomas
In reply to this post by d3x0r
Doesn't appear to be any change. I tried them both just to see. Here's the output:

C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lwsock32 -lws2_32 agil
e-api-interface.c -o agileapi.dll
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x1f)
: undefined reference to `WSAStartup@8'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x3e)
: undefined reference to `socket@12'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x6b)
: undefined reference to `htons@4'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x80)
: undefined reference to `gethostbyname@4'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0xc3)
: undefined reference to `connect@12'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x288
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x2ae
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x2d4
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x2fa
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x320
): undefined reference to `send@16'
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x37c
): more undefined references to `send@16' follow
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x54f
): undefined reference to `recv@16'
collect2: ld returned 1 exit status

C:\workspace\agile\agile-api-interface>

-----Original Message-----
From: J Decker [mailto:[hidden email]]
Sent: Wednesday, November 10, 2010 4:28 PM
To: MinGW Users List
Subject: Re: [Mingw-users] Linking into dll

-lwsock32
ws2_32  is for other extended functions...

On Wed, Nov 10, 2010 at 1:03 PM, Hehl, Thomas <[hidden email]> wrote:

> Thanks for the assist!
>
> This appears to have fixed that problem. Now I'm back to the original
> reason why I included the library in the first place.
>
> C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lws2_32
> agile-api-int
> rface.c -o agileapi.dll
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x1f
> : undefined reference to `WSAStartup@8'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x3e
> : undefined reference to `socket@12'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x6b
> : undefined reference to `htons@4'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x80
> : undefined reference to `gethostbyname@4'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0xc3
> : undefined reference to `connect@12'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x28
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x2a
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x2d
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x2f
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x32
> ): undefined reference to `send@16'
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x37
> ): more undefined references to `send@16' follow
> C:\DOCUME~1\40860205\LOCALS~1\Temp\cc2Xj9LV.o:agile-api-interface.c:(.te
> xt+0x54
> ): undefined reference to `recv@16'
> collect2: ld returned 1 exit status
>
> If I'm linking in winsock, why do these errors persist?
>
>
> -----Original Message-----
> From: Tor Lillqvist [mailto:[hidden email]]
> Sent: Wednesday, November 10, 2010 3:48 PM
> To: MinGW Users List
> Subject: Re: [Mingw-users] Linking into dll
>
> C knowledge has little to do with this. Try adding -lws2_32 at the
> *end* of your FCC command line.
>
> --tml
>
> ------------------------------------------------------------------------
> ------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list
> etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

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

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Keith Marshall
On 11 November 2010 12:28, Hehl, Thomas <[hidden email]> wrote:
> Doesn't appear to be any change. I tried them both just to see. Here's the output:
>
> C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lwsock32 -lws2_32 agil
> e-api-interface.c -o agileapi.dll
> C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.text+0x1f)
> : undefined reference to `WSAStartup@8'
> ...

You've still got the order completely wrong!  When Tor said "libraries must come
at the end", he meant exactly that; you haven't put them there!  As
you've ordered
it, the linker scans libwsock32.a and libws2_32.a (in that order),
*before* it has
seen your agile-api-interface.o, so it doesn't yet know it needs anything from
them, thinks it doesn't and discards them as unnecessary.  It then scans your
object file, sees the references, but no longer has a viable library
from which to
resolve them, (it has already discarded them, remember); thus, the references
remain unresolved.

You *must* specify libraries *after* the objects which require them, (and in the
correct relative order, if one library requires another).  Thus:

$ gcc -Wall -shared -o agileapi.dll agile-api-interface.c -lws2_32

is what you require; (it is unlikely that you need both -lws2_32 and -lwsock32).

--
Regards,
Keith.

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Hehl, Thomas
Sorry, I missed that part of his note. This seems to have corrected the
issue.

Thanks for the help!

-----Original Message-----
From: Keith Marshall [mailto:[hidden email]]
Sent: Thursday, November 11, 2010 8:11 AM
To: MinGW Users List
Subject: Re: [Mingw-users] Linking into dll

On 11 November 2010 12:28, Hehl, Thomas <[hidden email]> wrote:
> Doesn't appear to be any change. I tried them both just to see. Here's
the output:
>
> C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lwsock32
-lws2_32 agil
> e-api-interface.c -o agileapi.dll
>
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.te
xt+0x1f)
> : undefined reference to `WSAStartup@8'
> ...

You've still got the order completely wrong!  When Tor said "libraries
must come
at the end", he meant exactly that; you haven't put them there!  As
you've ordered
it, the linker scans libwsock32.a and libws2_32.a (in that order),
*before* it has
seen your agile-api-interface.o, so it doesn't yet know it needs
anything from
them, thinks it doesn't and discards them as unnecessary.  It then scans
your
object file, sees the references, but no longer has a viable library
from which to
resolve them, (it has already discarded them, remember); thus, the
references
remain unresolved.

You *must* specify libraries *after* the objects which require them,
(and in the
correct relative order, if one library requires another).  Thus:

$ gcc -Wall -shared -o agileapi.dll agile-api-interface.c -lws2_32

is what you require; (it is unlikely that you need both -lws2_32 and
-lwsock32).

--
Regards,
Keith.

------------------------------------------------------------------------
------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list
etiquette may cause your account to be moderated.

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

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

Hehl, Thomas
In reply to this post by Keith Marshall
OK, two questions now.

1) how do I know that I'm supposed to use wsock32 to suck in those
libraries? Where' is this stuff mapped so that I know when I need
functionality a I use this library name

2) How do I put this into my c build for eclipse? It appears to only
take files or pre-defined variables. I can't figure out how to define
wsock32 in there so it will use it at build time.

Thanks.

-----Original Message-----
From: Keith Marshall [mailto:[hidden email]]
Sent: Thursday, November 11, 2010 8:11 AM
To: MinGW Users List
Subject: Re: [Mingw-users] Linking into dll

On 11 November 2010 12:28, Hehl, Thomas <[hidden email]> wrote:
> Doesn't appear to be any change. I tried them both just to see. Here's
the output:
>
> C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lwsock32
-lws2_32 agil
> e-api-interface.c -o agileapi.dll
>
C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.te
xt+0x1f)
> : undefined reference to `WSAStartup@8'
> ...

You've still got the order completely wrong!  When Tor said "libraries
must come
at the end", he meant exactly that; you haven't put them there!  As
you've ordered
it, the linker scans libwsock32.a and libws2_32.a (in that order),
*before* it has
seen your agile-api-interface.o, so it doesn't yet know it needs
anything from
them, thinks it doesn't and discards them as unnecessary.  It then scans
your
object file, sees the references, but no longer has a viable library
from which to
resolve them, (it has already discarded them, remember); thus, the
references
remain unresolved.

You *must* specify libraries *after* the objects which require them,
(and in the
correct relative order, if one library requires another).  Thus:

$ gcc -Wall -shared -o agileapi.dll agile-api-interface.c -lws2_32

is what you require; (it is unlikely that you need both -lws2_32 and
-lwsock32).

--
Regards,
Keith.

------------------------------------------------------------------------
------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list
etiquette may cause your account to be moderated.

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

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
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: Linking into dll

d3x0r
on MSDN documentation at the bottom it usually references what header
defines it, and what library it is in, take the base name of the
library and use it for gcc.

Oh and I guess wsock32 is redundant might just be ws2_32.

On Thu, Nov 11, 2010 at 6:35 AM, Hehl, Thomas <[hidden email]> wrote:

> OK, two questions now.
>
> 1) how do I know that I'm supposed to use wsock32 to suck in those
> libraries? Where' is this stuff mapped so that I know when I need
> functionality a I use this library name
>
> 2) How do I put this into my c build for eclipse? It appears to only
> take files or pre-defined variables. I can't figure out how to define
> wsock32 in there so it will use it at build time.
>
> Thanks.
>
> -----Original Message-----
> From: Keith Marshall [mailto:[hidden email]]
> Sent: Thursday, November 11, 2010 8:11 AM
> To: MinGW Users List
> Subject: Re: [Mingw-users] Linking into dll
>
> On 11 November 2010 12:28, Hehl, Thomas <[hidden email]> wrote:
>> Doesn't appear to be any change. I tried them both just to see. Here's
> the output:
>>
>> C:\workspace\agile\agile-api-interface>gcc -Wall -shared -lwsock32
> -lws2_32 agil
>> e-api-interface.c -o agileapi.dll
>>
> C:\DOCUME~1\40860205\LOCALS~1\Temp\ccRsm8L7.o:agile-api-interface.c:(.te
> xt+0x1f)
>> : undefined reference to `WSAStartup@8'
>> ...
>
> You've still got the order completely wrong!  When Tor said "libraries
> must come
> at the end", he meant exactly that; you haven't put them there!  As
> you've ordered
> it, the linker scans libwsock32.a and libws2_32.a (in that order),
> *before* it has
> seen your agile-api-interface.o, so it doesn't yet know it needs
> anything from
> them, thinks it doesn't and discards them as unnecessary.  It then scans
> your
> object file, sees the references, but no longer has a viable library
> from which to
> resolve them, (it has already discarded them, remember); thus, the
> references
> remain unresolved.
>
> You *must* specify libraries *after* the objects which require them,
> (and in the
> correct relative order, if one library requires another).  Thus:
>
> $ gcc -Wall -shared -o agileapi.dll agile-api-interface.c -lws2_32
>
> is what you require; (it is unlikely that you need both -lws2_32 and
> -lwsock32).
>
> --
> Regards,
> Keith.
>
> ------------------------------------------------------------------------
> ------
> Centralized Desktop Delivery: Dell and VMware Reference Architecture
> Simplifying enterprise desktop deployment and management using
> Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
> client virtualization framework. Read more!
> http://p.sf.net/sfu/dell-eql-dev2dev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list
> etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
> ------------------------------------------------------------------------------
> Centralized Desktop Delivery: Dell and VMware Reference Architecture
> Simplifying enterprise desktop deployment and management using
> Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
> client virtualization framework. Read more!
> http://p.sf.net/sfu/dell-eql-dev2dev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

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