Error Undefined Reference To Wsastartup
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about undefined reference to wsastartup@8' code blocks Stack Overflow the company Business Learn more about hiring developers or posting ads with
Undefined Reference To Getaddrinfo'
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is undefined reference to wsastartup@8' dev c++ a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up C - Undefined Reference to WSAStartup@8' up vote 1 down vote favorite I am undefined reference to `wnetaddconnection2a@16' using Code::Blocks, MinGW, and Windows. Im trying to initialize the winsock so that I can work on a project. I keep getting the error Undefined Reference to WSAStartup@8 Anyone know how to go about fixing this? #include
Undefined Reference To `doformatmessage'
0; } } c mingw codeblocks winsock share|improve this question edited Dec 20 '15 at 20:50 bigreddot 4,962831 asked Dec 20 '15 at 19:15 Paulo 63 How do you compile your code ? –H. DJEMAI Dec 20 '15 at 19:23 FWIW it compiles and links with MSVC. –Weather Vane Dec 20 '15 at 19:25 It's compiled with GNU GCC hope that helps –Paulo Dec 20 '15 at 19:32 The variable Results is not declared in the Printf statement –H. DJEMAI Dec 20 '15 at 19:41 @HocineDJEMAI OP noticed his mistake but only partially edited it. –Weather Vane Dec 20 '15 at 19:42 | show 6 more comments 3 Answers 3 active oldest votes up vote 1 down vote Linker looks for dependencies after the code was loaded. If library appeared in the building process before the symbols were needed, because source files appeared after that, then no symbols were used and later when they appear in source files they will be unresolved. Place the winsock library -lws2_32 that you link with AFTER the source and object files. gcc prog.c -o prog -lws2_32 share|improve this answer edited Dec 30 '15 at 22:13 answered Dec 20 '15 at 19:46 where_is_t
here for a quick overview of mingw winsock the site Help Center Detailed answers to any questions lws2_32 you might have Meta Discuss the workings and policies of this site About
Undefined Reference To Socket@12' Code Blocks
Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions http://stackoverflow.com/questions/34384803/c-undefined-reference-to-wsastartup8 Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MinGW + Boost: undefined reference to http://stackoverflow.com/questions/12472654/mingw-boost-undefined-reference-to-wsastartup8 `WSAStartup@8' up vote 6 down vote favorite below is what I execute D:\Just4Fun\software\>make -f Makefile.hands stest
g++.exe -g -D_WIN32_WINNT=0x0601 -ID:\Boost\boost_1_51_0 -LD:\Boost\boost_1_51_0\stage\lib -LD:\MinGW\lib -lboost_system-mgw46-d-1_51 -lboost_filesystem-mgw46-d-1_51 -lboost_iostreams-mgw46-d-1_51 -lws2_32 -lwsock32 -o TestSerial.exe TestSerial.cpp below is the result of that C:\Users\oleg\AppData\Local\Temp\ccXpC7RG.o: In function 'ZN5boost4asio6detail17winsock_init_base7startupERNS2_4dataEhh': D:/Boost/boost_1_51_0/boost/asio/detail/impl/winsock_init.ipp:39: undefined reference to 'WSAStartup@8'C:\Users\oleg\AppData\Local\Temp\ccXpC7RG.o: In function 'ZN5boost4asio6detail17winsock_init_base7cleanupERNS2_4dataE': D:/Boost/boost_1_51_0/boost/asio/detail/impl/winsock_init.ipp:48: undefined reference to 'WSACleanup@0' collect2: ld returned 1 exit status make: *** [stest] Error 1 Below is result of checking libraries regarding to mentioned symobls (I failed to format it in appropriate way) `d:\MinGW\lib>nm -C libws2_32.a | grep WSAStartup 00000000 T WSAStartup@8 00000000 I imp_WSAStartup@8 d:\MinGW\lib>nm -C libws2_32.a | grep WSACleanup 00000000 T WSACleanup@0 00000000 I imp_WSACleanup@0 d:\MinGW\lib>nm -C libwsock32.a | grep WSACleanup 00000000 T WSACleanup@0 00000000 I imp_WSACleanup@0 d:\MinGW\lib>nm -C libwsock32.a | grep WSAStartup 00000000 T WSAStartup@8 00000000 I imp_WS
Windows and many major Linux distros here . Home Help Search Login Register Wiki Code::Blocks » User forums » Help » Winsock in Console Application http://forums.codeblocks.org/index.php?topic=1341.0 (undefined reference to `WSAStartup@8') « previous next » Send this topic Print Pages: [1] Go Down Author Topic: Winsock in Console Application (undefined reference to `WSAStartup@8') (Read 14757 times) Bj83 Guest Winsock in Console Application (undefined reference to `WSAStartup@8') « on: November 10, 2005, 03:48:52 pm » Hi,I already searched the internet for this problem, nothin found... :?I started a simple ConsoleApplication with this undefined reference text in main.cpp:Code: [Select]#include
#include
using namespace std;
int main()
{
WSADATA wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0)
{
cout<<"WSAStartup failed."<
return 0;
}
the compiler say:Code: [Select]Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : G:\Dokumente und Einstellungen\ma\Eigene Dateien\Neuer undefined reference to Ordner (6)\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
Linking console executable: G:\Dokumente und Einstellungen\ma\Eigene Dateien\Neuer Ordner (6)\console.exe
.objs\main.o:main.cpp:(.text+0x145): undefined reference to `WSAStartup@8'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
I just want a simple Winsock App. I read on some sites its a problem with the lib files, but no one could tell how to fix it.Using Code::Blocks 1RC2 Windows Version; GNU GCC compiler Logged mandrav Project Leader Administrator Lives here! Posts: 4291 Re: Winsock in Console Application (undefined reference to `WSAStartup@8') « Reply #1 on: November 10, 2005, 04:04:39 pm » QuoteI already searched the internet for this problem, nothin found...Yeah right...clickyGoogle says: Results 1 - 50 of about 565 English pages for undefined reference to `WSAStartup@8'. (2.46 seconds)Add libws2_32.a in link libraries... Logged Be patient!This bug will be fixed soon... Bj83 Guest Re: Winsock in Console Application (undefined reference to `WSAStartup@8') « Reply #2 on: November 10, 2005, 08:06:10 pm » Thanks... :oops:Looks like i have made some mistake, thanks again.It works fine now with the lib :oops: Logged Send this topic Print Pages: [1] Go Up « previous next » Code::Blocks