標籤:height initial table window byte caching nop include ogre
一、綜述
Libevent 是一個用C語言編寫的、輕量級的開源高效能事件通知庫。
在libevent官網(http://libevent.org)下載源碼包,在Windows平台編譯時間,會報缺少“print_winsock_errors.obj”的錯誤。
二、原因及解決
經檢查,這是因為源碼包中缺少檔案test/print_winsock_errors.c導致,原因未知。
解決方案:手工產生test/print_winsock_errors.c,以下為從git搜尋到的代碼內容:
#include <winsock2.h>#include <windows.h>#include <stdlib.h>#include <stdio.h>#include "event2/event.h"#include "event2/util.h"#include "event2/thread.h"#define E(x) printf (#x " -> \"%s\"\n", evutil_socket_error_to_string (x));int main (int argc, char **argv){ int i, j; const char *s1, *s2;#ifdef EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED evthread_use_windows_threads ();#endif s1 = evutil_socket_error_to_string (WSAEINTR); for (i = 0; i < 3; i++) { printf ("\niteration %d:\n\n", i); E(WSAEINTR); E(WSAEACCES); E(WSAEFAULT); E(WSAEINVAL); E(WSAEMFILE); E(WSAEWOULDBLOCK); E(WSAEINPROGRESS); E(WSAEALREADY); E(WSAENOTSOCK); E(WSAEDESTADDRREQ); E(WSAEMSGSIZE); E(WSAEPROTOTYPE); E(WSAENOPROTOOPT); E(WSAEPROTONOSUPPORT); E(WSAESOCKTNOSUPPORT); E(WSAEOPNOTSUPP); E(WSAEPFNOSUPPORT); E(WSAEAFNOSUPPORT); E(WSAEADDRINUSE); E(WSAEADDRNOTAVAIL); E(WSAENETDOWN); E(WSAENETUNREACH); E(WSAENETRESET); E(WSAECONNABORTED); E(WSAECONNRESET); E(WSAENOBUFS); E(WSAEISCONN); E(WSAENOTCONN); E(WSAESHUTDOWN); E(WSAETIMEDOUT); E(WSAECONNREFUSED); E(WSAEHOSTDOWN); E(WSAEHOSTUNREACH); E(WSAEPROCLIM); E(WSASYSNOTREADY); E(WSAVERNOTSUPPORTED); E(WSANOTINITIALISED); E(WSAEDISCON); E(WSATYPE_NOT_FOUND); E(WSAHOST_NOT_FOUND); E(WSATRY_AGAIN); E(WSANO_RECOVERY); E(WSANO_DATA); E(0xdeadbeef); /* test the case where no message is available */ /* fill up the hash table a bit to make sure it grows properly */ for (j = 0; j < 50; j++) { int err; evutil_secure_rng_get_bytes(&err, sizeof(err)); evutil_socket_error_to_string(err); } } s2 = evutil_socket_error_to_string (WSAEINTR); if (s1 != s2) printf ("caching failed!\n"); libevent_global_shutdown (); return EXIT_SUCCESS;}
然後使用VS命令提示工具,在libevent解壓目錄下執行:nmake /f Makefile.nmake,編譯順利通過。
三、其它
經檢查,在官網列出的1.4.x-stable, 2.0.x-stable, 2.1.x-stable等版本中貌似均存在此問題。
print_winsock_errors.c只有一段測試代碼,沒有也關係不大,因此另一種解決方案是:修改CmakeFileList,從中刪除與print_winsock_errors有關的內容。
windows編譯libevent時報告“缺少print_winsock_errors.obj”的解決