Cgo Compilation Error: "64-bit mode not compiled in"
When attempting to integrate C code into a Go project, you may encounter the error "sorry, unimplemented: 64-bit mode not compiled in." This issue arises when the compiler used to compile the C code doesn't support 64-bit mode.
To resolve this error, you need to ensure that you have installed a compatible compiler with 64-bit support. The suggested options include:
1. TDM-GCC-5.1.0-2.exe:
This version is highly recommended for both 32-bit and 64-bit Go builds running on 64-bit Windows OS. Install it in a directory such as "C:TDM-GCC-64" and include "C:TDM-GCC-64bin" at the beginning of your PATH environment variable.
2. MinGW-w64:
This option works well for both 32-bit and 64-bit Windows.
3. x64-4.8.1-release-posix-seh-rev5:
This version is specifically suited for 64-bit Go builds on 64-bit Windows OS.
Once you have installed the appropriate compiler, be sure to update your PATH environment variable to ensure that the compiler is used for Cgo compilation. Additionally, you should check the output of the "where gcc" command in a command prompt to verify that the correct compiler is selected.
By following these steps, you can successfully resolve the "64-bit mode not compiled in" error and integrate C code into your Go project.
The above is the detailed content of How to Fix '64-bit mode not compiled in' Cgo Compilation Error?. For more information, please follow other related articles on the PHP Chinese website!