Hello,
I struggle to understand why this simple cgo program does not get linked, I
would provide example in playground, but it does not seem to support cgo.
```
package main
// #include <stdio.h>
//
// extern int go_test_func(int c1, int c2);
//
// int c_test_func(int c1, int c2)
// {
// return go_test_func(c1,c2);
// }
import "C"
import (
"fmt"
)
//export go_test_func
func go_test_func(c1, c2 C.int) C.int {
return c1 + c2
}
func main() {
fmt.Printf("Result: %d\n", C.c_test_func(2, 2))
}
```
I am getting:
# command-line-arguments
/sw/packages/xr/go/1.19.4/pkg/tool/linux_amd64/link: running gcc failed: exit
status 1
/tmp/go-link-349950461/000001.o: In function `c_test_func':
/nobackup/sbezverk/projects/go/worspace/cgo_test/cgo.go:9: multiple definition
of `c_test_func'
/tmp/go-link-349950461/000000.o:/tmp/go-build/cgo.go:9: first defined here
collect2: error: ld returned 1 exit status
Thank you
Serguei
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/15C0C308-7287-4165-A328-8396B6E90F63%40gmail.com.