0

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?

gekigek99
  • 303
  • 3
  • 17
  • What is the code you're trying to compile? – Adrian Apr 15 '20 at 20:47
  • @Adrian I've updated the question – gekigek99 Apr 15 '20 at 22:39
  • Code runs on linux. Might be related to problems with mingw installation? [See here](https://stackoverflow.com/questions/50847868/compiling-c-program-with-mingw-causes-cc1-exe-fatal-error) – Mark Apr 16 '20 at 07:05
  • @Mark I have installed gcc 64bit with yypkg-1.5.0 because with mingw it installed gcc 32bit and throwed an error about the missing of gcc 64bit (if needed I can reinstall the 32bit version and try again to tell the spscific error) – gekigek99 Apr 16 '20 at 12:34
  • 3
    The problem in the linked question was caused by a space in the path, eg, "c:\Program Files\..." and the solution was to reinstall to a path with no spaces. Could that be the problem for you? – Mark Apr 16 '20 at 12:59
  • @Mark wow thanks a lot now it works like a charm! If you write 2 lines as a solution I can upvote and set it as solution! – gekigek99 Apr 16 '20 at 21:54
  • @gekigek99 glad you got it working :-) – Mark Apr 20 '20 at 04:07

2 Answers2

3

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.

  • 1
    Same symptoms for me: compiled in Ubuntu 18, but error in Ubuntu 20. The fix was to remove duplicated `-o libname.so` argument. – Andrei Jun 08 '22 at 02:36
2

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.

Mark
  • 6,731
  • 1
  • 40
  • 38