我正在尝试通过以下示例获取URL的内容:https://curl.haxx.se/libcurl/c/url2file.html
我已经安装了以下内容:
sudo apt-get install libcurl4
sudo apt-get install libcurlpp-dev
sudo apt-get install libcupt4-2-downloadmethod-curl
sudo apt-get install libcurl4-openssl-dev
我已将该代码添加到C ++程序中。该程序的makefile不包含与libcurl
相关的任何内容。生成文件使我可以使用hzeller's rpi-rgb library:
CXXFLAGS=-Wall -O3 -g -Wextra -Wno-unused-parameter
OBJECTS=Big_ppd_display_try1.o
BINARIES=Big_ppd_display_try1
OPTIONAL_OBJECTS=text_example.o coz_try1.o
OPTIONAL_BINARIES=text_example coz_try1
# Where our library resides. You mostly only need to change the
# RGB_LIB_DISTRIBUTION, this is where the library is checked out.
RGB_LIB_DISTRIBUTION=rpi-rgb-led-matrix
RGB_INCDIR=$(RGB_LIB_DISTRIBUTION)/include
RGB_LIBDIR=$(RGB_LIB_DISTRIBUTION)/lib
RGB_LIBRARY_NAME=rgbmatrix
RGB_LIBRARY=$(RGB_LIBDIR)/lib$(RGB_LIBRARY_NAME).a
LDFLAGS+=-L$(RGB_LIBDIR) -l$(RGB_LIBRARY_NAME) -lrt -lm -lpthread
all : $(BINARIES)
$(RGB_LIBRARY): FORCE
$(MAKE) -C $(RGB_LIBDIR)
Big_ppd_display_try1: Big_ppd_display_try1.o $(RGB_LIBRARY)
$(CXX) $(CXXFLAGS) Big_ppd_display_try1.o -o $@ $(LDFLAGS) $(MAGICK_LDFLAGS)
%.o : %.cc
$(CXX) -I$(RGB_INCDIR) $(CXXFLAGS) -c -o $@ $<
Big_ppd_display_try1.o : Big_ppd_display_try1.cc
$(CXX) -I$(RGB_INCDIR) $(CXXFLAGS) $(MAGICK_CXXFLAGS) -c -o $@ $<
clean:
rm -f $(OBJECTS) $(BINARIES) $(OPTIONAL_OBJECTS) $(OPTIONAL_BINARIES)
FORCE:
.PHONY: FORCE
所有undefined reference
函数都有一个libcurl
:
pi@raspberrypi:/var/www/html/4panel $ sudo make all
make -C rpi-rgb-led-matrix/lib
make[1]: Entering directory '/var/www/html/4panel/rpi-rgb-led-matrix/lib'
make[1]: Leaving directory '/var/www/html/4panel/rpi-rgb-led-matrix/lib'
g++ -Wall -O3 -g -Wextra -Wno-unused-parameter Big_ppd_display_try1.o -o Big_ppd_display_try1 -Lrpi-rgb-led-matrix/lib -lrgbmatrix -lrt -lm -lpthread
/usr/bin/ld: Big_ppd_display_try1.o: in function `main':
/var/www/html/4panel/Big_ppd_display_try1.cc:240: undefined reference to `curl_global_init'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:243: undefined reference to `curl_easy_init'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:246: undefined reference to `curl_easy_setopt'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:249: undefined reference to `curl_easy_setopt'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:252: undefined reference to `curl_easy_setopt'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:255: undefined reference to `curl_easy_setopt'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:262: undefined reference to `curl_easy_setopt'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:265: undefined reference to `curl_easy_perform'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:272: undefined reference to `curl_easy_cleanup'
/usr/bin/ld: /var/www/html/4panel/Big_ppd_display_try1.cc:274: undefined reference to `curl_global_cleanup'
collect2: error: ld returned 1 exit status
make: *** [Makefile:24: Big_ppd_display_try1] Error 1
我正在Linux PC上使用Visual Studio Code来检查代码中的错误并进行调试,并且那里没有错误或警告。
该代码与libcurl示例中的代码相同,不同之处在于它们全部处于一个大的while(true)
循环中,因为我需要它在Raspberry Pi 4上作为一个进程无限期地运行。
您怎么看?