Home > OS >  Go cross compiled program, on the arm can not perform the line 1: the syntax error: word unexpected
Go cross compiled program, on the arm can not perform the line 1: the syntax error: word unexpected

Time:11-08

Compile command: GOOS=Linux GOARCH=arm GOARM=7 go build hello. Go
After successful compilation on the arm, according to the line 1: the syntax error: word unexpected (expecting ") ")
Another cross compiled C language program can run normally, two readelf as shown below, which under the guidance of the great god why

An executable program:
The ELF Header:
Magic: 7 f 45 4 c 46 01, 02 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2 's complement, big endian
Version: 1 (current)
OS/ABI: UNIX System V -
ABI Version: 0
Type: the EXEC (Executable file)
Machine: ARM
Version: 0 x1
Entry point address: 0 xe0e0
The Start of the program headers: 52 (bytes into the file)
The Start of section headers: 36403244 bytes into the file ()
Flags: 0 x5800002, from the entry point, Version5 EABI, BE8
The Size of this header: 52 (bytes)
The Size of the program headers: 32 (bytes)
Number of program headers: 10
The Size of section headers: 40 (bytes)
Number of section headers: 42
A Section header string table index: 39

Program execution error:
The ELF Header:
Magic: 7 f 45 4 c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2 's complement, little endian
Version: 1 (current)
OS/ABI: UNIX System V -
ABI Version: 0
Type: the EXEC (Executable file)
Machine: ARM
Version: 0 x1
Entry point address: 0 x5f0a0
The Start of the program headers: 52 (bytes into the file)
The Start of section headers: 276 bytes into the file ()
Flags: 0 x5000002, from the entry point, Version5 EABI
The Size of this header: 52 (bytes)
The Size of the program headers: 32 (bytes)
Number of program headers: 7
The Size of section headers: 40 (bytes)
Number of section headers: 24
A Section header string table index: 3

CodePudding user response:

Suggest that 1. The go demo, try. 2. Don't go the demo contains the characteristic of CGO, i.e. not try call C functions, 3. Try using development version 4. Make sure your bat CPUt architecture, using GOARM=7 right?

CodePudding user response:

reference 1/f, maverick cat a reply:
advice, 1. The go demo, try. 2. Don't go the demo contains the characteristic of CGO, i.e. not try call C functions, 3. Try using development version 4. Make sure your board CPUt architecture, using GOARM=7 right?
thanks to reply, the demo program is very simple, did not include c calls, is GOARM this parameter represents the specific meaning, please? Didn't check the related description, in addition I am using the arm architecture (a8,
  • Related