GCC我是新來Mosquitto和我綁寫一個簡單的C客戶端連接到Mosquitto的測試服務器:http://test.mosquitto.org/鏈接Mosquitto與OSX
下面是簡單的C客戶端的代碼,這是一個99.9% http://pastie.org/private/orwicqjfjz8g8biurznca
編輯1:
我跟着意見,並寫了一個makefile而不是做
gcc -o test test.c
例如在Mosquitto的網站上發現
生成文件看起來是這樣的:
CC = gcc
CFLAGS = -I
DEPS = mosquitto.h
LIBS = -llibmosquitto
%.o: %.c $(DEPS)
$(CC) -c -o [email protected] $< $(CFLAGS)
make: test.c
$(CC) -m32 -Wall -o [email protected] $^ $(CFLAGS) $(LIBS)
.PHONY: clean
這是輸出我得到這似乎是有些問題的鏈接mosquitto庫用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
注:我用自制安裝mosquitto所以lib的路徑是
/usr/local/Cellar/mosquitto/1.1/
感謝任何幫助!
問候
你需要告訴GCC與libmosquitto鏈接爲它是能夠找到mosquitto功能。 –
它看起來像你*編譯*罰款。另一方面,鏈接...... – WhozCraig