我目前正在尝试为Go项目添加一些C代码。没有什么花哨的
/*
#include <stdio.h>
void test() {
printf("hooola")
}
*/
import (
"C"
)
func MessageBox() {
C.test()
}
然而,这将返回
cc1.exe:抱歉,未实现:64位模式未编译
我检查了我的g++
和gcc
编译器,一切似乎都很好,g++ -v
会返回此
C:\Users\ragga>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-6.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-6.2.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw620/x86_64-620-posix-seh-rt_v5-rev1/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-isl-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw620/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev1, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw620/x86_64-620-posix-seh-rt_v5-rev1/mingw64/opt/include -I/c/mingw620/prerequisites/x86_64-zlib-static/include -I/c/mingw620/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw620/x86_64-620-posix-seh-rt_v5-rev1/mingw64/opt/include -I/c/mingw620/prerequisites/x86_64-zlib-static/include -I/c/mingw620/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw620/x86_64-620-posix-seh-rt_v5-rev1/mingw64/opt/lib -L/c/mingw620/prerequisites/x86_64-zlib-static/lib -L/c/mingw620/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 6.2.0 (x86_64-posix-seh-rev1, Built by MinGW-W64 project)
gcc --version
会返回此
g:\Workspace\Go\src\github.com\raggaer\snak>gcc --version
gcc (GCC) 4.8.1
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.
两者都使用mingw64bits安装,所以我不确定我的问题来自哪里?
答案 0 :(得分:14)
1-简答:
我尝试了很多版本,64位Widows操作系统中32位和64位go build
的唯一工作版本是tdm64-gcc-5.1.0-2.exe
您可以将其安装到C:\TDM-GCC-64\
并将C:\TDM-GCC-64\bin
添加到PATH
(在顶部=或左侧)。
2-您可以尝试MinGW-w64 - for 32 and 64 bit Windows
或x64-4.8.1-release-posix-seh-rev5。
此版本仅适用于64位版本(64位操作系统上不是32位目标)。
3-对于Windows操作系统,运行命令提示符:cmd
(Linux中的终端)然后运行此命令(Linux中为whereis gcc
):
where gcc
然后,如果有多个gcc路径,那么您可以编辑这些路径的顺序并将您需要的路径放在顶部或删除所有其他路径。
4-见:
Differences between Mingw-w64 and TDM-GCC for a simple GDI project
What is the difference between Orwell's MinGW and TDM Dev-C++ versions?
我希望这会有所帮助。
答案 1 :(得分:0)
对我有用的是安装64位版本的mingw,将其添加到PATH,然后从PATH中删除所有其他mingw,然后非常重要的重新启动计算机,您必须重新启动计算机。
答案 2 :(得分:0)
好的答案,但令我困惑的是MinGW-w64安装程序默认选择Architecture i686而不是x