After I checked IBM online instruction for compiling C code:
gcc -m64 -o amqsput_64_r amqsput0.c -I/opt/mqm/inc -L/opt/mqm/lib64 -Wl,-rpath=/opt/mqm/lib64 -Wl,-rpath=/usr/lib64 -lmqm_r
I realized I should link the COBOL code to MQ server library (instead of MQ Client Library)
$cob64 -xtvP amq0put0.cbl -L /opt/mqm/lib64 -lmqmcb_r
cob64 -C nolist -xtvP amq0put0.cbl -L /opt/mqm/lib64 -lmqmcb_r
* Micro Focus COBOL V2.3 revision 000 Compiler
* Copyright (C) Micro Focus 1984-2015. All rights reserved.
* Accepted - verbose
* Accepted - reentrant
* Accepted - nolist
* Accepted - list("amq0put0.lst")
* Compiling amq0put0.cbl
* Total Messages: 0
* Data: 10608 Code: 1193
* Micro Focus COBOL Code Generator
* Copyright (C) Micro Focus 1984-2015. All rights reserved.
* Accepted - verbose
* Generating amq0put0
* Data: 10376 Code: 1950 Literals: 624
cob64: Entry points defined in module: amq0put0.o
*AMQ0PUT0
amq0put0
I retested with new executable:
$./amq0put0
AMQ0PUT0 start
Please enter the name of the target queue
REQUEST_Q
Please enter the name of the queue manager
sample
target queue is REQUEST_Q
Please enter the message(s)
Test from COBOL
Test again from COBOL
AMQ0PUT0 end
Everything is working now.