C++ GCC:抱歉,未实现:64 位模式未编译

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8861105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 19:14:21  来源:igfitidea点击:

GCC: sorry, unimplemented: 64-bit mode not compiled in

c++gcc

提问by Martin

I have built GCC 4.7 on my x86 32-bit linux system. When I try to cross-compile with the -m64 flag I get the following:

我已经在我的 x86 32 位 linux 系统上构建了 GCC 4.7。当我尝试使用 -m64 标志进行交叉编译时,我得到以下信息:

sorry, unimplemented: 64-bit mode not compiled in

抱歉,未实现:64 位模式未编译

while the compiler provided by default by my Linux distribution can cross-compile with -m64.

而我的 Linux 发行版默认提供的编译器可以与 -m64 交叉编译。

What do I have to pass to ./configure to enable the 64bit mode in GCC? These are the options I used to build GCC 4.7:

我必须传递给 ./configure 才能在 GCC 中启用 64 位模式?这些是我用来构建 GCC 4.7 的选项:

$ /usr/local/bin/g++ -v Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ./configure --enable-multiarch --with-cloog=/usr/local/ --with-mpfr=/usr/local/ --with-ppl=/usr/local/ --verbose --enable-languages=c,c++
Thread model: posix gcc version 4.7.0 20120113 (experimental) (GCC)

EDIT:

编辑:

--enable-multilib and --enable-targets=i686-pc-linux-gnu,x86_64-pc-linux-gnu

--enable-multilib 和 --enable-targets=i686-pc-linux-gnu,x86_64-pc-linux-gnu

do not change the situation. The compiler still complains about 64 bit mode not compiled in:

不要改变这种情况。编译器仍然抱怨未编译为 64 位模式:

$ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: ./configure --enable-multiarch --with-cloog=/usr/local/ --with-mpfr=/usr/local/ --with-ppl=/usr/local/ --verbose --enable-languages=c,c++ --enable-multilib --enable-targets=i686-pc-linux-gnu,x86_64-pc-linux-gnu Thread model: posix gcc version 4.7.0 20120113 (experimental) (GCC)

$ g++ -m64 c.cpp c.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in

$ g++ -v 使用内置规范。COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper 目标:i686-pc-linux-gnu 配置:./configure --enable-multiarch - -with-cloog=/usr/local/ --with-mpfr=/usr/local/ --with-ppl=/usr/local/ --verbose --enable-languages=c,c++ --enable-multilib - -enable-targets=i686-pc-linux-gnu,x86_64-pc-linux-gnu 线程模型:posix gcc version 4.7.0 20120113 (experimental) (GCC)

$ g++ -m64 c.cpp c.cpp:1:0:抱歉,未实现:64 位模式未编译

采纳答案by rubenvb

You will need both binutils and gcc configured with:

您将需要 binutils 和 gcc 配置:

--enable-multilib

and probably:

并且可能:

--enable-targets=i686-pc-linux-gnu,x86_64-pc-linux-gnu

to support multilib (the -m64and/or -m32options). You'll also need two versions of stuff like glibc to be able to link and run the resulting binaries.

支持 multilib(-m64和/或-m32选项)。您还需要两个版本的东西,比如 glibc 才能链接和运行生成的二进制文件。

回答by Chand Priyankara

This typically means that you're using the wrong (old) compiler.

这通常意味着您使用了错误的(旧的)编译器。

The new compilers support both -m32 and -m64. You have to set the PATH to the new compilers (in the gcc,MinGW subdirectory of Rtools) beforeany old compilers in Rtools.

新编译器同时支持 -m32 和 -m64。您必须在 Rtools 中的任何旧编译器之前将 PATH 设置为新编译器(在 Rtools 的 gcc,MinGW 子目录中)。

Try updating your compiler's binary lib path to 64bit version. Other resources like lib folders also should change accordingly.

尝试将编译器的二进制库路径更新为 64 位版本。其他资源(如 lib 文件夹)也应相应更改。

回答by Vishruit Kulshreshtha

Just resolved this issue. In the environment variables, remove the entries to any outdated c++ package.

刚刚解决了这个问题。在环境变量中,删除任何过时的 c++ 包的条目。

In my case, I worked in Anaconda on Windows 64-bit. In anaconda, I performed 'conda install mingw libpython'. Mingw is for c++ compiler. But I had earlier installed cygwin's mingw for c++ compilations which hadn't been updated. This is the reason for conflict. I resolved this issue by simply removing the environment variable (PATH) corresponding to these c++ packages.
I have tried almost all forums, this solution works.

就我而言,我在 64 位 Windows 上使用 Anaconda。在 anaconda 中,我执行了“conda install mingw libpython”。Mingw 用于 C++ 编译器。但是我之前为尚未更新的 c++ 编译安装了 cygwin 的 mingw。这就是冲突的原因。我通过简单地删除与这些 c++ 包对应的环境变量 (PATH) 解决了这个问题。
我已经尝试了几乎所有论坛,这个解决方案有效。

Please let me know in case anyone needs help. :)

如果有人需要帮助,请告诉我。:)

回答by eee

Had the same issues. My solution:

有同样的问题。我的解决方案:

Update everything (R, Rstudio, R packages) and close Rstudio.
Uninstall Rtools and install the latest version.
Add only 2 entries under Enviroment Variables/System variables/Path:
- C:\Rtools\bin
- C:\Rtools\mingw_64\bin (!not the 32bit version)
Path entries have to be in this order and above %SystemRoot\System32
I did NOT install in the strongly recommended default location on C:

更新所有内容(R、Rstudio、R 包)并关闭 Rstudio。
卸载 Rtools 并安装最新版本。
仅在环境变量/系统变量/路径下添加 2 个条目:
- C:\Rtools\bin
- C:\Rtools\mingw_64\bin(!不是 32 位版本)
路径条目必须按此顺序以及 %SystemRoot\System32 以上
我没有安装在 C 上强烈推荐的默认位置:

After that open Rstudio and re-install Rcpp via console:
install.packages("Rcpp")

之后打开 Rstudio 并通过控制台重新安装 Rcpp:
install.packages("Rcpp")

Test if it's working with:
Rcpp::evalCpp("2+2")

测试它是否适用于:
Rcpp::evalCpp("2+2")

After that just switch to the Terminal in Rstudio, go into the cmdstan source folder and type 'make build'.
--- CmdStan v2.19.1 built ---
Done!

之后只需切换到 Rstudio 中的终端,进入 cmdstan 源文件夹并键入“make build”。
--- CmdStan v2.19.1 构建 ---
完成!

Details:

细节:

*> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=Slovenian_Slovenia.1250  LC_CTYPE=Slovenian_Slovenia.1250    LC_MONETARY=Slovenian_Slovenia.1250 LC_NUMERIC=C                       
[5] LC_TIME=Slovenian_Slovenia.1250    
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0*