【问题标题】:Code Wont Build On Different Machine With Same OS And Compiler代码不会在具有相同操作系统和编译器的不同机器上构建
【发布时间】:2021-02-24 21:30:29
【问题描述】:

我似乎找不到关于这个错误的太多信息。我有一个 C++ 代码库,我交给我的教授,它有一个构建脚本,可以安装柯南,然后安装柯南的依赖项。我最初在 Windows 上编写了代码库,但它在 github 上的 ubuntu:latest CI 上运行良好。它在我的本地机器上的ubuntu:latest docker 容器中也可以正常工作,我也将它移植过来。我的本地 docker 容器说它是ubuntu 20.04。我的教授有一个ubuntu 20.04 和一个ubuntu 20.10,都得到同样的错误,这是他们的构建日志

$ cmake --version                                                        
cmake version 3.16.3
9:03
$ gcc --version                                                          
gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
9:03
$ conan --version                                                        
Conan version 1.33.1
9:04
$ ./build.sh                                                              
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=10
os=Linux
os_build=Linux
[options]
[build_requires]
[env]conanfile.txt: Installing package
Requirements
   boost/1.75.0 from 'conan-center' - Cache
   bzip2/1.0.8 from 'conan-center' - Cache
   catch2/2.13.4 from 'conan-center' - Cache
   libiconv/1.16 from 'conan-center' - Cache
   nlohmann_json/3.9.1 from 'conan-center' - Cache
   openssl/1.1.1i from 'conan-center' - Cache
   zlib/1.2.11 from 'conan-center' - Cache
Packages
   boost/1.75.0:91068d6d6067a809e746602e9538e15eddb14457 - Cache
   bzip2/1.0.8:91a8b22c2c5a149bc617cfc06cdd21bf23b12567 - Cache
   catch2/2.13.4:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
   libiconv/1.16:19729b9559f3ae196cad45cb2b97468ccb75dcd1 - Cache
   nlohmann_json/3.9.1:d1091b2ed420e6d287293709a907ae824d5de508 - Cache
   openssl/1.1.1i:19729b9559f3ae196cad45cb2b97468ccb75dcd1 - Cache
   zlib/1.2.11:19729b9559f3ae196cad45cb2b97468ccb75dcd1 - CacheInstalling (downloading, building) binaries...
bzip2/1.0.8: Already installed!
catch2/2.13.4: Already installed!
libiconv/1.16: Already installed!
libiconv/1.16: Appending PATH environment var: .conan/data/libiconv/1.16/_/_/package/19729b95
59f3ae196cad45cb2b97468ccb75dcd1/bin                                                                         
nlohmann_json/3.9.1: Already installed!
openssl/1.1.1i: Already installed!
zlib/1.2.11: Already installed!
boost/1.75.0: Already installed!
boost/1.75.0: WARN: Picked up a system libbacktrace library
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generator cmake created conanbuildinfo.cmake
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: workspace/Spring2021/Capstone/Project1Grading/project/build
-- Conan: Compiler GCC>=5, checking major version 10
-- Conan: Checking correct version: 10
-- Configuring done
-- Generating done
-- Build files have been written to: workspace/Spring2021/Capstone/Project1Grading/project/build
make[1]: Entering directory 'workspace/Spring2021/Capstone/Project1Grading/project/build'
make[2]: Entering directory 'workspace/Spring2021/Capstone/Project1Grading/project/build'
Scanning dependencies of target tests
make[2]: Leaving directory 'workspace/Spring2021/Capstone/Project1Grading/project/build'
make[2]: Entering directory 'workspace/Spring2021/Capstone/Project1Grading/project/build'
[ 14%] Building CXX object CMakeFiles/tests.dir/Source/Connect.cpp.o
In file included from .conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15edd
b14457/include/boost/asio/ssl/rfc2818_verification.hpp:26,
                from .conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15edd
