Cgo: sorry, unimplemented: 64-bit mode not compiled in
Asked Answered
S

6

26

I'm currently trying to add some C code to my Go project. nothing fancy

/*
#include <stdio.h>
void test() {
    printf("hooola")
}
*/

import (
    "C"
)

func MessageBox() {
    C.test()
}

However this will return

cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

I checked my g++ and gcc compilers and everything seems fine, g++ -v returns this

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)

While gcc --version returns this

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.

Both installed using mingw64bits so I am not sure where my problem is coming from?

Shamanism answered 4/10, 2016 at 23:16 Comment(1)
What is the output of gcc -v It seems that the gcc version is too old compared to g++. Probably you have multiple gcc installation.Halima
B
44
  1. Short Answer:
    I tried many versions, the Only working version for both 32-bit and 64-bit go build in 64-bit Windows OS is tdm64-gcc-5.1.0-2.exe (see the tdm-gcc page).
    You may install it to C:\TDM-GCC-64\ and add C:\TDM-GCC-64\bin to your PATH (on top = or left).

  1. You may try MinGW-w64 - for 32 and 64-bit Windows Or x64-4.8.1-release-posix-seh-rev5.
    This versions works fine just for the 64-bit build (not 32-bit target on 64-bit OS).

  1. For Windows OS run your command prompt: cmd (terminal in Linux) then run this command (whereis gcc in Linux):

    where gcc
    

    Then if there are multiple gcc paths, then you may edit the order of these and put the one you need in the top or remove all others.


  1. See:

I hope this helps.

Bonniebonns answered 5/10, 2016 at 6:48 Comment(0)
Y
6

Downloading the latest TDM-GCC-64 release worked for me! Make sure to add C:\TDM-GCC-64\bin to PATH Environmental Variable.

Yamamoto answered 1/4, 2022 at 1:53 Comment(0)
V
0

what worked for me was installing the 64 bit version of mingw adding it to PATH and then removing all other mingw's from PATH and then very important RESTARTING THE COMPUTER, you have to restart your computer.

Vasiliu answered 5/9, 2019 at 8:12 Comment(0)
P
0

Good answer, but what confused me is the MinGW-w64 installer choose the Architecture i686 by default instead of x

Physical answered 8/3, 2020 at 12:21 Comment(0)
W
0

This problem comes from the compilers: gcc and g++ old versions(6.2.x). Update your gcc and g++ using MinGW installer from here (make sure you are downloading mingw-w32 for 32-bit, mingw-w64 for 64-bit) restart your PC and check for your versions to be 11.^. This worked for me.

Wiegand answered 9/10, 2021 at 11:25 Comment(1)
Please add link to software provider. Direct link to sourceforge is not best option.Substantialize
G
0

In my case the CC environment variable was pointing to the old 32-bit GCC. Check with go env CC, where it is pointing.

Then either change it in the system environment variables or use go env -w CC=path to GCC -- this did not work in my case and I had to change it on OS level. Do not forget to close the terminal and re-open it after the environment variable change.

Ghats answered 4/9, 2022 at 13:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.