LeeReindeer / lightsocks-c

🌐 Light SOCKS5 proxy
MIT License
63 stars 25 forks source link

make遇错 #2

Closed luckypoem closed 5 years ago

luckypoem commented 5 years ago

hi。

[root@host lightsocks-c]# ls bin client config.json lib LICENSE Makefile README.md server [root@host lightsocks-c]# make gcc -c ./lib/base64.c -o ./bin/base64.o gcc -c ./lib/log.c -o ./bin/log.o -DLOG_USE_COLOR gcc -c ./lib/password.c -o ./bin/password.o ./lib/password.c: In function ‘gen_password_by_string’: ./lib/password.c:35:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < PASS_LENGTH; i++) { ^ ./lib/password.c:35:3: note: use option -std=c99 or -std=gnu99 to compile your code ./lib/password.c: In function ‘encode_data’: ./lib/password.c:67:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < size; i++) { ^ make: *** [password] Error 1 [root@host lightsocks-c]#

如何解决?

LeeReindeer commented 5 years ago

I'll fix makefile latter, you could add -std=c99 to every GCC command.

luckypoem commented 5 years ago

加了-std=c99 还是不行,还是没生成可执行文件

LeeReindeer commented 5 years ago

@luckypoem 是否已安装 libevent?有报错信息吗?

luckypoem commented 5 years ago

是的,安装了 libevent。安装 libevent时,一切正常

LeeReindeer commented 5 years ago

@luckypoem 那加了 std=c99 之后报什么错?

luckypoem commented 5 years ago

[root@host lightsocks-c]# ls bin base64.o log.o password.o [root@host lightsocks-c]# rm -rf bin/* [root@host lightsocks-c]# ls bin [root@host lightsocks-c]# pwd /root/lightsocks-c [root@host lightsocks-c]# gcc -c ./lib/base64.c -o ./bin/base64.o -std=c99 [root@host lightsocks-c]# ls bin base64.o [root@host lightsocks-c]# gcc -c ./lib/log.c -o ./bin/log.o -DLOG_USE_COLOR -std=c99 [root@host lightsocks-c]# ls bin base64.o log.o [root@host lightsocks-c]# gcc -c ./lib/password.c -o ./bin/password.o -std=c99 [root@host lightsocks-c]# ls bin base64.o log.o password.o [root@host lightsocks-c]#

没报错,但是加了‘-std=c99’跟没加它,没有什么区别。你在你的服务器上的bin目录里生成了可执行文件吗

LeeReindeer commented 5 years ago

你这样编译所有库之后,再运行 make lightclient。其实你直接再 Makefile 里加std=c99更方便。 PS: 服务端有点问题。本地的客户端没问题。所以我当时用的是lightsock(go语言)的服务端测试的。

LeeReindeer commented 5 years ago

如果你要实际用 lightsocks 去翻墙。我还是不推荐,个人感觉不安全,功能也不多。:smile: 以学习为目的,它倒是一个很好的例子。