927 questions
5 votes
1 answer
107 views
Use Petsc-Library in Go
I am trying to use the PETSc (Portable, Extensible Toolkit for Scientific Computation) library in Go over cgo. After the call of PetscInitialize, the program will crash at a random point with the ...
2 votes
1 answer
186 views
CGO allows function returning string but it does not work
I want to call a go function from C++ and return a string. The function: //export EditStr func EditStr(a string) (ostr string) { ostr = fmt.Sprintf("[["+a+"]]") fmt....
1 vote
0 answers
89 views
Environment variables not accessible in dynamically loaded .dylib on macOS using Rust libloading, but works on Windows
macOS: The dynamically loaded .dylib cannot read environment variables that were set by the main Rust process at runtime Windows: The same code works perfectly - the .dll can access environment ...
4 votes
0 answers
65 views
Failed to create thumbnail using the PTB_SaveAsImage function from the C API (In GO)
For testing the callas PDF toolbox SDK, I want to convert a sample PDF to a PNG. The callas license is activated. In my main() function, I successfully initialize the SDK. After that, I call the ...
1 vote
1 answer
158 views
ctypes + cgo and ownership of strings
Background I am currently using a DLL I generated with golang in python. As a sanity check for debugging I added a function called return_string(), which takes a pointer to a string in C (char*) ...
0 votes
1 answer
92 views
Deferring free on a parameter
I am working with cgo, I have a parameter that's being passed in as a *C.char. Once it's been used in a function call I no longer need it, so I defer freeing it, but when I do I don't get a result ...
1 vote
2 answers
141 views
Cross compiling a Go native binary for Java code using docker
I'm trying to compile a Go native binary to use in Java code on Mac. The binary needs to be executed on a linux host which has the following specifications: # uname -a Linux <hostname> 5.14.0-...
3 votes
1 answer
285 views
Zig as C Linux->Mac cross-compiler for go project with go-sqlite3 error: unable to find dynamic system library 'resolv'
I'm building a Go application with native (CGO_ENABLED=1) SQLite support using https://github.com/mattn/go-sqlite3. I'm trying to get the builder docker image to a reasonable size. (goreleaser/...
2 votes
1 answer
79 views
How to process mismatch C & Go structure issue when Go process C written file format?
I have a file written in C with the format "header.h", and I want to read it using CGO to automatically retrieve the field names defined in header.h. Here is a shortened example where I ...
0 votes
1 answer
122 views
Golang ImageMagick Leftover Threads
I have written a linux service in Go that processes a large number of image files, converting them from TIFF to JPEG and adding a text overlay on top. I'm using the Go package gographics/imagick/v3 ...
2 votes
1 answer
221 views
Calling a static C/C++ library from Go
I'm still on the learning curve with Go, but I've managed to compile and run a Go program that includes a C object file. The objective is to call an existing static C++ library. The call will be a bit ...
0 votes
0 answers
374 views
golang and C with SIMD instructions
I am quite new to golang, and I am doing some experiments with golang and cgo. I wanted to see if golang can benefit with a C program that uses SIMD operations on a simple test, however what I saw is ...
2 votes
0 answers
86 views
Unable to get the c stack trace with a corefile from a cgo routine
I'm using https://github.com/gen2brain/aac-go.git to encode AAC in my golang project, but sometimes I got crash in my ARMV7l linux and I have executed like CGO_DEBUG=1 GOTRACEBACK=crash ./binary to ...
0 votes
0 answers
193 views
Go CGO: Binary doesn't find shared library with rpath, only works with LD_LIBRARY_PATH
I am working on a GO project that links to a shared library (.so) using CGO. I want to embed the library path in the binary using rpath,so that it runs without needing to set the LD_LIBRARY_PATH. ...
1 vote
1 answer
192 views
cant run go code with sqlite3 on windows but works fine on linux
I have to switch to windows for a week and I cant run my project I installed GCC via Cygwin and added it to path, I can call it from any shell. I set CGOENABLED=1 because it was required but I keep ...