Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译报错 #3

Open
jswlives opened this issue Sep 8, 2021 · 7 comments
Open

编译报错 #3

jswlives opened this issue Sep 8, 2021 · 7 comments

Comments

@jswlives
Copy link

jswlives commented Sep 8, 2021

这个实例项目是必须要C++20是吧,编译报错提示g++: error: unrecognized command line option ‘-fcoroutines’
升级gcc12就编译通过了

@owent
Copy link
Member

owent commented Sep 9, 2021

这个实例项目是必须要C++20是吧

不是。GCC 4.8以上,Clang 4以上,或VS2017以上带的MSVC都可以。

运行cmake的编译器和实际执行编译的编译器要保持一致。在cmake阶段会检测编译器功能。如果切换编译器要删除build目录里的CMakeCache.txt文件。否则某些检测的结果可能会被cmake认为未变化而不重新执行检测过程。

@jswlives
Copy link
Author

jswlives commented Sep 9, 2021

不太能理解你说的意思,我查了一下unrecognized command line option ‘-fcoroutines,说是需要C++20才能支持

@owent
Copy link
Member

owent commented Sep 9, 2021

不太能理解你说的意思,我查了一下unrecognized command line option ‘-fcoroutines,说是需要C++20才能支持

这个选项如果在执行cmake的阶段检查出来发现不支持就不会加。

https://github.com/atframework/libatapp/actions/runs/1119065097

https://github.com/atframework/atframe_utils/actions/runs/1197439868

有各类编译环境的CI检查。

@jswlives
Copy link
Author

jswlives commented Sep 9, 2021

明白你的意思了,诡异的是我这个报错是在执行cmake的时候报错的,就是 sh cmake_dev.sh的时候

@jswlives
Copy link
Author

jswlives commented Sep 9, 2021

我贴一下cmake第一个报错的地方

