954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Linking Error In C

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
#include
#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.

Mahen
Junior Poster
144 posts since Aug 2004
Reputation Points: 10
Solved Threads: 2
 

Try linking with winsock.lib

FireNet
Posting Whiz in Training
258 posts since May 2004
Reputation Points: 108
Solved Threads: 7
 
Try linking with winsock.lib

Is it this that you r talking about:

#pragma comment(lib, "ws2_32") :?:

then how ????

Mahen
Junior Poster
144 posts since Aug 2004
Reputation Points: 10
Solved Threads: 2
 

Microsoft-specific pragmas need not work anywhere but with a Microsoft toolchain.

#pragma comment(lib, "ws2_32")
I use the LCC compiler and linker on windowsXP.

What does the LCC documentation say about linking to specific libraries?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

Microsoft-specific pragmas need not work anywhere but with a Microsoft toolchain.

#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.

Mahen
Junior Poster
144 posts since Aug 2004
Reputation Points: 10
Solved Threads: 2
 

: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.

[img]http://img33.exs.cx/img33/672/Wedit.jpg[/img]Additional libraries. Here you put a series of libraries you may need separated by spaces.
Have you added winsock in this way?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You