0

例の 1 つをコンパイルしようとすると、次のエラーが発生します。

main.cpp:8:undefined reference to `mosqpp::lib_init()'
main.cpp:13: undefined reference to `mosqpp::mosquittopp::loop(int, int)'
main.cpp:15: undefined reference to `mosqpp::mosquittopp::reconnect()'
temperature_conversion.o: In function `mqtt_tempconv':
temperature_conversion.cpp:7: undefined reference to `mosqpp::mosquittopp::mosquittopp(char const*, bool)'
temperature_conversion.cpp:13: undefined reference to `mosqpp::mosquittopp::connect(char const*, int, int)'
temperature_conversion.cpp:7: undefined reference to `mosqpp::mosquittopp::~mosquittopp()'
temperature_conversion.o: In function `mqtt_tempconv::on_connect(int)':
temperature_conversion.cpp:21: undefined reference to `mosqpp::mosquittopp::subscribe(int*, char const*, int)'
temperature_conversion.o: In function `mqtt_tempconv::on_message(mosquitto_message const*)':
temperature_conversion.cpp:37: undefined reference to `mosqpp::mosquittopp::publish(int*, char const*, int, void const*, int, bool)'

助けてください

4

2 に答える 2

2

あなたの質問はあまり詳細を示していません -問題が何であるかだけでなく、それについてどのように行ったかを説明する必要があります.

そうは言っても、ライブラリに対してリンクしていないようです。

次のようにコンパイルする場合:

g++ main.o temperature_conversion.o -o temperature_conversion 

次に、ライブラリに対してリンクする必要があります。

g++ main.o temperature_conversion.o -o temperature_conversion -lmosquittopp

すでにインストールされているとします。

于 2014-10-13T11:59:23.347 に答える