https://github.com/xaionaro-go/pkg-config-wrapper
A wrapper for `pkg-config` to force static linking when needed
https://github.com/xaionaro-go/pkg-config-wrapper
build compile go golang libraries library link linking pkg-config pkgconfig static wrapper
Last synced: 9 days ago
JSON representation
A wrapper for `pkg-config` to force static linking when needed
- Host: GitHub
- URL: https://github.com/xaionaro-go/pkg-config-wrapper
- Owner: xaionaro-go
- License: cc0-1.0
- Created: 2024-10-11T18:41:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-13T15:15:41.000Z (over 1 year ago)
- Last Synced: 2025-02-02T03:17:39.959Z (over 1 year ago)
- Topics: build, compile, go, golang, libraries, library, link, linking, pkg-config, pkgconfig, static, wrapper
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
This is a minimalistic wrapper for `pkg-config` that allows to control which libraries should be linked dynamically or statically using two additional environment variables:
* `PKG_CONFIG_LIBS_FORCE_STATIC`
* `PKG_CONFIG_LIBS_FORCE_DYNAMIC`
Initially I had to implement this tool to make sure the CGo libraries I have as dependencies for my Android application are linked statically, because otherwise [it did not work](https://github.com/fyne-io/fyne/issues/5189).
# How to use
```sh
go install github.com/xaionaro-go/pkg-config-wrapper@latest
PKG_CONFIG_LIBS_FORCE_STATIC="libav*,libvlc" PKG_CONFIG="$(go env GOPATH | awk -F ':' '{print $1}')/bin/pkg-config" go build PATH/TO/MY/PROJECT
```
It works not only with Go, but also with anything that understands variable `PKG_CONFIG`.
# Example of the output
```
$ go run ./ --libs-only-l libavcodec
-lavcodec
```
vs:
```
$ PKG_CONFIG_LIBS_FORCE_STATIC=libav* go run ./ --libs-only-l libavcodec
-Wl,-Bstatic -lavcodec -lvpx -lm -lvpx -lm -lvpx -lm -lvpx -lm -lwebpmux -lm -latomic -llzma -laribb24 -ldav1d -ldavs2 -lopencore-amrwb -lrsvg-2 -lm -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lcairo -lzvbi -lpthread -lm -lpng -lz -lsnappy -lstdc++ -laom -lcodec2 -lfdk-aac -lgsm -lilbc -ljxl -ljxl_threads -lmp3lame -lm -lopencore-amrnb -lopenjp2 -lopus -lrav1e -lm -lshine -lspeex -lSvtAv1Enc -ltheoraenc -ltheoradec -logg -ltwolame -lvo-amrwbenc -lvorbis -lvorbisenc -lwebp -lx264 -lx265 -lxavs2 -lxvidcore -lopenh264 -lkvazaar -lz -lva -lvpl -ldl -lstdc++ -lswresample -lm -lsoxr -latomic -lva-drm -lva -lva-x11 -lva -lvdpau -lX11 -lgcrypt -lm -ldrm -lvpl -ldl -lstdc++ -lOpenCL -lssl -lcrypto -lva -latomic -lX11 -lavutil -lva-drm -lva -lva-x11 -lva -lvdpau -lX11 -lgcrypt -lm -ldrm -lvpl -ldl -lstdc++ -lOpenCL -lssl -lcrypto -lva -latomic -lX11
```