Thread: [Dev-C++] Trouble compiling winsock programs.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Manoj S. <sha...@ro...> - 2002-12-29 19:14:03
|
Hi, I am trying to compile a simple winsock program using Dev-C++ and get the following error [Linker error] undefined reference to WSAStartup@8. I tried generating my own libwsock32.a library using the wsock32.dll on my system with the help of the dllwrap utility and linking it to my program by copying the generated .a file to the lib directory but the error stayed the same. I also tried using an older version of wsock32.dll (since I have the latest version of the dll) and it may not be compatible with the header files as supplied by Dev-C++. But this gave me the same undefined reference error. As a last resort I tried using the header files supplied by the Microsoft SDK instead of the include directory header files as supplied by Dev-C++. I get a target architecture must be defined error. An attempt to #define _M_IX86 which is the macro that needs to be defined leads to further errors, so I would prefer not to go down that path further. Can anyone suggest what else can be done to get a very simple winsock program to work. I have the XP OS on a Pentium machine. Regards, Manoj. http://manoj_sharma0.tripod.com |
|
From: Abhijit S. <mu...@gm...> - 2002-12-29 20:00:10
|
Greets, Manoj. > I am trying to compile a simple winsock program using Dev-C++ and get the > following error > [Linker error] undefined reference to WSAStartup@8. I tried generating my > own libwsock32.a library using the wsock32.dll on my system with the help > of the dllwrap utility and linking it to my program by copying the generated > .a file to the lib directory but the error stayed the same. Just because a file is present in the `lib' directory, doesn't mean that it'll be linked in. You need to add it to your the list of libraries the linker must add. Add `-lwsock32' to the linker command-line. Any lib by the name `libfoo.a' in the `lib' directory has to/can be linked in using -lfoo. HTH. ___________________________________________________________ Abhijit Shylanath E-mail: mu...@gm... || ibr...@bi... Web-site: http://mudeth.tripod.com/ |
|
From: Manoj S. <sha...@ro...> - 2002-12-30 00:13:44
|
Hi, Thanks for your prompt responses! I should have mentioned in my earlier that I did try adding the -lwsock32 option to the linker command line.I tried it once again though and the result was the same as before.The undefined reference error to WSAStartup error still shows up. Also I would like to run this a stand alone file (not a project). Any suggestions? Thanks in advance once again for your help. Regards, Manoj. http://manoj_sharma0.tripod.com -----Original Message----- From: Abhijit Shylanath [mailto:mu...@gm...] Sent: Sunday, December 29, 2002 2:57 PM To: Manoj Sharma; Dev-C++ Subject: Re: [Dev-C++] Trouble compiling winsock programs. Greets, Manoj. > I am trying to compile a simple winsock program using Dev-C++ and get the > following error > [Linker error] undefined reference to WSAStartup@8. I tried generating my > own libwsock32.a library using the wsock32.dll on my system with the help > of the dllwrap utility and linking it to my program by copying the generated > .a file to the lib directory but the error stayed the same. Just because a file is present in the `lib' directory, doesn't mean that it'll be linked in. You need to add it to your the list of libraries the linker must add. Add `-lwsock32' to the linker command-line. Any lib by the name `libfoo.a' in the `lib' directory has to/can be linked in using -lfoo. HTH. ___________________________________________________________ Abhijit Shylanath E-mail: mu...@gm... || ibr...@bi... Web-site: http://mudeth.tripod.com/ |
|
From: Charles K. <ch...@ke...> - 2002-12-30 00:27:46
|
In the linker options, where one adds libraries, I have this: C:/Dev-Cpp/lib/libws2_32.a for my winsock2 projects ----- Original Message ----- From: "Manoj Sharma" <sha...@ro...> To: "Dev-C++" <dev...@li...> Sent: Sunday, December 29, 2002 7:13 PM Subject: RE: [Dev-C++] Trouble compiling winsock programs. > Hi, > > Thanks for your prompt responses! > > I should have mentioned in my earlier that I did try adding the -lwsock32 > option to the linker command line.I tried it once again though and the > result was the same as before.The undefined reference error to WSAStartup > error still shows up. > > Also I would like to run this a stand alone file (not a project). Any > suggestions? > Thanks in advance once again for your help. > > Regards, > Manoj. > http://manoj_sharma0.tripod.com > > > -----Original Message----- > From: Abhijit Shylanath [mailto:mu...@gm...] > Sent: Sunday, December 29, 2002 2:57 PM > To: Manoj Sharma; Dev-C++ > Subject: Re: [Dev-C++] Trouble compiling winsock programs. > > > Greets, Manoj. > > > I am trying to compile a simple winsock program using Dev-C++ and get the > > following error > > [Linker error] undefined reference to WSAStartup@8. I tried generating my > > own libwsock32.a library using the wsock32.dll on my system with the > help > > of the dllwrap utility and linking it to my program by copying the > generated > > .a file to the lib directory but the error stayed the same. > > Just because a file is present in the `lib' directory, doesn't mean that > it'll be linked in. You need to add it to your the list of libraries the > linker must add. Add `-lwsock32' to the linker command-line. Any lib by the > name `libfoo.a' in the `lib' directory has to/can be linked in using -lfoo. > > HTH. > > ___________________________________________________________ > > Abhijit Shylanath > > E-mail: mu...@gm... || ibr...@bi... > Web-site: http://mudeth.tripod.com/ > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > |
|
From: Abhijit S. <mu...@gm...> - 2002-12-30 10:49:51
|
> Hi, > > Thanks for your prompt responses! > > I should have mentioned in my earlier that I did try adding the -lwsock32 > option to the linker command line.I tried it once again though and the > result was the same as before.The undefined reference error to WSAStartup > error still shows up. Try linking in the WinSock2 lib, as Charles mentioned. > Also I would like to run this a stand alone file (not a project). Any > suggestions? For this, you might want to use the command-line/make, or else, specify in compiler options that you want the WinSock lib to be linked with all your programs. Remove it once you're done with this project. Bit of a hassle. Command-line would be better. ___________________________________________________________ Abhijit Shylanath E-mail: mu...@gm... || ibr...@bi... Web-site: http://mudeth.tripod.com/ |
|
From: Manoj S. <sha...@ro...> - 2002-12-30 17:03:47
|
That did the trick! Adding -lws2_32 to my command line is just what the doctor ordered. Thanks a lot for your help guys! It is greatly appreciated. Regards, Manoj. http://manoj_sharma0.tripod.com -----Original Message----- From: Abhijit Shylanath [mailto:mu...@gm...] Sent: Monday, December 30, 2002 5:49 AM To: Manoj Sharma; Dev-C++ Subject: Re: [Dev-C++] Trouble compiling winsock programs. > Hi, > > Thanks for your prompt responses! > > I should have mentioned in my earlier that I did try adding the -lwsock32 > option to the linker command line.I tried it once again though and the > result was the same as before.The undefined reference error to WSAStartup > error still shows up. Try linking in the WinSock2 lib, as Charles mentioned. > Also I would like to run this a stand alone file (not a project). Any > suggestions? For this, you might want to use the command-line/make, or else, specify in compiler options that you want the WinSock lib to be linked with all your programs. Remove it once you're done with this project. Bit of a hassle. Command-line would be better. ___________________________________________________________ Abhijit Shylanath E-mail: mu...@gm... || ibr...@bi... Web-site: http://mudeth.tripod.com/ |
|
From: Palamino <am...@ur...> - 2002-12-29 20:19:01
|
Just add "c:\Dev-c++\Lib\libwsock32.a" (supposing you have Dev-c++ installed on drive C) in the project options, under "Further object files or linker options". ----- Original Message ----- From: "Manoj Sharma" <sha...@ro...> To: "Dev-C++" <dev...@li...> Sent: Sunday, December 29, 2002 10:14 PM Subject: [Dev-C++] Trouble compiling winsock programs. > Hi, > > I am trying to compile a simple winsock program using Dev-C++ and get the > following error > [Linker error] undefined reference to WSAStartup@8. I tried generating my > own libwsock32.a library using the wsock32.dll on my system with the help > of the dllwrap utility and linking it to my program by copying the generated > .a file to the lib directory but the error stayed the same. > > I also tried using an older version of wsock32.dll (since I have the latest > version of the dll) and it may not be compatible with the header files as > supplied by Dev-C++. But this gave me the same undefined reference error. > > As a last resort I tried using the header files supplied by the Microsoft > SDK instead of the include directory header files as supplied by Dev-C++. I > get a target architecture must be defined error. An attempt to #define > _M_IX86 which is the macro that needs to be defined leads to further errors, > so I would prefer not to go down that path further. > > Can anyone suggest what else can be done to get a very simple winsock > program to work. I have the XP OS on a Pentium machine. > > Regards, > Manoj. > > http://manoj_sharma0.tripod.com > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |