GithubHelp home page GithubHelp logo

dpull / skynet-mingw Goto Github PK

View Code? Open in Web Editor NEW
302.0 25.0 125.0 224 KB

对skynet无任何改动的windows版

Home Page: http://blog.dpull.com/post/2015-11-08-skynet_mingw

License: MIT License

Makefile 11.26% C 77.95% Shell 1.08% Lua 9.71%

skynet-mingw's Introduction

关于skynet-mingw Build status

skynet-mingwskynet的windows平台的实现。其主要特点是:

  1. skynet 以submodule链接,方便升级,确保不改
  2. 仅扩展了700行代码,方便维护。
  3. 自动更新skynet,自动构建,自动化测试,确保质量。

编译

不想自行编译的朋友可访问 自动构建平台获取最新的构建版本

  1. 安装 MinGW
  2. 安装 gcc g++
  3. 安装 pthread (dev)
  4. 运行 MinGW\msys\1.0\msys.bat
  5. 运行 prepare.sh
  6. 运行 make

常见问题

  1. 建议使用 MinGW\msys\1.0\msys.bat 进行编译
  2. 错误: gcc: Command not found, 解决: 修改 msys\1.0\etc\fstab 中的 /mingw 路径
  3. 当提示缺少类似dlfcn.h文件时,建议看看头文件搜索路径是否有问题,举个例子perl(Strawberry Perl)中有gcc程序,同时它注册了系统环境变量

测试

./skynet.exe examples/config    # Launch first skynet node  (Gate server) and a skynet-master (see config for standalone option)
./3rd/lua/lua examples/client.lua   # Launch a client, and try to input hello.

已知问题

  1. console服务不可用(无法对stdin进行select), 会提示如下出错信息,暂时没有解决方案。
stack traceback:
        [C]: in function 'assert'
        ./lualib/socket.lua:361: in function 'socket.lock'
        ./service/console.lua:15: in upvalue 'func'
        ./lualib/skynet.lua:452: in upvalue 'f'
        ./lualib/skynet.lua:105: in function <./lualib/skynet.lua:104>
  1. 使用skynet.abort无法退出,看堆栈卡在了系统中,暂时没有解决方案。(替代方案os.exit(true)
#0  0x77bd718c in ntdll!ZwWaitForMultipleObjects () from C:\WINDOWS\SYSTEM32\ntdll.dll
#1  0x74c0a4fa in WaitForMultipleObjectsEx () from C:\WINDOWS\SYSTEM32\KernelBase.dll
#2  0x74c0a3d8 in WaitForMultipleObjects () from C:\WINDOWS\SYSTEM32\KernelBase.dll
#3  0x6085be1c in pause () from D:\MinGW\msys\1.0\bin\msys-1.0.dll
#4  0x6085ccf1 in msys-1.0!cwait () from D:\MinGW\msys\1.0\bin\msys-1.0.dll
#5  0x6080dff4 in msys-1.0!cygwin_stackdump () from D:\MinGW\msys\1.0\bin\msys-1.0.dll
#6  0x00413fe5 in ?? ()
#7  0x00413e8f in ?? ()
#8  0x00412a1b in ?? ()
#9  0x0040f77b in ?? ()
#10 0x0040f151 in ?? ()
#11 0x00403869 in __mingw_opendir ()
#12 0x0000000a in ?? ()
#13 0x0069fe30 in ?? ()
#14 0x00000000 in ?? ()

相关文档

开发笔记

skynet-mingw's People

Contributors

dpull avatar liubing2023 avatar michaeloujie avatar srdgame avatar yuanfengyun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skynet-mingw's Issues

关于windows版本的socket的error无法正常返回

由于socket_server.c的头文件包含顺序,winsock2.h定义SOCKET_ERROR=-1,而skynet定义是4,然后socket_server_poll处理时,如果是-1就直接continue掉了,造成windows版本socket的error就一直阻塞,通过将socket_server.h的包含调整到最下面可以解决此问题。

在 minGW 下运行 prepare.sh 的问题

系统:win10 64
minGW32:6.3.0

执行第5步,提示错误:

$ prepare.sh
ln: creating symbolic link `3rd/3rd' to `skynet/3rd/': No such file or directory
ln: creating symbolic link `examples/examples' to `skynet/examples/': No such file or directory
ln: creating symbolic link `lualib/lualib' to `skynet/lualib/': No such file or directory
ln: creating symbolic link `lualib-src/lualib-src' to `skynet/lualib-src/': No such file or directory
ln: creating symbolic link `service/service' to `skynet/service/': No such file or directory
ln: creating symbolic link `service-src/service-src' to `skynet/service-src/': No such file or directory
ln: creating symbolic link `skynet-src/skynet-src' to `skynet/skynet-src/': No such file or directory
ln: creating symbolic link `test/test' to `skynet/test/': No such file or directory

可能是win10下ln函数不好用,改了一个批处理。

cd F:\source\skynet-mingw
f:

mklink /D  3rd skynet\3rd\
mklink /D  examples skynet\examples\
mklink /D  lualib  skynet\lualib\
mklink /D  lualib-src  skynet\lualib-src\
mklink /D  service skynet\service\
mklink /D  service-src  skynet\service-src\
mklink /D  skynet-src skynet\skynet-src\
mklink /D  test skynet\test\
pause

这样好用了。

msys2编译,link函数重复

msys2编译,platform可以删掉一些代码,不过最后遇到一个问题,unistd.h和time.c有一个link函数重复定义了,不知道如何解决。

make的时候error: unknown type name 'sigset_t'

platform/platform.h:16:2: error: unknown type name 'sigset_t'
sigset_t sa_mask;
^
platform/platform.h:21:16: error: unknown type name 'sigset_t'
int sigfillset(sigset_t *set);
^
platform/platform.h:22:17: error: unknown type name 'sigset_t'
int sigemptyset(sigset_t *set);

windows 下编译 错误, 自动编译平台上也是这个错误,帮忙看一下呢,谢谢

make
gcc -std=gnu99 -g -O2 -Wall -Iplatform -I3rd/lua --shared platform/platform.c platform/epoll.c platform/socket_poll.c platform/socket_extend.c -lws2_32 -lwsock32 -o platform.dll -DDONOT_USE_IO_EXTEND -DFD_SETSIZE=1024
gcc -std=gnu99 -includeplatform.h -g -O2 -Wall -Iplatform -I3rd/lua --shared -o skynet.dll skynet-src/skynet_handle.c skynet-src/skynet_module.c skynet-src/skynet_mq.c skynet-src/skynet_server.c skynet-src/skynet_start.c skynet-src/skynet_timer.c skynet-src/skynet_error.c skynet-src/skynet_harbor.c skynet-src/skynet_env.c skynet-src/skynet_monitor.c skynet-src/skynet_socket.c skynet-src/socket_server.c skynet-src/malloc_hook.c skynet-src/skynet_daemon.c skynet-src/skynet_log.c -Iskynet-src -llua54 -lplatform -lpthread -lws2_32 -L. -DNOUSE_JEMALLOC -DFD_SETSIZE=4096
skynet-src/skynet_start.c: In function 'thread_timer':
skynet-src/skynet_start.c:137:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
usleep(2500);
^~~~~~
In file included from platform/platform.h:5:0,
from :0:
d:\mingw\include\unistd.h:104:5: note: declared here
int usleep( useconds_t period ){ return __mingw_sleep( 0, 1000 * period ); }
^~~~~~
skynet-src/socket_server.c: In function 'enable_write':
skynet-src/socket_server.c:541:10: warning: implicit declaration of function 'sp_enable' [-Wimplicit-function-declaration]
return sp_enable(ss->event_fd, s->fd, s, s->reading, enable);
^~~~~~~~~
skynet-src/socket_server.c: In function 'close_write':
skynet-src/socket_server.c:697:19: error: 'SHUT_WR' undeclared (first use in this function)
shutdown(s->fd, SHUT_WR);
^~~~~~~
skynet-src/socket_server.c:697:19: note: each undeclared identifier is reported only once for each function it appears in
make: *** [skynet.dll] Error 1

关于代码的一些问题

我是使用xubuntu16.04交叉编译的这份代码。
其中有这么几个问题:
1、是不是只能编译32位的代码?我编译64位的后,执行会报:
Expression: sizeof(struct epoll_fd*) <= sizeof(int)

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

2、windows.h和ws2tcpip.h建议使用小写。因为linux下的mingw32这二个文件是小写的。win下对大小写不敏感。所以应当没有什么问题。

3、socket下的.h文件中的 EWOULDBLOCK和 EINPROGRESS定义用#ifndef #define #endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#endif
#ifndef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#endif

4、关于dlfcn.h缺失问题,我不知道win上的mingw32存不存在这个问题。但是ubuntu上是存在的。我是使用
https://github.com/dlfcn-win32/dlfcn-win32
来替代的。

5、platform.h中的
enum { CLOCK_THREAD_CPUTIME_ID, CLOCK_REALTIME, CLOCK_MONOTONIC }; 和 enum { LOCK_EX, LOCK_NB };莫名冲突。后面我发现与pthread_time.h里的定义冲突了,你看一下,要不要使用pthread_time.h来替代一下。

最后,为你这个项目点个赞,让我们能够在win上学习skynet

帮忙看看, 是我环境有问题吗

cd 3rd/lua && D:/Bin/mingw/bin/make CC='gcc -std=gnu99' mingw && cd - && cp -f 3rd/lua/lua54.dll ./lua54.dll
make[1]: Entering directory 'd:/Workspace/skynet-mingw/3rd/lua'
D:/Bin/mingw/bin/make "LUA_A=lua54.dll" "LUA_T=lua.exe"
"AR=gcc -std=gnu99 -shared -o" "RANLIB=strip --strip-unneeded"
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
D:\Bin\mingw\bin\make: invalid option -- =
D:\Bin\mingw\bin\make: invalid option -- g
D:\Bin\mingw\bin\make: invalid option -- u
D:\Bin\mingw\bin\make: invalid option -- 9
D:\Bin\mingw\bin\make: invalid option -- 9
D:\Bin\mingw\bin\make: invalid option -- a
D:\Bin\mingw\bin\make: unrecognized option '--strip-unneeded SYSCFLAGS=-DLUA_BUILD_AS_DLL SYSLIBS= SYSLDFLAGS=-s lua.exe'
Usage: make [options] [target] ...
Options:
-b, -m Ignored for compatibility.
-B, --always-make Unconditionally make all targets.
-C DIRECTORY, --directory=DIRECTORY
Change to DIRECTORY before doing anything.
-d Print lots of debugging information.
--debug[=FLAGS] Print various types of debugging information.
-e, --environment-overrides
Environment variables override makefiles.
--eval=STRING Evaluate STRING as a makefile statement.
-f FILE, --file=FILE, --makefile=FILE
Read FILE as a makefile.
-h, --help Print this message and exit.
-i, --ignore-errors Ignore errors from recipes.
-I DIRECTORY, --include-dir=DIRECTORY
Search DIRECTORY for included makefiles.
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-k, --keep-going Keep going when some targets can't be made.
-l [N], --load-average[=N], --max-load[=N]
Don't start multiple jobs unless load is below N.
-L, --check-symlink-times Use the latest mtime between symlinks and target.
-n, --just-print, --dry-run, --recon
Don't actually run any recipe; just print them.
-o FILE, --old-file=FILE, --assume-old=FILE
Consider FILE to be very old and don't remake it.
-p, --print-data-base Print make's internal database.
-q, --question Run no recipe; exit status says if up to date.
-r, --no-builtin-rules Disable the built-in implicit rules.
-R, --no-builtin-variables Disable the built-in variable settings.
-s, --silent, --quiet Don't echo recipes.
-S, --no-keep-going, --stop
Turns off -k.
-t, --touch Touch targets instead of remaking them.
--trace Print tracing information.
-v, --version Print the version number of make and exit.
-w, --print-directory Print the current directory.
--no-print-directory Turn off -w, even if it was turned on implicitly.
-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
Consider FILE to be infinitely new.
--warn-undefined-variables Warn when an undefined variable is referenced.

This program built for i686-pc-mingw32
Report bugs to [email protected]
Makefile:130: recipe for target 'mingw' failed
make[1]: *** [mingw] Error 2
make[1]: Leaving directory 'd:/Workspace/skynet-mingw/3rd/lua'
Makefile:79: recipe for target '3rd/lua/liblua.a' failed
make: *** [3rd/lua/liblua.a] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.