https://github.com/ollevche/goshlib
How to build a shared library (.dll) in Go for Windows on Ubuntu?
https://github.com/ollevche/goshlib
Last synced: 6 months ago
JSON representation
How to build a shared library (.dll) in Go for Windows on Ubuntu?
- Host: GitHub
- URL: https://github.com/ollevche/goshlib
- Owner: ollevche
- License: mit
- Created: 2020-11-06T13:50:45.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-06T18:41:59.000Z (over 5 years ago)
- Last Synced: 2025-02-08T21:31:11.544Z (over 1 year ago)
- Language: Makefile
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## goshlib - Go Shared Library Example
This is an example of how to build shared libraries (**.dll**, **.so**) in **Go** and **C** using **Linux**.
You have to install `x86_64-w64-mingw32-gcc` compiler to build a shared library for **Windows** (**.dll**).
**Makefile** has had targets for building **libraries** (**Go**, **C**) and a **client app** as an example. Here is how you can try it:
Target | Action
------- |--------
`make (all)` | builds **Go** and **C** **.so** libraries, the **client app**, then **runs** the app
`make run` | **runs** the app
`make usego` / `make usec` | swaps the shared library for **Go** / **C**
`make win` | builds **Go** and **C** **.dll** libraries for **Windows**
`make clean` | deletes object files
`make fclean` | deletes object files, binaries and libraries
`make re` | `make fclean` + `make (all)`
### Useful resources
* [How to - C libraries](https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html)
* [Fun building shared libraries in Go](https://medium.com/@walkert/fun-building-shared-libraries-in-go-639500a6a669)
* [Cross-Compiling Golang (CGO) Projects](https://dh1tw.de/2019/12/cross-compiling-golang-cgo-projects)