Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kbehouse/go_call_cxx_so

golang call c++ shared library(.so)
https://github.com/kbehouse/go_call_cxx_so

c-plus-plus go golang shared-library

Last synced: about 2 months ago
JSON representation

golang call c++ shared library(.so)

Awesome Lists containing this project

README

        

# Call C++ from Go with shared library

Modify From: https://github.com/draffensperger/go-interlang/tree/master/go_to_cxx/c_wrapper

## Build & Run

```
sh build_and_run.sh
```

### Build .so

```
cd cpp/
mkdir build/
cd build/
cmake ..
make -j4
cp libmyso.so ../../libmyso.so
```

### copy .hxx

```
cd ../
cp wrap_point.hxx ../
```

### build go
```
cd ../
go build -o exe
```

### Run
```
export LD_LIBRARY_PATH=.
./exe
```

## Note

1. Add *#cgo LDFLAGS: -L"${SRCDIR}/libs"* to main.go

2. Generate .so look CMakeLists.txt