From: Daniel K. <dko...@gm...> - 2011-06-24 17:47:29
|
I want to add the Sockets library (version 2.3.9.5) at http://www.alhem.net/Sockets/index.html to my compiler (Mingw32 version 4.5.2). I am not using cygwin, I am using the windows port of mingw32. I was able to compile the library using mingw32-make. However, I am having difficulty in compiling an example that came with the library source. Specifically, "echoserver.cpp". When I initially tried to compile this program, I did not tell mingw where the newly compiled library was; obviously a lot of errors where thrown. I looked into how to add said library to mingw. With that info, I decided to dump the library into the <mingw install root>\lib directory. I included all of the .o and .d files along with "libSockets.a". Next, I dumped everything else (.cpp, .h) into the <mingw install root>\include directory. Here I had one problem crop up- "semaphore.h" was a duplicate (it was in the newly compiled directory, and there was a copy in the <mingw install root>\include directory). I renamed the copy that had already been there (which is larger than the one that I compiled). Now, when I try to compile echoserver.cpp, I have far fewer errors than my first attempt to compile. Note- vast majority of errors in each case are "undefined referrence to XXX". This suggests to me that I went a step in the right direction. Now, I have had to tell mingw to use the library when I go to compile, using the "-l" switch. I think the issue I have now involves the semaphore.h file, which has stuff in it that referrence a threading library, namely "pthreads". I am not sure if the pthreads lib I grabbed is the right one. In fact, I have two files I dloaded- one is "libpthreadGC2.a" and the other is "libpthreadGCE2.a", and I forget where I got them from (though I do remember trusting the site). So, what I need is a brief explanation of what is going on here- why wasn't "pthreads" in the system32 directory? What should I do with the semaphore.h files? Some commands: [code] mingw32-c++ echoserver.cpp -o /c/echoserver.exe -lSockets -lws2_32 -lwsock32 -lpthreadGC2 -lpthreadGCE2 [/code] produces: [code] In file included from c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/Socket.h:46:0, from c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/ISocketHandler.h:40, from c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/ListenSocket.h:42, from echoserver.cpp:27: c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/Thread.h:115:2: error: 'Semaphore' does not name a type [/code] (Note- above output due to using the semaphore.h file that came from mingw, NOT the file I compiled). The below example is with the semaphore.h file that I compiled. [code] produces: [code] C:\Users\DKOVAC~1\AppData\Local\Temp\ccAO9Vef.o:echoserver.cpp:(.text$_ZN12ListenSocketI8MySocketE4BindER13SocketAddressRKSsi[ListenSocket<MySocket>::Bind(SocketAddress&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0xfe): undefined reference to `StrError(int)' C:\Users\DKOVAC~1\AppData\Local\Temp\ccAO9Vef.o:echoserver.cpp:(.text$_ZN12ListenSocketI8MySocketE4BindER13SocketAddressRKSsi[ListenSocket<MySocket>::Bind(SocketAddress&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x1ad): undefined reference to `StrError(int)' C:\Users\DKOVAC~1\AppData\Local\Temp\ccAO9Vef.o:echoserver.cpp:(.text$_ZN12ListenSocketI8MySocketE4BindER13SocketAddressRKSsi[ListenSocket<MySocket>::Bind(SocketAddress&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x2dc): undefined reference to `StrError(int)' C:\Users\DKOVAC~1\AppData\Local\Temp\ccAO9Vef.o:echoserver.cpp:(.text$_ZN12ListenSocketI8MySocketE4BindER13SocketAddressRKSsi[ListenSocket<MySocket>::Bind(SocketAddress&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x38b): undefined reference to `StrError(int)' C:\Users\DKOVAC~1\AppData\Local\Temp\ccAO9Vef.o:echoserver.cpp:(.text$_ZN12ListenSocketI15HttpDebugSocketE4BindER13SocketAddressRKSsi[ListenSocket<HttpDebugSocket>::Bind(SocketAddress&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0xfe): undefined reference to `StrError(int)' C:\Users\DKOVAC~1\AppData\Local\Temp\ccAO9Vef.o:echoserver.cpp:(.text$_ZN12ListenSocketI15HttpDebugSocketE4BindER13SocketAddressRKSsi[ListenSocket<HttpDebugSocket>::Bind(SocketAddress&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x1ad): more undefined references to `StrError(int)' follow c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(Thread.o): In function `Thread': c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/Thread.cpp:54: undefined reference to `Semaphore::Semaphore(long)' c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/Thread.cpp:73: undefined reference to `Semaphore::Post()' c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/Thread.cpp:54: undefined reference to `Semaphore::~Semaphore()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(Thread.o): In function `~Thread': c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/Thread.cpp:77: undefined reference to `Semaphore::~Semaphore()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(Thread.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/Thread.cpp:146: undefined reference to `Semaphore::Post()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(Thread.o): In function `~Thread': c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/Thread.cpp:77: undefined reference to `Semaphore::~Semaphore()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(Thread.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/Thread.cpp:170: undefined reference to `Semaphore::Wait()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(ResolvServer.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/ListenSocket.h:341: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(ResolvServer.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/ListenSocket.h:290: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(ResolvServer.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/ListenSocket.h:293: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(ResolvServer.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/ListenSocket.h:299: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(ResolvServer.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/ListenSocket.h:302: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(SocketHandlerThread.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/SocketHandlerThread.cpp:63: undefined reference to `Semaphore::Post()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(SocketHandlerThread.o): In function `~SocketHandlerThread': c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/SocketHandlerThread.cpp:48: undefined reference to `Semaphore::~Semaphore()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(SocketHandlerThread.o): In function `SocketHandlerThread': c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/SocketHandlerThread.cpp:43: undefined reference to `Semaphore::Semaphore(long)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(SocketHandlerThread.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/SocketHandlerThread.cpp:75: undefined reference to `Semaphore::Wait()' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(UdpSocket.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/UdpSocket.cpp:371: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(UdpSocket.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/UdpSocket.cpp:556: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(UdpSocket.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/UdpSocket.cpp:531: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(UdpSocket.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/UdpSocket.cpp:229: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(UdpSocket.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/UdpSocket.cpp:327: undefined reference to `StrError(int)' c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libSockets.a(UdpSocket.o):c:\Users\dkovacevic\Downloads\Binaries_and_Sources\C++\Sockets-2.3.9.5/UdpSocket.cpp:581: more undefined references to `StrError(int)' follow collect2: ld returned 1 exit status [/code] Any advice? |