TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

compile error with linux x86

Open rainsh2021 opened this issue 5 years ago • 13 comments

虚拟机系统环境:ubuntu 12.04 CMAKE版本:3.15.4 TDengine源码版本:2.0.5.0 编译目标:编译x86环境下可用的libtaos.so 操作步骤如下:

解压TDengine-ver-2.0.5.0.zip 执行正常

mkdir debug && cd debug 执行正常

cmake .. && cmake --build . 执行错误 root@ubuntn-virtual-machine:/third/TDengine-ver-2.0.5.0/debug# cmake --build . /usr/local/bin/cmake -S/third/TDengine-ver-2.0.5.0 -B/third/TDengine-ver-2.0.5.0/debug --check-build-system CMakeFiles/Makefile.cmake 0 /usr/local/bin/cmake -E cmake_progress_start /third/TDengine-ver-2.0.5.0/debug/CMakeFiles /third/TDengine-ver-2.0.5.0/debug/CMakeFiles/progress.marks /usr/bin/make -f CMakeFiles/Makefile2 all make[1]: 正在进入目录 '/third/TDengine-ver-2.0.5.0/debug' /usr/bin/make -f deps/zlib-1.2.11/CMakeFiles/z.dir/build.make deps/zlib-1.2.11/CMakeFiles/z.dir/depend make[2]: 正在进入目录 '/third/TDengine-ver-2.0.5.0/debug' cd /third/TDengine-ver-2.0.5.0/debug && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /third/TDengine-ver-2.0.5.0 /third/TDengine-ver-2.0.5.0/deps/zlib-1.2.11 /third/TDengine-ver-2.0.5.0/debug /third/TDengine-ver-2.0.5.0/debug/deps/zlib-1.2.11 /third/TDengine-ver-2.0.5.0/debug/deps/zlib-1.2.11/CMakeFiles/z.dir/DependInfo.cmake --color= Scanning dependencies of target z make[2]:正在离开目录 '/third/TDengine-ver-2.0.5.0/debug' /usr/bin/make -f deps/zlib-1.2.11/CMakeFiles/z.dir/build.make deps/zlib-1.2.11/CMakeFiles/z.dir/build make[2]: 正在进入目录 '/third/TDengine-ver-2.0.5.0/debug' [ 1%] Building C object deps/zlib-1.2.11/CMakeFiles/z.dir/src/adler32.c.o cd /third/TDengine-ver-2.0.5.0/debug/deps/zlib-1.2.11 && /home/7_0_0_240/basic/Build_Tools/x86/ia32-4.4/bin/i686-pc-linux-gnu-gcc -DLINUX -DUSE_LIBICONV -D_LIBC_REENTRANT -D_LINUX -D_MQTT -D_REENTRANT -D_SYNC -D_TD_LINUX -D_TD_LINUX_32 -D__USE_POSIX -I/third/TDengine-ver-2.0.5.0/deps/cJson/inc -I/third/TDengine-ver-2.0.5.0/deps/lz4/inc -I/third/TDengine-ver-2.0.5.0/src/inc -I/third/TDengine-ver-2.0.5.0/src/os/inc -I/third/TDengine-ver-2.0.5.0/src/util/inc -I/third/TDengine-ver-2.0.5.0/src/common/inc -I/third/TDengine-ver-2.0.5.0/deps/zlib-1.2.11/inc -g -std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -O0 -DDEBUG -std=gnu99 -o CMakeFiles/z.dir/src/adler32.c.o -c /third/TDengine-ver-2.0.5.0/deps/zlib-1.2.11/src/adler32.c cc1: error: unrecognized command line option "-munaligned-access" make[2]: *** [deps/zlib-1.2.11/CMakeFiles/z.dir/src/adler32.c.o] 错误 1 make[2]:正在离开目录 '/third/TDengine-ver-2.0.5.0/debug' make[1]: *** [deps/zlib-1.2.11/CMakeFiles/z.dir/all] 错误 2 make[1]:正在离开目录 '/third/TDengine-ver-2.0.5.0/debug' make: *** [all] 错误 2 在网上查了下,相关的参数只有-unaligned-access,针对于字节对齐设置的,没有找到-munaligned-access相关的信息,不知道什么情况会引起相关错误。

修改'/third/TDengine-ver-2.0.5.0/cmake/define.inc 第60行,去掉-munaligned-access 将 SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") 改为 SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")

