https://github.com/optimizely/go-sdk-c-wrapper-hack-week
A GO SDK wrapper for C/C++ (any native code) - Winter Hack Week 2020
https://github.com/optimizely/go-sdk-c-wrapper-hack-week
Last synced: 10 months ago
JSON representation
A GO SDK wrapper for C/C++ (any native code) - Winter Hack Week 2020
- Host: GitHub
- URL: https://github.com/optimizely/go-sdk-c-wrapper-hack-week
- Owner: optimizely
- Archived: true
- Created: 2020-02-10T18:29:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-10T18:39:52.000Z (about 6 years ago)
- Last Synced: 2025-03-01T12:17:18.685Z (about 1 year ago)
- Language: C
- Size: 11.7 KB
- Stars: 0
- Watchers: 8
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# README
This repository gives an example of how the Optimizely GO SDK can be compiled and used in native C/C++ code.
In this example an Nginx module is built that dynamically loads the Optimizely SDKs and changes it's behavior depending
on some feature flags.
The nginx module is based on
This was done as part of Winter Hackweek 2020.
## Build
First compile nginx on a Linux VM.
```
ssh LINUX_HOST
cd
./configure --with-debug --add-dynamic-module=/home/ec2-user/go-sdk-c-wrapper/nginx-hello-world-module
make
```
Copy this directory over to the linux box and `make` to build the shared library. Golang cross compiling still can't
compile native code. See `Makefile` for `cp` target that does this.
The following didn't work. Only dynamically loading the module seems to work.
```
./configure --with-debug --add-module=/home/ec2-user/go-sdk-c-wrapper/nginx-hello-world-module --with-ld-opt=/home/ec2-user/go-sdk-c-wrapper/go-sdk-c-wrapper.so
./configure --add-module=/home/ec2-user/nginx-hello-world-module
./configure --add-dynamic-module=/home/ec2-user/nginx-hello-world-module
```
## Local builds
For a local test, that will build an run on any architecture try the following.
```
make localtest
./test
```
Key and feature names may need to be adjusted.