ibm-messaging / mq-golang

Calling IBM MQ from Go applications
Apache License 2.0
168 stars 60 forks source link

Cannot statically link the mqitest sample #92

Closed wcn00 closed 5 years ago

wcn00 commented 5 years ago

Using go version go1.11.5 using ubuntu 18 on Intel x86-64 using the mq9.1.01 installation

I need to link mq-golang (and maybe mq-golang-jms20) apps statically so that they can be distributed without dependencies. I have set environment variables: CGO_LDFLAGS=-L/opt/mqm/lib64 -lmqm_r -Wl,-rpath,/opt/mqm/lib64 CGO_LDFLAGS_ALLOW=-Wl,-rpath.* CGO_CFLAGS=-I/opt/mqm/inc

I've tried many build commands but they all give the same error:

wcn00@gandalf:~/go/src/github.com/ibm-messaging/mq-golang$ go build -ldflags '-extldflags -static ' -o ./bin/mqitest samples/mqitest/*.go

command-line-arguments

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /usr/bin/ld: cannot find -lmqm_r /usr/bin/ld: cannot find -lmqm_r /usr/bin/ld: cannot find -lmqm_r collect2: error: ld returned 1 exit status

I've set LD _LIBRARY_PATH to /opt/mqm/lib64, and I'v even added it to my ldconfig. No help.

p.s. I definatly can link one of the C samples on this system. And I can dynamically link my go application.

Any ideas?

ibmmqmet commented 5 years ago

The MQ client libraries (libmqm et al.) are only available in .so (shared) form. There's no .a (archive) version. I don't know any way of converting .so to ,a format for static linking.

MQ's Redistributable Client package is intended for inclusion in application packages.

wcn00 commented 5 years ago

I agree that MQ is not distributed with static libs. If the lawyers will agree to ship the redistributable client...that may solve my problem. wcn