$>:sh  cmake_dev.sh     
error: unknown option `show-current'
usage: git branch [<options>] [-r | -a] [--merged | --no-merged]
   or: git branch [<options>] [-l] [-f] <branch-name> [<start-point>]
   or: git branch [<options>] [-r] (-d | -D) <branch-name>...
   or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
   or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>
   or: git branch [<options>] [-r | -a] [--points-at]
   or: git branch [<options>] [-r | -a] [--format]

Generic options
    -v, --verbose         show hash and subject, give twice for upstream branch
    -q, --quiet           suppress informational messages
    -t, --track           set up tracking mode (see git-pull(1))
    -u, --set-upstream-to <upstream>
                          change the upstream info
    --unset-upstream      Unset the upstream info
    --color[=<when>]      use colored output
    -r, --remotes         act on remote-tracking branches
    --contains <commit>   print only branches that contain the commit
    --no-contains <commit>
                          print only branches that don't contain the commit
    --abbrev[=<n>]        use <n> digits to display SHA-1s

Specific git-branch actions:
    -a, --all             list both remote-tracking and local branches
    -d, --delete          delete fully merged branch
    -D                    delete branch (even if not merged)
    -m, --move            move/rename a branch and its reflog
    -M                    move/rename a branch, even if target exists
    -c, --copy            copy a branch and its reflog
    -C                    copy a branch, even if target exists
    --list                list branch names
    -l, --create-reflog   create the branch's reflog
    --edit-description    edit the description for the branch
    -f, --force           force creation, move/rename, deletion
    --merged <commit>     print only branches that are merged
    --no-merged <commit>  print only branches that are not merged
    --column[=<style>]    list branches in columns
    --sort <key>          field name to sort on
    --points-at <object>  print only branches of the object
    -i, --ignore-case     sorting and filtering are case insensitive
    --format <format>     format to use for the output

-- Available Build Type: Unknown
-- Check Flag: -rdynamic -- yes
-- GCC Version 6.3.0 Found, -Wno-unused-local-typedefs added.
-- GCC Version 6.3.0 , using -std=c11/c++20.
-- Dependency(atf4g-co): zlib found.(/usr/lib/x86_64-linux-gnu/libz.so)
-- Dependency(atf4g-co): lz4 found target lz4::lz4_static
-- Dependency(atf4g-co): lz4 found exec: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/lz4
-- Dependency(atf4g-co): lz4 found exec: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/lz4c
-- Dependency(atf4g-co): zstd found target zstd::libzstd_static
-- Dependency(atf4g-co): zstd found exec: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/zstd
-- Dependency(atf4g-co): jemalloc using target jemalloc
-- Dependency(atf4g-co): libunwind found and using target: Libunwind::libunwind
-- Dependency(atf4g-co): xxHash using target xxHash::xxhash
-- Dependency(atf4g-co): libuv using target: libuv
-- Dependency(atf4g-co): Lua found target lua::liblua-static
-- Dependency(atf4g-co): fmtlib using target fmt::fmt-header-only
-- Dependency(atf4g-co): yaml-cpp using target yaml-cpp
-- RapidJSON found. Headers: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/lib/cmake/RapidJSON/../../../include
-- Dependency(atf4g-co): rapidjson using target: rapidjson
-- Dependency(atf4g-co): Target nlohmann_json::nlohmann_json found
-- Dependency(atf4g-co): Flatbuffer found.(/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/include)
-- Dependency(atf4g-co): openssl found.(1.1.1k)
-- hiredis using target: hiredis::hiredis_ssl_static
-- Patch: INTERFACE_LINK_LIBRARIES of hiredis::hiredis_ssl_static from "" to "hiredis::hiredis_static"
-- Dependency(atf4g-co): c-ares using target c-ares::cares
-- Dependency(atf4g-co): re2 using target re2::re2
-- Dependency(atf4g-co): libcurl found.(|)
-- Libcurl: use target CURL::libcurl
-- Dependency(atf4g-co): Protobuf found.(/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/protoc-3.17.3.0)
-- Dependency(atf4g-co): Protobuf libraries.(protobuf::libprotobuf/protobuf::libprotobuf-lite)
'/usr/local/bin/cmake' '../../../../third_party/packages/abseil-cpp-20210324.2' '-Wno-dev' '-DCMAKE_INSTALL_PREFIX=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-G' 'Ninja' '-DCMAKE_EXE_LINKER_FLAGS=-rdynamic' '-DCMAKE_MODULE_LINKER_FLAGS=-rdynamic' '-DCMAKE_SHARED_LINKER_FLAGS=-rdynamic' '-DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib/X11' '-DCMAKE_SYSTEM_VERSION=4.9.0-12-amd64' '-DCMAKE_FIND_ROOT_PATH=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE' '-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON' '-DCMAKE_AR=/usr/bin/ar' '-DCMAKE_RANLIB=/usr/bin/ranlib' '-DCMAKE_CXX_FLAGS_DEBUG=-g -ggdb' '-DCMAKE_CXX_FLAGS_RELEASE=-O3 -DNDEBUG' '-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG -ggdb' '-DCMAKE_CXX_FLAGS_MINSIZEREL=-Os -DNDEBUG' '-DCMAKE_CXX_COMPILER=/usr/bin/g++' '-DCMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/ccache' '-DCMAKE_CXX_IMPLICIT_LINK_LIBRARIES=stdc++\;m\;gcc_s\;gcc\;c' '-DCMAKE_CXX_STANDARD_LIBRARIES=-lm -ldl -lpthread -lrt -lgcc -lgcc_s' '-DCMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-6' '-DCMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-6' '-DCMAKE_POLICY_DEFAULT_CMP0091=NEW' '-DCMAKE_CXX_STANDARD=20' '-DCMAKE_FIND_ROOT_PATH=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-DCMAKE_PREFIX_PATH=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-DCMAKE_POSITION_INDEPENDENT_CODE=ON' '-DBUILD_TESTING=OFF' '-DBUILD_SHARED_LIBS=OFF'
-- The CXX compiler identification is GNU 6.3.0
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
CMake Error in absl/base/CMakeLists.txt:
  Target "malloc_internal" requires the language dialect "CXX20" (with
  compiler extensions), but CMake does not know the compile flags to use to
  enable it.

@owent
Copy link
Member

owent commented Sep 9, 2021

我贴一下cmake第一个报错的地方

$>:sh  cmake_dev.sh     
error: unknown option `show-current'
usage: git branch [<options>] [-r | -a] [--merged | --no-merged]
   or: git branch [<options>] [-l] [-f] <branch-name> [<start-point>]
   or: git branch [<options>] [-r] (-d | -D) <branch-name>...
   or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
   or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>
   or: git branch [<options>] [-r | -a] [--points-at]
   or: git branch [<options>] [-r | -a] [--format]

Generic options
    -v, --verbose         show hash and subject, give twice for upstream branch
    -q, --quiet           suppress informational messages
    -t, --track           set up tracking mode (see git-pull(1))
    -u, --set-upstream-to <upstream>
                          change the upstream info
    --unset-upstream      Unset the upstream info
    --color[=<when>]      use colored output
    -r, --remotes         act on remote-tracking branches
    --contains <commit>   print only branches that contain the commit
    --no-contains <commit>
                          print only branches that don't contain the commit
    --abbrev[=<n>]        use <n> digits to display SHA-1s

Specific git-branch actions:
    -a, --all             list both remote-tracking and local branches
    -d, --delete          delete fully merged branch
    -D                    delete branch (even if not merged)
    -m, --move            move/rename a branch and its reflog
    -M                    move/rename a branch, even if target exists
    -c, --copy            copy a branch and its reflog
    -C                    copy a branch, even if target exists
    --list                list branch names
    -l, --create-reflog   create the branch's reflog
    --edit-description    edit the description for the branch
    -f, --force           force creation, move/rename, deletion
    --merged <commit>     print only branches that are merged
    --no-merged <commit>  print only branches that are not merged
    --column[=<style>]    list branches in columns
    --sort <key>          field name to sort on
    --points-at <object>  print only branches of the object
    -i, --ignore-case     sorting and filtering are case insensitive
    --format <format>     format to use for the output