b14457/include/boost/asio/ssl.hpp:21,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/LoadRootCertificate.hpp:13,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/Connect.hpp:26,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/Connect.cpp:16:
.conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15eddb14457/include/boost/a
sio/detail/push_options.hpp:82:12: error: ‘#pragma’ is not allowed here
  82 | #  pragma GCC visibility push (default)
     |           ^~~
In file included from .conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15edd
b14457/include/boost/asio/ssl/rfc2818_verification.hpp:92,
                from .conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15edd
b14457/include/boost/asio/ssl.hpp:21,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/LoadRootCertificate.hpp:13,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/Connect.hpp:26,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/Connect.cpp:16:
.conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15eddb14457/include/boost/a
sio/detail/pop_options.hpp:74:27: warning: no matching push for ‘#pragma GCC visibility pop’ [-Wpragmas]
  74 | #  pragma GCC visibility pop
     |                          ^~~
In file included from .conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15edd
b14457/include/boost/asio/ssl/rfc2818_verification.hpp:95,
                from .conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15edd
b14457/include/boost/asio/ssl.hpp:21,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/LoadRootCertificate.hpp:13,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/Connect.hpp:26,
                from workspace/Spring2021/Capstone/Project1Grading/project
/Source/Connect.cpp:16:
.conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15eddb14457/include/boost/a
sio/ssl/impl/rfc2818_verification.ipp:34:6: error: ‘rfc2818_verification’ has not been declared
  34 | bool rfc2818_verification::operator()(
     |     ^~~~~~~~~~~~~~~~~~~~
.conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15eddb14457/include/boost/a
sio/ssl/impl/rfc2818_verification.ipp:35:44: error: non-member function ‘bool boost::asio::ssl::operator()(bo
ol, boost::asio::ssl::verify_context&)’ cannot have cv-qualifier
  35 |    bool preverified, verify_context& ctx) const
     |                                           ^~~~~
.conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15eddb14457/include/boost/a
sio/ssl/impl/rfc2818_verification.ipp:34:6: error: ‘bool boost::asio::ssl::operator()(bool, boost::asio::ssl:
:verify_context&)’ must be a nonstatic member function
  34 | bool rfc2818_verification::operator()(
     |     ^~~~~~~~~~~~~~~~~~~~
.conan/data/boost/1.75.0/_/_/package/91068d6d6067a809e746602e9538e15eddb14457/include/boost/a
sio/ssl/impl/rfc2818_verification.ipp:126:6: error: ‘rfc2818_verification’ has not been declared
 126 | bool rfc2818_verification::match_pattern(const char* pattern,
     |     ^~~~~~~~~~~~~~~~~~~~

我确实发现我在使用gcc 9.3.0,而他们正在使用gcc 10.2.0,所以我更新了,更改了柯南配置文件,删除了构建文件,在容器上重新安装了deps和所有东西,它仍然可以构建。

如您所见,它在boost::asio 头文件中出现error: ‘#pragma’ is not allowed 错误。我真的不确定 github 和本地 docker 使用相同版本的 Ubuntu 构建良好的问题是什么。 GCC、cmake 和柯南也一样。我真的很困惑。我确实知道一些部门使用 glibc 和一些使用 newlib,从他告诉我的情况来看,他们似乎确实更新了他们的柯南个人资料,那里可能有问题吗?他们安装 GCC 会不会有问题?非常感谢任何帮助!

【问题讨论】:

    标签: c++ ubuntu boost conan


    【解决方案1】:

    在一个肢体上,可能是您在语法上无法做到这一点的地方包含了一个 boost 标头,例如:

    struct X {
        int a, b, c;
        void foo() {
            /* lot's of code
            */
    
        }
    
    
     // OOPS forgot closing }; for the struct
     #include <boost/optional.hpp>
    

    那里的包含会导致这些错误。

    【讨论】:

    • 感谢您的回答,不幸的是我没有这门课了,所以我不能让他测试它,我可能有点吹掉了 repo 什么的。
    • 请随意删除此问题,因为它在未来对其他人没有任何帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多