link libcurl static lib

This commit is contained in:
cppla 2022-07-15 21:14:39 +08:00
parent f70705d872
commit 2e62ffa593
3 changed files with 19 additions and 2 deletions

@ -3,7 +3,7 @@ FROM debian:buster as builder
MAINTAINER cppla https://cpp.la
RUN apt-get update -y && apt-get -y install gcc g++ make
RUN apt-get update -y && apt-get -y install gcc g++ make libcurl4-openssl-dev
COPY . .

@ -26,7 +26,7 @@ $(ODIR)/%.o: $(SDIR)/%.cpp
$(CXX) -c $(INC) $(CXXFLAGS) $< -o $@
$(OUT): $(OBJS)
$(CXX) $(LIBS) $^ -o $(OUT)
$(CXX) $(LIBS) $^ -o $(OUT) -lcurl
.PHONY: clean

@ -8,6 +8,7 @@
#include "server.h"
#include "main.h"
#include "exprtk.hpp"
#include "curl/curl.h"
#if defined(CONF_FAMILY_UNIX)
#include <signal.h>
@ -321,6 +322,22 @@ void CMain::WatchdogMessage(int ClientNetID, double load_1, double load_5, doubl
printf("node info: %s\n\n", Client(ClientID)->m_aLocation);
printf("watchdog name: %s\n", Watchdog(ID)->m_aName);
printf("watchdog rule: %s\n", Watchdog(ID)->m_aRule);
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://cpp.la");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");
res = curl_easy_perform(curl);
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
}
ID++;