I am trying to import and use C package but I keep getting this error:
# runtime/cgo
cc1.exe: error: too many filenames given. Type cc1.exe --help for usage
cc1.exe: fatal error: Files/Win-builds/include: No such file or directory
compilation terminated.
exit status 2
Process exiting with code: 1
this is the code:
package main
import (
"C"
"fmt"
"unsafe"
)
func main() {
c := 1
var Cvar C.int = 1
cup := unsafe.Pointer(&c)
cbyte := C.GoBytes(cup, Cvar)
fmt.Printf("%x", cbyte)
}
I searched everywhere on internet but couldn't find any solution.
On windows 64 bit:
> gcc --version
gcc (GCC) 4.8.3
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.
> go version
go version go1.14 windows/amd64
Is there a way to solve the issue?
A similar problem was caused by a space in the mingw installation path, eg, "c:\Program Files...". The solution in that case was to reinstall to a path with no spaces.
I have similar problem with C++ and ninja on UBUNTU 20.04
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: ALIGNMENT/CMakeFiles/ALIGNMENT_0.12_svg.dir/home/data/SCC/__public_git/Processing2C/PROJECTS/ALIGNMENT/cppsrc/project_at_once.cpp.d: No such file or directory
compilation terminated.
The problem was very strange. But the solution was simple! I need to change "-o3" into "-O3" in my CMakeLists.txt (worked well under UBUNTU 18.04) and it comes to work in UBUNTU 20.04.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.