0

I have created a new makefile

CC = /usr/bin/gcc    

MQM_HOME = /opt/mqm   
CFLAGS = -g -Wall \    
     -I$(MQM_HOME)/inc \    
     -I/usr/include    


#IBM_LIBPATH=-L/usr/vacpp/lib    
IBM_LIBS= -liconv    

MQ_LIBPATH=-L$(MQM_HOME)/lib64    
MQLIB = $(MQ_LIBPATH) -lmqm -lmqmcs -lmqmzse    

LIBS    =  $(IBM_LIBS)  $(MQLIB) -lpthreads    
#LDFLAGS = -q64 $(IBM_LIBPATH) $(MQ_LIBPATH)    

SOURCE=/home/avalanche/oleg    
default: ctm_mq_con_ex    

ctm_mq_con_ex: ctm_mq_con_ex.o    
# Compilation rules    

EXE     = $(SOURCE)/ctm_mq_con_ex    
MAIN    = $(SOURCE)/ctm_mq_con_ex.c    
OBJS    = $(SOURCE)/ctm_mq_con_ex.o    

.c.o:    
    $(CC) $(CFLAGS) -c $(MAIN)    

    $(CC) $(CFLAGS) -o $(EXE) $(OBJS)    


clean:    
     \rm -f $(OBJS)    
     \rm -f $(EXE)    

Now it shows errors

 make -f ./ctm_mq_con_ex.mk    
/usr/bin/gcc -g -Wall -I/opt/mqm/inc -I/usr/include -c /home/avalanche/oleg/ctm_mq    
/usr/bin/gcc -g -Wall -I/opt/mqm/inc -I/usr/include -o /home/avalanche/oleg/ctm_mq    
/home/avalanche/oleg/ctm_mq_con_ex.o: In function `main':    
/home/avalanche/oleg/ctm_mq_con_ex.c:67: undefined reference to `MQCONNX'    
/home/avalanche/oleg/ctm_mq_con_ex.c:86: undefined reference to `MQOPEN'    
/home/avalanche/oleg/ctm_mq_con_ex.c:114: undefined reference to `MQINQ'    
/home/avalanche/oleg/ctm_mq_con_ex.c:142: undefined reference to `MQCLOSE'    
/home/avalanche/oleg/ctm_mq_con_ex.c:163: undefined reference to `MQDISC'   
collect2: ld returned 1 exit status    

But in my C program I put header files

#include <stdio.h>    
#include <stdlib.h>    
#include <ctype.h>    
#include <string.h>    

 /* includes for WebSphere MQ */    
#include <cmqc.h>                  /* For regular MQI definitions   */    
#include <cmqxc.h>                 /* For MQCD definition           */    

Did I miss something?

JoshMc
  • 10,239
  • 2
  • 19
  • 38
  • Is anybody can help me to solve the problem? –  Jun 07 '17 at 18:14
  • Maybe need to check else where on SE communities, I'll vote to move to StackOverflow but there's Unix and Linux and SO and maybe others where you may be able to get help with your inquiry if it gets no attention here. I don't know C that well but this seems like a programming question at least. – Bitcoin Murderous Maniac Jun 10 '17 at 02:27
  • You're net telling it where to find the header files for WebSphere and/or it fails to link them. – Seth Jun 10 '17 at 11:45
  • Looks like you are not linking with libraries `$(CC) $(CFLAGS) -o $(EXE) $(OBJS)` --> `$(CC) $(CFLAGS) -o $(EXE) $(OBJS) $(LIBS)` – Marian Jun 10 '17 at 11:51
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – melpomene Oct 13 '17 at 08:15

0 Answers0