I am new to Mosquitto and I am tying to write a simple C client connecting to Mosquitto's test server: http://test.mosquitto.org/
Here is the code of the simple C client which is 99.9% of an example found on Mosquitto's site: http://pastie.org/private/orwicqjfjz8g8biurznca
EDIT 1:
I followed the comments and wrote a makefile instead of doing
gcc -o test test.c
The makefile looks like this:
CC = gcc
CFLAGS = -I
DEPS = mosquitto.h
LIBS = -llibmosquitto
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
make: test.c
$(CC) -m32 -Wall -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
This is the output i get which seems to be some problem linking mosquitto libs with gcc:
Undefined symbols for architecture i386:
"_mosquitto_connect", referenced from:
_main in cc6Blyda.o
"_mosquitto_connect_callback_set", referenced from:
_main in cc6Blyda.o
"_mosquitto_destroy", referenced from:
_main in cc6Blyda.o
"_mosquitto_lib_cleanup", referenced from:
_main in cc6Blyda.o
"_mosquitto_lib_init", referenced from:
_main in cc6Blyda.o
"_mosquitto_log_callback_set", referenced from:
_main in cc6Blyda.o
"_mosquitto_loop", referenced from:
_main in cc6Blyda.o
"_mosquitto_message_callback_set", referenced from:
_main in cc6Blyda.o
"_mosquitto_new", referenced from:
_main in cc6Blyda.o
"_mosquitto_subscribe", referenced from:
_my_connect_callback in cc6Blyda.o
"_mosquitto_subscribe_callback_set", referenced from:
_main in cc6Blyda.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [make] Error 1
NOTE: I used homebrew to install the mosquitto so the path to the lib is
/usr/local/Cellar/mosquitto/1.1/
Appreciate any help!!
Regards