重新执行 cmake .. && cmake --build . 执行错误 /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c: In function 'taosSetCoreDump': /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:606: error: storage size of 'args' isn't known /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:612: error: 'CTL_KERN' undeclared (first use in this function) /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:612: error: (Each undeclared identifier is reported only once /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:612: error: for each function it appears in.) /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:612: error: 'KERN_CORE_USES_PID' undeclared (first use in this function) /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:614: error: invalid application of 'sizeof' to incomplete type 'struct __sysctl_args' /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:615: error: request for member 'name' in something not a structure or union cc1: warnings being treated as errors /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:615: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:616: error: request for member 'nlen' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:616: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:617: error: request for member 'oldval' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:617: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:618: error: request for member 'oldlenp' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:618: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:619: error: request for member 'newval' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:619: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:620: error: request for member 'newlen' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:620: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:628: error: format '%llu' expects type 'long long unsigned int', but argument 4 has type 'size_t' **/third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:633: error: invalid application of 'sizeof' to incomplete type 'struct __sysctl_args' ** /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:634: error: request for member 'name' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:634: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:635: error: request for member 'nlen' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:635: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:636: error: request for member 'oldval' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:636: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:637: error: request for member 'oldlenp' in something not a structure or union /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:637: error: statement with no effect /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:645: error: format '%llu' expects type 'long long unsigned int', but argument 4 has type 'size_t' /third/TDengine-ver-2.0.5.0/src/os/src/detail/osSysinfo.c:606: error: unused variable 'args' make[2]: *** [src/os/src/detail/CMakeFiles/osdetail.dir/osSysinfo.c.o] 错误 1 make[2]:正在离开目录 '/third/TDengine-ver-2.0.5.0/debug' make[1]: *** [src/os/src/detail/CMakeFiles/osdetail.dir/all] 错误 2 make[1]:正在离开目录 '/third/TDengine-ver-2.0.5.0/debug' make: *** [all] 错误 2

rainsh2021 avatar Mar 21 '21 15:03 rainsh2021

gcc 版本太低了吧?

sangshuduo avatar Mar 21 '21 15:03 sangshuduo

gcc 版本太低了吧? 查询的版本信息如下,会有影响么? root@ubuntn-virtual-machine:/third/TDengine-ver-2.0.5.0/debug# gcc --version gcc (Ubuntu 5.4.1-2ubuntu1~12.04) 5.4.1 20160904 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

rainsh2021 avatar Mar 22 '21 01:03 rainsh2021

试试 develop 分支下编译

sangshuduo avatar Mar 22 '21 03:03 sangshuduo

试试 develop 分支下编译 尝试了下载一个develop版本的源代码,执行错误,错误原因和之前的版本一致 root@ubuntn-virtual-machine:/third/TDengine-develop/debug# cmake --build . /usr/local/bin/cmake -S/third/TDengine-develop -B/third/TDengine-develop/debug --check-build-system CMakeFiles/Makefile.cmake 0 /usr/local/bin/cmake -E cmake_progress_start /third/TDengine-develop/debug/CMakeFiles /third/TDengine-develop/debug/CMakeFiles/progress.marks /usr/bin/make -f CMakeFiles/Makefile2 all make[1]: 正在进入目录 '/third/TDengine-develop/debug' /usr/bin/make -f deps/zlib-1.2.11/CMakeFiles/z.dir/build.make deps/zlib-1.2.11/CMakeFiles/z.dir/depend make[2]: 正在进入目录 '/third/TDengine-develop/debug' cd /third/TDengine-develop/debug && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /third/TDengine-develop /third/TDengine-develop/deps/zlib-1.2.11 /third/TDengine-develop/debug /third/TDengine-develop/debug/deps/zlib-1.2.11 /third/TDengine-develop/debug/deps/zlib-1.2.11/CMakeFiles/z.dir/DependInfo.cmake --color= Scanning dependencies of target z make[2]:正在离开目录 '/third/TDengine-develop/debug' /usr/bin/make -f deps/zlib-1.2.11/CMakeFiles/z.dir/build.make deps/zlib-1.2.11/CMakeFiles/z.dir/build make[2]: 正在进入目录 '/third/TDengine-develop/debug' [ 0%] Building C object deps/zlib-1.2.11/CMakeFiles/z.dir/src/adler32.c.o cd /third/TDengine-develop/debug/deps/zlib-1.2.11 && /home/7_0_0_240/basic/Build_Tools/x86/ia32-4.4/bin/i686-pc-linux-gnu-gcc -DLINUX -DUSE_LIBICONV -D_LIBC_REENTRANT -D_LINUX -D_REENTRANT -D_TD_LINUX -D_TD_LINUX_32 -D__USE_POSIX -I/third/TDengine-develop/deps/cJson/inc -I/third/TDengine-develop/deps/lz4/inc -I/third/TDengine-develop/src/inc -I/third/TDengine-develop/src/os/inc -I/third/TDengine-develop/src/util/inc -I/third/TDengine-develop/src/common/inc -I/third/TDengine-develop/deps/zlib-1.2.11/inc -g -std=gnu99 -Wall -Werror -fPIC -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -O0 -g3 -DDEBUG -std=gnu99 -o CMakeFiles/z.dir/src/adler32.c.o -c /third/TDengine-develop/deps/zlib-1.2.11/src/adler32.c cc1: error: unrecognized command line option "-munaligned-access" make[2]: *** [deps/zlib-1.2.11/CMakeFiles/z.dir/src/adler32.c.o] 错误 1 make[2]:正在离开目录 '/third/TDengine-develop/debug' make[1]: *** [deps/zlib-1.2.11/CMakeFiles/z.dir/all] 错误 2 make[1]:正在离开目录 '/third/TDengine-develop/debug' make: *** [all] 错误 2

