<i id='o7RLh'><tr id='o7RLh'><dt id='o7RLh'><q id='o7RLh'><span id='o7RLh'><b id='o7RLh'><form id='o7RLh'><ins id='o7RLh'></ins><ul id='o7RLh'></ul><sub id='o7RLh'></sub></form><legend id='o7RLh'></legend><bdo id='o7RLh'><pre id='o7RLh'><center id='o7RLh'></center></pre></bdo></b><th id='o7RLh'></th></span></q></dt></tr></i><div id='o7RLh'><tfoot id='o7RLh'></tfoot><dl id='o7RLh'><fieldset id='o7RLh'></fieldset></dl></div>
<legend id='o7RLh'><style id='o7RLh'><dir id='o7RLh'><q id='o7RLh'></q></dir></style></legend>
    <tfoot id='o7RLh'></tfoot>

      • <bdo id='o7RLh'></bdo><ul id='o7RLh'></ul>

      <small id='o7RLh'></small><noframes id='o7RLh'>

        对 `__stack_chk_fail' 的未定义引用

        时间:2023-09-19
          • <i id='MlZdP'><tr id='MlZdP'><dt id='MlZdP'><q id='MlZdP'><span id='MlZdP'><b id='MlZdP'><form id='MlZdP'><ins id='MlZdP'></ins><ul id='MlZdP'></ul><sub id='MlZdP'></sub></form><legend id='MlZdP'></legend><bdo id='MlZdP'><pre id='MlZdP'><center id='MlZdP'></center></pre></bdo></b><th id='MlZdP'></th></span></q></dt></tr></i><div id='MlZdP'><tfoot id='MlZdP'></tfoot><dl id='MlZdP'><fieldset id='MlZdP'></fieldset></dl></div>

          • <legend id='MlZdP'><style id='MlZdP'><dir id='MlZdP'><q id='MlZdP'></q></dir></style></legend>

            1. <small id='MlZdP'></small><noframes id='MlZdP'>

            2. <tfoot id='MlZdP'></tfoot>
                <tbody id='MlZdP'></tbody>

                • <bdo id='MlZdP'></bdo><ul id='MlZdP'></ul>
                  本文介绍了对 `__stack_chk_fail' 的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  编译 C++ 代码时出现此错误:

                  Getting this error while compiling C++ code:

                  undefined reference to `__stack_chk_fail'
                  

                  已经尝试过的选项:

                  1. 在编译时添加了 -fno-stack-protector - 不起作用,错误仍然存​​在
                  2. 在我的代码中添加了 void __stack_chk_fail(void) 的虚拟实现.仍然出现同样的错误.

                  详细错误:

                  /u/ac/alanger/gurobi/gurobi400/linux64/lib/libgurobi_c++.a(Env.o)(.text+0x1034): In function `GRBEnv::getPar/u/ac/alanger/gurobi/gurobi400/linux64/lib/libgurobi_c++.a(Env.o)(.text+0x1034): In function `GRBEnv::getParamInfo(GRB_StringParam, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
                  : undefined reference to `__stack_chk_fail'
                  amInfo(GRB_StringParam, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
                  : **undefined reference to `__stack_chk_fail'**
                  

                  早些时候,我收到了 10 个这样的错误.发现我使用的预编译库的 gcc 和我用来编译代码的 gcc 版本之间存在版本不匹配.更新了 gcc,现在我只收到了其中的 2 个错误.

                  Earlier, I was getting 10's of such errors. Found out that there was a version mismatch between the gcc of the pre-compiled libraries I am using and the gcc version I was using to compile the code. Updated gcc and now I am getting only 2 of these errors.

                  有什么帮助吗?

                  推荐答案

                  libgurobi_c++.a 是用 -fno-stack-protector 编译的(显然).

                  libgurobi_c++.a was compiled with -fno-stack-protector (obviously).

                  想到一些事情:

                  1. 在链接时添加 -fstack-protector.这将确保 libssp 被链接.
                  2. 手动链接-lssp
                  3. 在它自己的目标文件中制作 __stack_chk_fail(void) 的虚拟版本,然后将此 .o 文件添加到您的链接器命令 AFTER libgurobi_c++.a.GCC/G++ 在链接期间从左到右解析符号,因此尽管您的代码定义了函数,但包含 __stack_chk_fail 符号的对象的副本需要位于 libgurobi_c++.a 右侧的链接器行上.
                  1. add -fstack-protector when linking. This will make sure that libssp gets linked.
                  2. Manually link -lssp
                  3. Make your dummy version of __stack_chk_fail(void) in it's own object file and and add this .o file to your linker command AFTER libgurobi_c++.a. GCC/G++ resolves symbols from left to right during linking so despite your code having the function defined, a copy of an object containing the __stack_chk_fail symbol needs to be on the linker line to the right of libgurobi_c++.a.

                  这篇关于对 `__stack_chk_fail' 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么增强的 GCC 6 优化器会破坏实用的 C++ 代码 下一篇:从 char** 到 const char** 的隐式转换

                  相关文章

                  最新文章

                      <bdo id='iXT6q'></bdo><ul id='iXT6q'></ul>
                    <tfoot id='iXT6q'></tfoot>
                    <legend id='iXT6q'><style id='iXT6q'><dir id='iXT6q'><q id='iXT6q'></q></dir></style></legend>
                    <i id='iXT6q'><tr id='iXT6q'><dt id='iXT6q'><q id='iXT6q'><span id='iXT6q'><b id='iXT6q'><form id='iXT6q'><ins id='iXT6q'></ins><ul id='iXT6q'></ul><sub id='iXT6q'></sub></form><legend id='iXT6q'></legend><bdo id='iXT6q'><pre id='iXT6q'><center id='iXT6q'></center></pre></bdo></b><th id='iXT6q'></th></span></q></dt></tr></i><div id='iXT6q'><tfoot id='iXT6q'></tfoot><dl id='iXT6q'><fieldset id='iXT6q'></fieldset></dl></div>

                    1. <small id='iXT6q'></small><noframes id='iXT6q'>