alphacep / alphacep/vosk-api

Go Binding statically references resources outside of the go module's scope

Offen
#708 7 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Jupyter Notebook
Sterne
15.1k
Forks
1.8k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Issue

I'm working an a golang application that will is trying to use Vosk offline and saw the new go bindings. When I attempted to use the binding I get the following error...

```
ld: warning: directory not found for option '-L/Users/myUser/go/pkg/mod/github.com/alphacep/vosk-api/go@v0.3.36/../src'
```

The issue here is that when you install a go module it considers the directory with the `go.mod` file in it as the parent directory and installs from that point down (sub-dirs - no parents). This means that installing only the go module won't compile because it won't have access to the src parent directory where the C header files are located.

A similar use case in another application I work is to build the binding with the following settings...

```
/*
#cgo CXXFLAGS: -std=c++11
#cgo LDFLAGS: -lmyLibName
#include "my_header_file.h"
#include "stdlib.h"
*/
import ....
```

And then I include my own settings for the `-I` and `-L` CGO flags at build time. (Setting this options regardless did not override the ones in the binding)

```
CGO_LDFLAGS="-L/tmp/myLibName/lib/"
CGO_CXXFLAGS="-I/tmp/myLibName/include/"
```

This allows consumers to configure their artifacts/resources as needed and makes integrating with go modules much easier.

If there is simply a step I've missed in getting the go binding properly installed let me know, otherwise adjusting the CGO settings would be appreciated. Thanks!

Ref: https://github.com/alphacep/vosk-api/blob/master/go/vosk.go#L3

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.