acl-dev / acl

C/C++ server and network library, including coroutine,redis client,http/https/websocket,mqtt, mysql/postgresql/sqlite client with C/C++ for Linux, Android, iOS, MacOS, Windows, etc..
https://acl-dev.cn
GNU Lesser General Public License v3.0
2.83k stars 937 forks source link

make出错 #292

Open qazwsxedckll opened 1 year ago

qazwsxedckll commented 1 year ago
make[1]: Entering directory '/workspaces/acl-3.5.3-22/app/master/tools/master_ctl'
rm -f master_ctl
g++ -c -g -W -Wall -Wcast-qual -Wcast-align -Wno-long-long -Wpointer-arith -Werror -Wshadow -O3 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO -DLINUX2 -D_REENTRANT -I. -I../../daemon/json -I../../../../lib_acl/include -I../../../../lib_acl_cpp/include -I../../../../lib_protocol/include stdafx.cpp -o debug/stdafx.o
g++ -c -g -W -Wall -Wcast-qual -Wcast-align -Wno-long-long -Wpointer-arith -Werror -Wshadow -O3 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO -DLINUX2 -D_REENTRANT -I. -I../../daemon/json -I../../../../lib_acl/include -I../../../../lib_acl_cpp/include -I../../../../lib_protocol/include main.cpp -o debug/main.o
g++ -c -g -W -Wall -Wcast-qual -Wcast-align -Wno-long-long -Wpointer-arith -Werror -Wshadow -O3 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_USE_FAST_MACRO -DLINUX2 -D_REENTRANT -I. -I../../daemon/json -I../../../../lib_acl/include -I../../../../lib_acl_cpp/include -I../../../../lib_protocol/include ../../daemon/json/struct.gson.cpp -o debug/struct.gson.o
g++  ./debug/stdafx.o  ./debug/main.o  ./debug/struct.gson.o -L../../../../lib_acl_cpp/lib -lacl_cpp -L../../../../lib_protocol/lib -lprotocol -L../../../../lib_acl/lib -lacl -lpthread -lz -liconv -lcrypt -ldl -lz -o master_ctl
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: cannot find -liconv
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile.in:172: all] Error 1
make[1]: Leaving directory '/workspaces/acl-3.5.3-22/app/master/tools/master_ctl'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/workspaces/acl-3.5.3-22/app/master/tools/master_ctl'
cp master_ctl ../../../../dist/master/bin/linux64/
cp: cannot stat ‘master_ctl’: No such file or directory
make[1]: *** [Makefile.in:184: install] Error 1
make[1]: Leaving directory '/workspaces/acl-3.5.3-22/app/master/tools/master_ctl'
make: *** [Makefile:158: acl_master] Error 2

windows docker环境,centos7.9镜像

$uname -a
Linux 0c15f8482e48 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

acl-3.5.3-22/app/master/tools/master_ctl/Makefile.in

OS_ENV=$(shell uname -a)
ifeq ($(findstring WSL, $(OS_ENV)), WSL)
    SYSLIB += -liconv
endif

虽然内核有WSL字样,但是还是centos的镜像,不应该加上liconv吧。

zhengshuxin commented 1 year ago

可以自行在连接时加上。

qazwsxedckll commented 1 year ago

我的意思是,应该不需要这个判断,docker容器和wsl,uname -a出来是一样的,但是不知道docker用的是什么镜像。

就像这里没有加-liconv的理由一样

#Path for Linux
ifeq ($(findstring Linux, $(OSNAME)), Linux)
    ifeq ($(findstring i686, $(OSNAME)), i686)
        RPATH = linux32
    endif
    ifeq ($(findstring x86_64, $(OSNAME)), x86_64)
        RPATH = linux64
    endif
#   CFLAGS += -DLINUX2
    SYSLIB += -rdynamic
endif
zhengshuxin commented 1 year ago

OS_ENV=$(shell uname -a) ifeq ($(findstring WSL, $(OS_ENV)), WSL) SYSLIB += -liconv endif

这个是针对WSL的环境的编译选项。

qazwsxedckll commented 1 year ago

windows的docker desktop,启动任何一个镜像,uname -a出来,也会带有WSL的字样,但是不代表有iconv,会导致编译不过。并不是只有wsl才会uname -a出来WSL。

zhengshuxin commented 1 year ago

有的Linux上的 glibc 包含有 iconv,有的不包含,需要单独引入,目前还没有更好的办法在 Makefile 中探测到底属于哪种情形,所以只能是粗略地通过 uname -a 来加以区分。

babA409866 commented 1 year ago

可以直接安装个iconv就好了。apt-get install libiconv-dev。