rainsh2021 avatar Mar 22 '21 07:03 rainsh2021

怀疑是你的工具链配置的安装问题,我在 Ubuntu 14.04 安装系统默认的 cmake 2.8.12 和 gcc 4.8 编译没问题

sangshuduo avatar Mar 22 '21 09:03 sangshuduo

怀疑是你的工具链配置的安装问题,我在 Ubuntu 14.04 安装系统默认的 cmake 2.8.12 和 gcc 4.8 编译没问题 重新卸载并安装了cmake和gcc、g++, 版本分别为2.8.12和4.8.4,报错内容还是一样 /usr/cmake-2.8.12.1-Linux-i386/bin/cmake -E cmake_progress_report /third/TDengine-ver-2.0.5.2/build/CMakeFiles [ 0%] Building C object deps/zlib-1.2.11/CMakeFiles/z.dir/src/inflate.c.o cd /third/TDengine-ver-2.0.5.2/build/deps/zlib-1.2.11 && /usr/bin/gcc -DLINUX -DUSE_LIBICONV -D_LIBC_REENTRANT -D_LINUX -D_MQTT -D_REENTRANT -D_SYNC -D_TD_LINUX -D_TD_LINUX_32 -D__USE_POSIX -g -std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -O0 -DDEBUG -I/third/TDengine-ver-2.0.5.2/deps/cJson/inc -I/third/TDengine-ver-2.0.5.2/deps/lz4/inc -I/third/TDengine-ver-2.0.5.2/src/inc -I/third/TDengine-ver-2.0.5.2/src/os/inc -I/third/TDengine-ver-2.0.5.2/src/util/inc -I/third/TDengine-ver-2.0.5.2/src/common/inc -I/third/TDengine-ver-2.0.5.2/deps/zlib-1.2.11/inc -o CMakeFiles/z.dir/src/inflate.c.o -c /third/TDengine-ver-2.0.5.2/deps/zlib-1.2.11/src/inflate.c gcc: error: unrecognized command line option ‘-munaligned-access’ make[2]:正在离开目录 '/third/TDengine-ver-2.0.5.2/build' make[2]: *** [deps/zlib-1.2.11/CMakeFiles/z.dir/src/inflate.c.o] 错误 1 make[1]: *** [deps/zlib-1.2.11/CMakeFiles/z.dir/all] 错误 2 make: *** [all] 错误 2 make[1]:正在离开目录 ‘/third/TDengine-ver-2.0.5.2/build' root@ubuntn-virtual-machine:/third/TDengine-ver-2.0.5.2/build# cmake --version cmake version 2.8.12.1 root@ubuntn-virtual-machine:/third/TDengine-ver-2.0.5.2/build# gcc --version gcc (Ubuntu 4.8.4-1ubuntu15~12.04.1) 4.8.4 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. root@ubuntn-virtual-machine:/third/TDengine-ver-2.0.5.2/build# g++ --version g++ (Ubuntu 4.8.4-1ubuntu15~12.04.1) 4.8.4 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

rainsh2021 avatar Mar 23 '21 03:03 rainsh2021

你试试装一个 Ubuntu 14.04 以上的版本,不要自己下载源码或者 deb 包,只需要 

  1. apt-get install cmake build-essential 
  2.  git clone https://github.com/taosdata/TDengine 
  3. cd TDengine
  4. mkdir debug
  5. cd debug
  6. cmake ..
  7. make

sangshuduo avatar Mar 23 '21 07:03 sangshuduo

你试试装一个 Ubuntu 14.04 以上的版本,不要自己下载源码或者 deb 包,只需要 

  1. apt-get install cmake build-essential
  2. git clone https://github.com/taosdata/TDengine
  3. cd TDengine
  4. mkdir debug
  5. cd debug
  6. cmake ..
  7. make 根据你的推荐,重新下载了一个ubuntu 14的镜像文件,用虚拟机打开, 虚拟机系统环境:ubuntu 14.04 CMAKE版本:2.8.12.2 (通过apt-get install cmake指令安装) GCC版本:4.8.4 (系统自带) G++版本:4.8.4 (通过apt-get install g++指令安装) 按照你推荐的步骤进行操作,执行到make编译编译,提示如下: 'cc1: error: unrecognized command line option "-munaligned-access"'

