包含SDL时,简单的tcp echo程序无法正常工作?

我有这个奇怪的问题,每当我#include "SDL/SDL.h" ,我的Windows套接字程序都不会执行。 它可以编译但运行时不会执行任何操作。 当我删除#include "SDL/SDL.h"标头,编译并运行时,它又开始工作了吗?

我正在尝试使SDL和我的原始套接字程序工作,但我不明白这是错误的。

 //#include "SDL/SDL.h" #define _WIN32_WINNT 0x501 #include  #include  #include  #include  #include  #include  #define MAXLEN 80 using namespace std; const int winsockVersion = 2; int main( int argc, char* args[] ) { WSADATA wsadata; if ( (WSAStartup(MAKEWORD(2,0),&wsadata)) == 0){ cout<<"-[ WSAStartup Initialized. ]" << endl; char PORT[MAXLEN]; char SERVER[MAXLEN]; cout <>SERVER; cout <>PORT; struct addrinfo hints, *res; int sockfd; memset(&hints,0,sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if (getaddrinfo(SERVER,PORT,&hints,&res) != 0){ cout<<"-Getaddrinfo unsuccessful." <ai_family,res->ai_socktype,res->ai_protocol)) == -1 ){ cout<<"-Unable to create socket." <ai_addr,res->ai_addrlen)) != -1 ){ cout<<"-[ Connection Established. ]" << endl; } cout<<"-[ Client connecting to: ]" <ai_addr << endl; while(true){ string text_buff; cout<<"Send: "; getline(cin,text_buff); if( (send(sockfd,text_buff.c_str(),text_buff.length()+1,0)) != -1 ){ cout< Data sent!." << endl; } if ( text_buff == "quit" ){ break; } } }else{ cout<<"-WSAStartup Initialization failed." << endl; if(WSACleanup()!=0){ cout<<"-WSACleanup Successful." << endl; }else{ cout<<"-WSACleanup Failed." << endl; } } return 0; } 

编译

 g++ -o draft.exe draft.cpp -I"C:\compilers and libs\Libs\SDL\SDL devep\SDL-1.2.15\include" -L"C:\compilers and libs\Libs\SDL\SDL devep\SDL-1.2.15\lib" -lmingw32 -lSDLmain -lSDL -lws2_32 

据我所知,SDL用一些愚蠢的#define main技巧重写主要function,它就像那样拦截程序主。

因此,可能根本没有调用main。

如果我没记错的话,你的主函数(参数)应该是int main(int argc, char *argv[])