Connecting Tech Pros Worldwide Forums | Help | Site Map

how to link libws2_32.a?

Newbie
 
Join Date: Jul 2007
Posts: 12
#1: Sep 22 '07
Hi,

I have a problem to compile my socket program.
I want to use winsock.h.
I need link libws2_32.a (for dev-c++) .
I found a libws2_32.a file and link it, but i have a next error:
....
gcc: c:\documents and settings\ervin\asztal\programming tcp sockets for the beginner\source code\dev-c++\chat1.rc: linker input file unused since linking not done
gcc: libws2_32.a: linker input file unused since linking not done
....


What can I do ?
Please let me know.

Thanks,

Takeshi Honda

ruskalym's Avatar
Member
 
Join Date: Sep 2007
Posts: 65
#2: Sep 22 '07

re: how to link libws2_32.a?


Quote:

Originally Posted by kiberg

gcc: c:\documents and settings\ervin\asztal\programming tcp sockets for the beginner\source code\dev-c++\chat1.rc: linker input file unused since linking not done
gcc: libws2_32.a: linker input file unused since linking not done
....

Hi, the message you get is a GCC warning.
Linking is done at the linking step, this message usually appears when you specify linking flags at compiling : gcc -c johndoe.c -o johndoe.o -Lpath/to/mylibrary -lmylibrary.
These -L and -l flags have no sense there, they should be used when building the target binary : gcc johndoe.o otherfile.o -o mybinary -L... -l...
or passed to ld if you call it manually.
Newbie
 
Join Date: Jul 2007
Posts: 12
#3: Sep 23 '07

re: how to link libws2_32.a?


Thanks,
I linking folowing files:
libws2_32.a Chat1.cpp Chat1.rc Chat1.h

but is a new error:

gcc: Compilation of header file requested

This error show when I linking chat1.h..But if I don't linking it then showing following errors:

gcc: libws2_32.a: linker input file unused since linking not done
gcc: Chat1.rc: linker input file unused since linking not done


Please help me!
ruskalym's Avatar
Member
 
Join Date: Sep 2007
Posts: 65
#4: Sep 23 '07

re: how to link libws2_32.a?


Please tell me the full command you're using when running GCC.
Newbie
 
Join Date: Jul 2007
Posts: 12
#5: Sep 23 '07

re: how to link libws2_32.a?


I only wrote file names...
So, dev c++ -> options -> copiler options -> Add the following comands when calling copiler, and I write following:
libws2_32.a Chat1.cpp Chat1.rc Chat1.h

I dont write commands....
I probaly following:
gcc -a libws2_32.a -cpp Chat1.cpp -rc Chat1.rc -h Chat1.h

But I get following errors:
gcc: gcc: No such file or directory
gcc: unrecognized option `-cpp'
gcc: unrecognized option `-rc'
gcc: unrecognized option `-h'
gcc: Compilation of header file requested

I dont understand it.:S
Newbie
 
Join Date: Jul 2007
Posts: 12
#6: Sep 23 '07

re: how to link libws2_32.a?


and if I write following:
gcc -c libws2_32.a -c Chat1.cpp -c Chat1.rc -c Chat1.h

Then retry only is a error:
gcc: Compilation of header file requested...........
ruskalym's Avatar
Member
 
Join Date: Sep 2007
Posts: 65
#7: Sep 23 '07

re: how to link libws2_32.a?


Try this :

gcc Chat1.cpp Chat1.rc -o Chat1.exe -L/path/to/library/if/not/in/same/directory -lws2_32
ruskalym's Avatar
Member
 
Join Date: Sep 2007
Posts: 65
#8: Sep 23 '07

re: how to link libws2_32.a?


If this doesn't work, try adding option -mwindows
Newbie
 
Join Date: Jul 2007
Posts: 12
#9: Sep 26 '07

re: how to link libws2_32.a?


Copiler and linker output:

C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `WinMain@16'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `GetTextandAddLine(char *, HWND__ *, int)':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:38: multiple definition of `GetTextandAddLine(char *, HWND__ *, int)'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:38: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `DlgProc(HWND__ *, unsigned int, unsigned int, long)':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:48: multiple definition of `DlgProc__FP6HWND__UiUil@16'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:48: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `ConnectDlgProc(HWND__ *, unsigned int, unsigned int, long)':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:190: multiple definition of `ConnectDlgProc__FP6HWND__UiUil@16'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:190: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `ListenDlgProc(HWND__ *, unsigned int, unsigned int, long)':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:249: multiple definition of `ListenDlgProc__FP6HWND__UiUil@16'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:249: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `ListenOnPort(int)':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:329: multiple definition of `ListenOnPort(int)'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:329: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `TryConnect(long, int)':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:289: multiple definition of `TryConnect(long, int)'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:289: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `Title'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:30: multiple definition of `hInst'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:30: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:33: multiple definition of `fromlen'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:33: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `hwnd'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:29: multiple definition of `hStatus'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:29: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:30: multiple definition of `s'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:30: first defined here
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccUfdaaa.o: In function `WinMain':
//C/Documents and Settings/ervin/Asztal/Programming TCP Sockets for the Beginner/Source Code/Dev-C++/Chat1.cpp:30: multiple definition of `from'
C:\DOCUME~1\ervin\LOCALS~1\Temp\ccYtcaaa.o://c/docume~1/ervin/asztal/progra~1/source~1/dev-c_~1/chat1.cpp:30: first defined here

Why don't work?
Newbie
 
Join Date: Jun 2009
Posts: 1
#10: Jun 18 '09

re: how to link libws2_32.a?


Quote:

Originally Posted by kiberg View Post

Hi,

I have a problem to compile my socket program.
I want to use winsock.h.
I need link libws2_32.a (for dev-c++) .
I found a libws2_32.a file and link it, but i have a next error:
....
gcc: c:\documents and settings\ervin\asztal\programming tcp sockets for the beginner\source code\dev-c++\chat1.rc: linker input file unused since linking not done
gcc: libws2_32.a: linker input file unused since linking not done
....


What can I do ?
Please let me know.

Thanks,

Takeshi Honda






Hi Takeshi Honda,

I am a beginner in programming. Can u kindly instruct me on how to link libws2_32.a to the project?

Thank you in advance.

Cheers
Siow
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 831
#11: Jun 18 '09

re: how to link libws2_32.a?


Quote:

Originally Posted by kiberg View Post

and if I write following:
gcc -c libws2_32.a -c Chat1.cpp -c Chat1.rc -c Chat1.h

Then retry only is a error:
gcc: Compilation of header file requested...........

The -c switch means compile or assemble the following file, but do not link. You definitely don't want to compile libsw2_32.a or Chat1.h. Personally, I typically use the -c switch when I'm using individual gcc invocations to compile each source file. You don't need it when you specify all of the source files on a single line.

I'm not familiar with the .rc suffix, what kind of file is Chat1.rc?
Needs Regular Fix
 
Join Date: Jul 2008
Posts: 383
#12: Jun 19 '09

re: how to link libws2_32.a?


That message is 2 years old btw.
Reply