去掉-munaligned-access后,再用make指令编译,提示如下,感觉又回到了最初的情况: cd /third/TDengine/debug/src/os/src/detail && /usr/bin/cc -DLINUX -DUSE_LIBICONV -D_LIBC_REENTRANT -D_LINUX -D_REENTRANT -D_TD_LINUX -D_TD_LINUX_32 -D__USE_POSIX -g -std=gnu99 -Wall -Werror -fPIC -fsigned-char -unaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -O0 -g3 -DDEBUG -I/third/TDengine/deps/cJson/inc -I/third/TDengine/deps/lz4/inc -I/third/TDengine/src/inc -I/third/TDengine/src/os/inc -I/third/TDengine/src/util/inc -I/third/TDengine/src/common/inc -I/third/TDengine/src/os/src/detail/. -I/third/TDengine/deps/zlib-1.2.11/inc -o CMakeFiles/osdetail.dir/osSysinfo.c.o -c /third/TDengine/src/os/src/detail/osSysinfo.c /third/TDengine/src/os/src/detail/osSysinfo.c: In function ‘taosSetCoreDump’: /third/TDengine/src/os/src/detail/osSysinfo.c:593:24: error: storage size of ‘args’ isn’t known struct __sysctl_args args; ^ /third/TDengine/src/os/src/detail/osSysinfo.c:600:17: error: ‘CTL_KERN’ undeclared (first use in this function) int name[] = {CTL_KERN, KERN_CORE_USES_PID}; ^ /third/TDengine/src/os/src/detail/osSysinfo.c:600:17: note: each undeclared identifier is reported only once for each function it appears in /third/TDengine/src/os/src/detail/osSysinfo.c:600:27: error: ‘KERN_CORE_USES_PID’ undeclared (first use in this function) int name[] = {CTL_KERN, KERN_CORE_USES_PID}; ^ /third/TDengine/src/os/src/detail/osSysinfo.c:602:27: error: invalid application of ‘sizeof’ to incomplete type ‘struct __sysctl_args’ memset(&args, 0, sizeof(struct __sysctl_args)); ^ /third/TDengine/src/os/src/detail/osSysinfo.c:602:34: error: passing argument 3 of ‘memset’ makes integer from pointer without a cast [-Werror] memset(&args, 0, sizeof(struct __sysctl_args)); ^ In file included from /third/TDengine/src/os/inc/osLinux32.h:52:0, from /third/TDengine/src/os/inc/os.h:40, from /third/TDengine/src/os/src/detail/osSysinfo.c:17: /usr/include/string.h:66:14: note: expected ‘size_t’ but argument is of type ‘int *’ extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));

如果方便的话,是否能提供一个已经能编译通过的虚拟机环境给我,谢谢!

rainsh2021 avatar Mar 26 '21 01:03 rainsh2021

我就是用 docker pull ubuntu:14.04 然后 docker run  -dit ubuntu:14.04 再 docker exec -ti <docker id> bash,后面步骤前面提到的。都是官方镜像官方源,完全没有自己编译工具链

sangshuduo avatar Mar 26 '21 03:03 sangshuduo

我就是用 docker pull ubuntu:14.04 然后 docker run  -dit ubuntu:14.04 再 docker exec -ti bash,后面步骤前面提到的。都是官方镜像官方源,完全没有自己编译工具链 没有编译工具链,只是通过apt-get install指令安装cmake和g++两个工具,理论上不存在环境变更,其它没有配置过。如果和你现在编译结果存在差异,会不会是在docker环境中的ubuntu系统里有对环境调整过,能否把正在使用并能正常编译通过的ubuntu系统打成iso传到百度云盘上,我下载试试。确实是折腾了挺长时间还没有定位到问题,不得已出此下策,不知是否方便?

rainsh2021 avatar Mar 28 '21 15:03 rainsh2021

为什么要编译 2.0.5?我们只支持最新版本 和 develop 分支

sangshuduo avatar Apr 01 '21 10:04 sangshuduo

为什么要编译 2.0.5?我们只支持最新版本 和 develop 分支

sangshuduo avatar Apr 01 '21 10:04 sangshuduo

问题已经解决,详细过程可参考https://blog.csdn.net/stumer/article/details/115524036

rainsh2021 avatar Apr 08 '21 09:04 rainsh2021