ibm-messaging / mq-golang

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

clang error trying to execute simple file #141

Closed Aornn closed 4 years ago

Aornn commented 4 years ago

Hi i have a little problem, i try to connect a go client to mqseries server. I have git clone this repository, and try to run amqssub.go with modification for localhost. But everytime I run go run amqssub.go i have this error ld: warning: directory not found for option '-L/opt/mqm/lib64' ld: unknown option: -rpath=/usr/lib64 clang: error: linker command failed with exit code 1 (use -v to see invocation) I have no idea what can i do :/

this i my env : export MQ_INSTALLATION_PATH=/Users/ronan/Downloads/IBM-MQ-Toolkit-Mac-x64-9.1.1.0 export CGO_CFLAGS="-I$MQ_INSTALLATION_PATH/inc" export CGO_LDFLAGS="-L$MQ_INSTALLATION_PATH/lib64 -Wl,-rpath,$MQ_INSTALLATION_PATH/lib64"

with version go version go1.13.8 darwin/amd64 and with go-module

Anyone know why ?

Thanks for all :)

ibmmqmet commented 4 years ago

I don't use MacOS so can't try things myself. But perhaps adding -Wl,-v to CGO_LDFLAGS would give more info as suggested (the -Wl passes options to the linker command line). You can ignore the warning about the missing /opt/mqm/lib64 directory - that's one of the default paths that's always looked for. I'd normally expect -rpath to have a space after it, not "=". But some linkers have accepted both versions or it might be an artifact of the linker error printing. Make sure you've got a current version of this repository as I think there might have been an "=" on the rpath option at some point a long time ago.

Aornn commented 4 years ago

Thanks for your reply. I have tried both of yours ideas and thisis the result : export CGO_LDFLAGS="-L$MQ_INSTALLATION_PATH/lib64 -Wl,-v,-rpath $MQ_INSTALLATION_PATH/lib64"

# runtime/cgo
@(#)PROGRAM:ld  PROJECT:ld64-556.6
BUILD 13:10:29 Apr  7 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
    /Users/ronan/Downloads/IBM-MQ-Toolkit-Mac/lib64
    /usr/local/lib
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
Framework search paths:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/
# github.com/ibm-messaging/mq-golang/ibmmq
@(#)PROGRAM:ld  PROJECT:ld64-556.6
BUILD 13:10:29 Apr  7 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
ld: warning: directory not found for option '-L/opt/mqm/lib64'
Library search paths:
    /Users/ronan/Downloads/IBM-MQ-Toolkit-Mac/lib64
    /usr/local/lib
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
Framework search paths:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/
ld: unknown option: -rpath=/usr/lib64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't understand. at all because i don't have -rpath=something in my global var

ibmmqmet commented 4 years ago

Final (?) thought -

go build -x -a amqsput.go 2>&1 | tee /tmp/build.out

That wlil force a complete rebuild and trace the commands and all the flags that are being used by the compiler.

Aornn commented 4 years ago

The output is pretty long but the tail of the build.out file is:

# github.com/ibm-messaging/mq-golang/ibmmq
@(#)PROGRAM:ld  PROJECT:ld64-556.6
BUILD 13:10:29 Apr  7 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
ld: warning: directory not found for option '-L/opt/mqm/lib64'
Library search paths:
    /Users/ronan/Downloads/IBM-MQ-Toolkit-Mac/lib64
    /usr/local/lib
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
Framework search paths:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/
ld: unknown option: -rpath=/usr/lib64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So nothing new, same error, i'm pretty sure the error come from the mac os toolkit but it's pretty weird because just two weeks ago with the exact same file and exact same var i had no issues.

Aornn commented 4 years ago

Ok i found something interesting, i have juste created a new empty folder copy and paste the file amqsput and it works perfectly ! For my project i need module so i typed go mod init and juste after i run again the same file and BOOM the error comes in ! So i deleted the go.mod and go.sum and it works perfectly

ibmmqmet commented 4 years ago

That is interesting - I suspect that once you start using modules you are pulling in an old level of the mq library because the current version in master does not provide a module interface. In the go.sum/go.mod files that got created I would bet you see something like "mq-golang v3.0.0". The Go designers have made some "interesting" choices around compatibility, automatic downloads, and versioning.

There is a beta version of the MQ library available here which should work properly with modules. And has a new major version, v5. Users of that then use v5 in the import path.

In go.mod, put

require (
        github.com/ibm-messaging/mq-golang/v5 v5.0.0-beta
)

and in application code, put

import "github.com/ibm-messaging/mq-golang/v5/ibmmq"

At some point I'll promote that branch to master and remove the beta tag.

Aornn commented 4 years ago

AAAAAAAAAAND finally it works ! Thanks again for what you are doing ! I hope I don't get any more bugs ahah. Thanks for all

matrober-uk commented 4 years ago

I had the same ld: unknown option: -rpath=/usr/lib64 symptom while updating the Golang JMS repo to use mq-golang/v5 yesterday.

Definitely a surprising error symptom - but I was pleased I remembered you having this thread so I was able to benefit from your respective hard work!