Comments (5)
Sorry, I'm not quite sure what you mean by this. If you build with lilliput, the Go binary you get should only link libc dynamically presently. Can you give me more specific information on what isn't static in your situation?
from lilliput.
I should have added more information. Specifically I'm trying this:
Let's say this is my main.go file:
package main
import (
"github.com/discordapp/lilliput"
)
func main() {
// just so we can import lilliput...
lilliput.NewDecoder(nil)
}
I'm trying to build a static binary like this:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w -extldflags "-static"' main.go
(I did try other command lines, with and without a bunch of these flags; did not find a definitive source of truth for how to do this.)
And then I'm getting these errors during compilation:
# github.com/discordapp/lilliput
../../../github.com/discordapp/lilliput/lilliput.go:26:13: undefined: ImageHeader
../../../github.com/discordapp/lilliput/lilliput.go:41:14: undefined: Framebuffer
../../../github.com/discordapp/lilliput/lilliput.go:48:12: undefined: Framebuffer
../../../github.com/discordapp/lilliput/ops.go:43:16: undefined: Framebuffer
With the C/C++ libraries being used by lilliput, I was doubting that it would be possible to create a fully statically linked binary (without too much effort), so that's why I thought I would ask here if there is a way.
Hope this makes more sense now!
Thanks!
from lilliput.
Ah, I see. Sounds like you are trying to get around including libc then.
To me, the idea of a unix system without libc sounds like madness. But I gather Docker tends to do things in strange ways. If you really want to do this, you'll need to build each of the libs packaged with lilliput with static libc linkage. This is going to require going through each step in the build-deps-linux.sh
file and changing the config to using your chosen libc. You'll need to dig around and find out how people have built OpenCV and ffmpeg with static libc, amongst the other various deps here. And then on top of that, as you've done, you need to convince Go itself not to use its bits that depend on a shared libc like the networking portions (e.g. use netgo). (If you're getting the impression that no sane system would ever omit libc... you are correct).
I don't know that you'll actually need the bit about ldflags - I think once you've made these changes, you'll be set. CGO_ENABLED=0 is basically nonsense in this context since it disables Go's ability to build C and C++.
Good luck, and let me know if you have other questions on the way.
from lilliput.
Actually, after reading a bit more, it seems what that bit with ldflags is trying to do is pass -static to Cgo. That definitely won't work here on its own since so many deps are already built targeting dynamic libc, but it does point to a good place to start. If you just add -static to CFLAGS in build-deps-linux.sh
, that might just work. And you will actually need -ldflags '-w -extldflags "-static"'
for lilliput, since the small amount of binding here uses some libc as well.
from lilliput.
yes just do
GOOS=linux GOARCH=amd64 go build -ldflags '-w -s -extldflags "-static"' -a -installsuffix cgo -o main
and it should work
from lilliput.
Related Issues (20)
- APNG support HOT 4
- WebP animated support HOT 7
- Unreachable code in thumbhash_encoder_create function
- Segfaults when `go-fitz` is imported
- ld: library not found for -lsharpyuv HOT 2
- Dockerfile Example HOT 1
- Getting error in building library
- The effect of Discord increasingly relying on rust on this project HOT 2
- Couldnt build lilliput HOT 2
- Can not build the lib HOT 4
- PNG compression algorithm causing desaturation
- Please add sample for Audio support
- Some .gifs are incorrectly "smearing"
- go get error HOT 3
- Not possible to cross compile
- Compile warning on Ubuntu 20.04.2 LTS HOT 4
- PNG compression - larger then before HOT 2
- ARM support (Apple M1) HOT 4
- Apple M1 issues HOT 2
- Versions not picked up by pkg.go.dev
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lilliput.