aleksi / cgo-by-example Goto Github PK
View Code? Open in Web Editor NEWNOT UPDATED FOR YEARS. How to mix C and Go with cgo
NOT UPDATED FOR YEARS. How to mix C and Go with cgo
Running make, "go vet" fails, I commented this line out, and get the following results.
gofmt -e -s -w .
cc -g -fPIC -c -o lib/lib.o lib/lib.c
cc -g -fPIC -shared -o liblib.so lib/lib.o
cc -g -fPIC -c wrapper/wrapper.c
LD_LIBRARY_PATH=. go run main.go
f0()
f1(5)
f1(8)
f2(Go string)
fmt: return f2(Go string)
f31: s1={5}, s1Ret={10}
f32: s1={10}, s1Ret={10}
s2={0xc20800014c}, *s2.p=8, i=8
f4: s2={0xc20800014c}, *s2.p=16, i=8
f1(0)
f1(1)
f1(2)
LD_LIBRARY_PATH=. go run main2.go
# command-line-arguments
ld: library not found for -llib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/usr/local/Cellar/go/1.3.3/libexec/pkg/tool/darwin_amd64/6l: running clang failed: unsuccessful exit status 0x100
make: *** [all] Error 2
I'm running go version go1.3.3 darwin/amd64
I just downloaded the Git source and ran make
:
gofmt -e -s -w .
go vet .
cc -g -fPIC -c -o lib/lib.o lib/lib.c
cc -g -fPIC -shared -o liblib.so lib/lib.o
LD_LIBRARY_PATH=. go run main.go
f0()
f1(5)
f1(8)
f2(Go string)
fmt: return f2(Go string)
f31: s1={5}, s1Ret={10}
f32: s1={10}, s1Ret={10}
s2={0xc82000a460}, _s2.p=8, i=8
f4: s2={0xc82000a460}, *s2.p=16, i=8
f1(0)
f1(1)
f1(2)
cp liblib.so wrapper/
LD_LIBRARY_PATH=. go run main2.go
main2.go:7:2: cannot find package "github.com/AlekSi/cgo-by-example/wrapper" in any of:
/usr/lib/golang/src/github.com/AlekSi/cgo-by-example/wrapper (from $GOROOT)
($GOPATH not set)
Makefile:2: recipe for target 'all' failed
make: *_\* [all] Error 1
Hello!
Could you add test for cgo.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.