-- Available Build Type: Unknown
-- Check Flag: -rdynamic -- yes
-- GCC Version 6.3.0 Found, -Wno-unused-local-typedefs added.
-- GCC Version 6.3.0 , using -std=c11/c++20.
-- Dependency(atf4g-co): zlib found.(/usr/lib/x86_64-linux-gnu/libz.so)
-- Dependency(atf4g-co): lz4 found target lz4::lz4_static
-- Dependency(atf4g-co): lz4 found exec: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/lz4
-- Dependency(atf4g-co): lz4 found exec: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/lz4c
-- Dependency(atf4g-co): zstd found target zstd::libzstd_static
-- Dependency(atf4g-co): zstd found exec: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/zstd
-- Dependency(atf4g-co): jemalloc using target jemalloc
-- Dependency(atf4g-co): libunwind found and using target: Libunwind::libunwind
-- Dependency(atf4g-co): xxHash using target xxHash::xxhash
-- Dependency(atf4g-co): libuv using target: libuv
-- Dependency(atf4g-co): Lua found target lua::liblua-static
-- Dependency(atf4g-co): fmtlib using target fmt::fmt-header-only
-- Dependency(atf4g-co): yaml-cpp using target yaml-cpp
-- RapidJSON found. Headers: /home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/lib/cmake/RapidJSON/../../../include
-- Dependency(atf4g-co): rapidjson using target: rapidjson
-- Dependency(atf4g-co): Target nlohmann_json::nlohmann_json found
-- Dependency(atf4g-co): Flatbuffer found.(/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/include)
-- Dependency(atf4g-co): openssl found.(1.1.1k)
-- hiredis using target: hiredis::hiredis_ssl_static
-- Patch: INTERFACE_LINK_LIBRARIES of hiredis::hiredis_ssl_static from "" to "hiredis::hiredis_static"
-- Dependency(atf4g-co): c-ares using target c-ares::cares
-- Dependency(atf4g-co): re2 using target re2::re2
-- Dependency(atf4g-co): libcurl found.(|)
-- Libcurl: use target CURL::libcurl
-- Dependency(atf4g-co): Protobuf found.(/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu/bin/protoc-3.17.3.0)
-- Dependency(atf4g-co): Protobuf libraries.(protobuf::libprotobuf/protobuf::libprotobuf-lite)
'/usr/local/bin/cmake' '../../../../third_party/packages/abseil-cpp-20210324.2' '-Wno-dev' '-DCMAKE_INSTALL_PREFIX=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-G' 'Ninja' '-DCMAKE_EXE_LINKER_FLAGS=-rdynamic' '-DCMAKE_MODULE_LINKER_FLAGS=-rdynamic' '-DCMAKE_SHARED_LINKER_FLAGS=-rdynamic' '-DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib/X11' '-DCMAKE_SYSTEM_VERSION=4.9.0-12-amd64' '-DCMAKE_FIND_ROOT_PATH=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE' '-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON' '-DCMAKE_AR=/usr/bin/ar' '-DCMAKE_RANLIB=/usr/bin/ranlib' '-DCMAKE_CXX_FLAGS_DEBUG=-g -ggdb' '-DCMAKE_CXX_FLAGS_RELEASE=-O3 -DNDEBUG' '-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG -ggdb' '-DCMAKE_CXX_FLAGS_MINSIZEREL=-Os -DNDEBUG' '-DCMAKE_CXX_COMPILER=/usr/bin/g++' '-DCMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/ccache' '-DCMAKE_CXX_IMPLICIT_LINK_LIBRARIES=stdc++\;m\;gcc_s\;gcc\;c' '-DCMAKE_CXX_STANDARD_LIBRARIES=-lm -ldl -lpthread -lrt -lgcc -lgcc_s' '-DCMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-6' '-DCMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-6' '-DCMAKE_POLICY_DEFAULT_CMP0091=NEW' '-DCMAKE_CXX_STANDARD=20' '-DCMAKE_FIND_ROOT_PATH=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-DCMAKE_PREFIX_PATH=/home/shaowei/workspace/atsf4g-co/third_party/install/linux-x86_64-gnu' '-DCMAKE_POSITION_INDEPENDENT_CODE=ON' '-DBUILD_TESTING=OFF' '-DBUILD_SHARED_LIBS=OFF'
-- The CXX compiler identification is GNU 6.3.0
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
CMake Error in absl/base/CMakeLists.txt:
  Target "malloc_internal" requires the language dialect "CXX20" (with
  compiler extensions), but CMake does not know the compile flags to use to
  enable it.

我修订下构建系统。CI里没有gcc 6的环境。可能gcc 6下cmake自带的检测有点问题。我自己patch一下吧,感谢反馈。
用gcc 8以上或者gcc 4.8应该是没问题的。

@owent owent self-assigned this Sep 9, 2021
@jswlives jswlives closed this as completed Sep 9, 2021
@jswlives jswlives reopened this Sep 9, 2021
@jswlives
Copy link
Author

jswlives commented Sep 9, 2021

谢谢抽空解答,刚试了一下,确实还是有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants