Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
GoLang: principal no encuentra la biblioteca compartida utilizada por el módulo

Estoy construyendo un módulo en go, se parece a esto:

 package eos /* #cgo LDFLAGS: -L${SRCDIR}/vendor/MyLibrary/1.14.2/Bin/Linux -lMY_SDK-Linux-Shipping #cgo CFLAGS: -I ${SRCDIR}/vendor/MyLibrary/1.14.2/Include #include "my_sdk.h"*/ import "C" func useMyCFunc() void { C.myCFunc() }

Luego tengo hello.go que es mi principal:

 package main import ( "helloworld/eos" ) func main() { eos.useMyCFunc() }

La estructura del directorio es la siguiente:

 -helloworld/ | - hello/ | - hello.go | -eos/ | - eos.go | - vendor/ | - (all the required lib files)

Estos son los comandos que ejecuto para construir el programa:

 cd eos go mod init helloworld/eos cd ../hello go mod init helloworld/hello go mod edit -replace helloworld/eos=../eos go mod tidy go build .

Ninguno de estos devuelve ningún tipo de error. Sin embargo, cuando corro go run . de /hello , me sale este error:

 /tmp/go-build2142984290/b001/exe/hello: error while loading shared libraries: libMY_SDK-Linux-Shipping.so: cannot open shared object file: No such file or directory

Este archivo existe y se encuentra en helloworld/eos/vendor/MyLibrary/1.14.2/Bin/Linux/libMY_SDK-Linux-Shipping.so , como se especifica en LDFLAGS de eos.go

¿Por qué hello.go no puede encontrar este archivo?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Además de lo que mencionó @rocka2q sobre CGo, useMyCFunc() debe estar en mayúsculas para que sea accesible desde fuera del paquete eos .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!