Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
GoLang: main not finding shared library used by module

I'm building a module in go, it looks something like this:

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()
}

Then I have hello.go which is my main:

package main

import (
    "helloworld/eos"
)

func main() {
    eos.useMyCFunc()
}

The directory structure is as follows:

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

These are the commands I run to build the program:

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 .

None of these return any kind of error. However, when I run go run . from /hello, I get this 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

This file does exist, and is located at helloworld/eos/vendor/MyLibrary/1.14.2/Bin/Linux/libMY_SDK-Linux-Shipping.so, as specified in the LDFLAGS of eos.go.

Why can hello.go not find this file?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

On top of what @rocka2q mentioned about CGo, useMyCFunc() needs to be capitalized for it to be accessible to outside of the eos package.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda