Trouble linking

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

Trouble linking

James Rome
I am working inside of NetBeans 6.9 RC1 in Win7 64-bits.

Although everything compiles correctly, linking to the mingw routines
referenced in winsock2.h seems to fail. What am I doing wrong?

Thanks for the help,
Jim

gcc.exe     -shared -o dist/Debug_MinGW/MinGW-Windows/libGraphiC2dll.dll
build/Debug_MinGW/MinGW-Windows/_ext/1360937237/curves.o
build/Debug_MinGW/MinGW-Windows/_ext/1360937237/axesdraw.o
build/Debug_MinGW/MinGW-Windows/_ext/1360937237/ttdisk.o
. . .
build/Debug_MinGW/MinGW-Windows/_ext/1360937237/baux.o: In function `ciq':
C:/Users/jar/GraphiC2/GraphiC2dll/../src/baux.c:58: undefined reference
to `select@20'
build/Debug_MinGW/MinGW-Windows/_ext/1360937237/tkfPush.o: In function
`tkfpush':
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:161: undefined
reference to `WSAStartup@8'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:170: undefined
reference to `socket@12'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:173: undefined
reference to `WSAGetLastError@0'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:174: undefined
reference to `WSACleanup@0'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:183: undefined
reference to `inet_addr@4'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:184: undefined
reference to `htons@4'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:196: undefined
reference to `connect@12'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:205: undefined
reference to `WSACleanup@0'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:213: undefined
reference to `send@16'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:214: undefined
reference to `send@16'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:216: undefined
reference to `send@16'
build/Debug_MinGW/MinGW-Windows/_ext/1360937237/tkfPush.o: In function
`getFirstFreePort':
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:273: undefined
reference to `WSAStartup@8'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:282: undefined
reference to `socket@12'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:285: undefined
reference to `WSAGetLastError@0'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:286: undefined
reference to `WSACleanup@0'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:291: undefined
reference to `inet_addr@4'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:296: undefined
reference to `htons@4'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:298: undefined
reference to `bind@12'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:304: undefined
reference to `closesocket@4'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:305: undefined
reference to `WSACleanup@0'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:310: undefined
reference to `closesocket@4'
C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:311: undefined
reference to `WSACleanup@0make[2]: Leaving directory
`/c/Users/jar/GraphiC2/GraphiC2dll'
make[1]: Leaving directory `/c/Users/jar/GraphiC2/GraphiC2dll'
'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug_MinGW/MinGW-Windows/libGraphiC2dll.dll] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

------------------------------------------------------------------------------

_______________________________________________
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: Trouble linking

Tor Lillqvist
> Although everything compiles correctly, linking to the mingw routines
> referenced in winsock2.h seems to fail.

There is nothing "mingw" about those functions; they are Microsoft
ones, the Winsock API.

> What am I doing wrong?

You need to link with -lws2_32.

--tml

------------------------------------------------------------------------------

_______________________________________________
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: Trouble linking

Greg Chicares
In reply to this post by James Rome
On 2010-06-01 16:32Z, James Rome wrote:
>
> gcc.exe     -shared -o dist/Debug_MinGW/MinGW-Windows/libGraphiC2dll.dll
> build/Debug_MinGW/MinGW-Windows/_ext/1360937237/curves.o
[...]
> build/Debug_MinGW/MinGW-Windows/_ext/1360937237/baux.o: In function `ciq':
> C:/Users/jar/GraphiC2/GraphiC2dll/../src/baux.c:58: undefined reference to `select@20'
> build/Debug_MinGW/MinGW-Windows/_ext/1360937237/tkfPush.o: In function `tkfpush':
> C:/Users/jar/GraphiC2/GraphiC2dll/../src/tkfPush.c:161: undefined reference to `WSAStartup@8'

Specify the sockets library on the linker command line after
the object files that refer to it. It's not linked by default.

------------------------------------------------------------------------------

_______________________________________________
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