User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 455,962 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,602 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 4581 | Replies: 5
Reply
Join Date: Aug 2004
Posts: 76
Reputation: Mahen is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Mahen Mahen is offline Offline
Junior Poster in Training

Linking Error In C

  #1  
Aug 23rd, 2004
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2004
Posts: 251
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Rep Power: 6
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: Linking Error In C

  #2  
Aug 23rd, 2004
Try linking with winsock.lib
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote  
Join Date: Aug 2004
Posts: 76
Reputation: Mahen is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Mahen Mahen is offline Offline
Junior Poster in Training

Help Re: Linking Error In C

  #3  
Aug 23rd, 2004
Originally Posted by FireNet
Try linking with winsock.lib

Is it this that you r talking about:

#pragma comment(lib, "ws2_32")

then how ????
Reply With Quote  
Join Date: Apr 2004
Posts: 3,755
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 17
Solved Threads: 147
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Linking Error In C

  #4  
Aug 23rd, 2004
Microsoft-specific pragmas need not work anywhere but with a Microsoft toolchain.
#pragma comment(lib, "ws2_32")
Originally Posted by Mahen
I use the LCC compiler and linker on windowsXP.
What does the LCC documentation say about linking to specific libraries?
Reply With Quote  
Join Date: Aug 2004
Posts: 76
Reputation: Mahen is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Mahen Mahen is offline Offline
Junior Poster in Training

Re: Linking Error In C

  #5  
Aug 24th, 2004
Originally Posted by Dave Sinkula
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.
Reply With Quote  
Join Date: Apr 2004
Posts: 3,755
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 17
Solved Threads: 147
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Linking Error In C

  #6  
Aug 24th, 2004
: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?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 8:59 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC