I want to create a go library and use it with go application using LD_PRELOAD. Suppose my library code is in a folder golib.
create library
go install -buildmode=shared golib
It will create golib.so
create application
go build gosampleapp.go
It will create gosampleapp. To use the library run following command
export LD_PRELOAD=path of golib.so; ./gosampleapp
It will give the error “undefined symbol: main.main”
But if I compile the library and application using linkshared option then there is no error and gosampleapp runs successfully.
Can someone suggest how to solve this problem without using linkshared option.