943,915 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 8952
  • C RSS
Aug 23rd, 2004
0

Linking Error In C

Expand Post »
Hi everyone,
First of all thank you very much for all the help that you have been providing me. Unfortunately, i am with another bug. This time, i am havinh problems linking OBJ files that uses the following:

#include <stdio.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32")

When i link them, i get the following errors:

C:\lcc\bin>lcclnk wgate.obj
wgate.obj .text: undefined reference to '_socket@12'
wgate.obj .text: undefined reference to '_send@16'
wgate.obj .text: undefined reference to '_recv@16'
wgate.obj .text: undefined reference to '_WSAGetLastError@0'
wgate.obj .text: undefined reference to '_htons@4'
wgate.obj .text: undefined reference to '_inet_addr@4'
wgate.obj .text: undefined reference to '_gethostbyname@4'
wgate.obj .text: undefined reference to '_connect@12'
wgate.obj .text: undefined reference to '_WSAStartup@8'
wgate.obj .text: undefined reference to '_WSACleanup@0'

N.B: I use the LCC compiler and linker on windowsXP.
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster
Mahen is offline Offline
144 posts
since Aug 2004
Aug 23rd, 2004
0

Re: Linking Error In C

Try linking with winsock.lib
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004
Aug 23rd, 2004
0

Re: Linking Error In C

Quote originally posted by FireNet ...
Try linking with winsock.lib
Is it this that you r talking about:

#pragma comment(lib, "ws2_32")

then how ????
Reputation Points: 10
Solved Threads: 2
Junior Poster
Mahen is offline Offline
144 posts
since Aug 2004
Aug 23rd, 2004
0

Re: Linking Error In C

Microsoft-specific pragmas need not work anywhere but with a Microsoft toolchain.
  1. #pragma comment(lib, "ws2_32")
Quote originally posted by Mahen ...
I use the LCC compiler and linker on windowsXP.
What does the LCC documentation say about linking to specific libraries?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Aug 24th, 2004
0

Re: Linking Error In C

Quote originally posted by Dave Sinkula ...
Microsoft-specific pragmas need not work anywhere but with a Microsoft toolchain.
  1. #pragma comment(lib, "ws2_32")
What does the LCC documentation say about linking to specific libraries?
This is what the LCC help file says:

Libraries Distributed with lcc-win32
These libraries are distributed in the form of ASCII description files « .exp ». These files will be transformed by the installation program into libraries in lcc-win32 format. This is a different format than the format used by Microsoft, so the libraries generated are NOT compatible with Microsoft or other compilers.

To see the contents of each library, look at the corresponding .exp file in the \lcc\buildlib directory.
Reputation Points: 10
Solved Threads: 2
Junior Poster
Mahen is offline Offline
144 posts
since Aug 2004
Aug 24th, 2004
0

Re: Linking Error In C

:rolleyes:

Okay, I Googled and found a reference page. There was documentation there. In it, under the confusing heading of "Configuring the linker", was this.

  • Additional libraries. Here you put a series of libraries you may need separated by spaces.
Have you added winsock in this way?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: passing arrays,reference and value parameters
Next Thread in C Forum Timeline: Socket programming + porting Unix to Win32





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC