From: Aron R. <aro...@gm...> - 2008-06-24 01:22:41
|
On Mon, Jun 23, 2008 at 1:54 AM, JonY <10...@gm...> wrote: > Mariano Martinez Peck wrote: > > Vicents: Thanks a lot. I have been searching and it obviously seems an > > error with sockets. > > > > If you see in config.log, you can see thees things: > > > > c:/MySQL/include/mysql_com.h:183: error: syntax error before "SOCKET" > > c:/MySQL/include/mysql_com.h:183: warning: no semicolon at end of struct > > or union > > c:/MySQL/include/mysql_com.h:222: error: syntax error before '}' token > > > > > > > > configure:26052: checking for select > > configure:26108: gcc -std=gnu99 -o conftest.exe -g -O2 > > -Ic:/MySQL/include -Lc:/MySQL/lib/opt conftest.c >&5 > > C:/DOCUME~1/JuanjoE/CONFIG~1/Temp/ccgXlikM.o: In function `main': > > c:/mariano/opendbx-1.3.10/conftest.c:75: undefined reference to `select' > > > > > > configure:25820: checking sys/socket.h usability > > configure:25837: gcc -std=gnu99 -c -g -O2 -Ic:/MySQL/include conftest.c > >&5 > > conftest.c:68:24: sys/socket.h: No such file or directory > > > > > > | #include <sys/socket.h> > > configure:25857: result: no > > configure:25861: checking sys/socket.h presence > > configure:25876: gcc -std=gnu99 -E -Ic:/MySQL/include conftest.c > > conftest.c:35:24: sys/socket.h: No such file or directory > > > > > > | #include <sys/socket.h> > > configure:25896: result: no > > configure:25929: checking for sys/socket.h > > configure:25937: result: no > > > > configure:25988: gcc -std=gnu99 -c -g -O2 -Ic:/MySQL/include conftest.c > >&5 > > conftest.c: In function `main': > > conftest.c:79: error: syntax error before "fd_set" > > > > > > and lots more. > > > > Now, the question is, how openDBX code should be done so that to be able > > to be compiled with gcc under linux and MinGW under windows? > > > > I have been these links: > > > > - http://www.mingw.org/MinGWiki/index.php/sockets > > - http://bytes.com/forum/thread745513.html > > Here it does something like this: > > > > #ifdef MINGW32 > > #include <winsock2.h> > > > > > > int main() { > > #ifdef MINGW32 > > WSADATA wsadata; > > > > > > And the last question, just to understand not to criticize. Why this do > > compiles under cygwin but doesn't under MinGW? > > > > very thanks, > > > > Mariano > > > > Hi, > this is because Cygwin is designed from the ground up to be more > "unixy", functioning as an emulation layer of sorts, translating > traditional Unix calls to win32. Its also the reason Cygwin apps depend > on the Cygwin Runtime dll, cywin1.dll. > > MinGW on the other hand provides a minimalist interface to MS's C > runtime, msvcrt.dll. It does not provide additional Unix calls other > than what is already supported by msvcrt. > > Next time, please avoid top posting, thanks. IMHO, MinGW should provide POSIX abstractions in headers where possible. I do understand the reasoning for not providing replacement functions as additional libraries though. I use the following in my little socket abstraction library: #if (PLATFORM_KIND==Posix_Platform) #include <unistd.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netdb.h> #include <net/if.h> #include <stdint.h> #include <errno.h> #define closesocket close #define ioctlsocket ioctl #define WSAEINTR EINTR #define WSAEWOULDBLOCK EWOULDBLOCK #define WSAECONNREFUSED ECONNREFUSED #define WSAECONNABORTED ECONNABORTED #define WSAEAGAIN EAGAIN #define WSAEPROTO EPROTO #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define wsa_get_ready() {} #else //Posix #include <windows.h> #include <winbase.h> #include <winuser.h> #include <ws2tcpip.h> #include <iphlpapi.h> #ifndef R_OK #define R_OK 2 #endif #define WSAEAGAIN WSATRY_AGAIN #define WSAEPROTO WSAEPROTONOSUPPORT typedef unsigned long in_addr_t; #define IFNAMSIZ MAX_ADAPTER_NAME_LENGTH #define IFHWADDRLEN MAX_ADAPTER_ADDRESS_LENGTH int wsa_is_ready = 0; #define wsa_get_ready() if( !wsa_is_ready ) {WSADATA wd; WSAStartup( MAKEWORD(2,2), &wd );} #endif // Posix |