.
This commit is contained in:
14
test/CMakeLists.txt
Normal file
14
test/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(cppstaticbuild)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Static build settings
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
|
||||
|
||||
include_directories(/usr/local/include)
|
||||
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main pthread)
|
20
test/main.cpp
Normal file
20
test/main.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <httplib.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <libassert/assert.hpp>
|
||||
|
||||
int main() {
|
||||
httplib::Client cli("https://ipinfo.io");
|
||||
auto res = cli.Get("/ip");
|
||||
|
||||
ASSERT(res->status == 200, "Failed to get IP");
|
||||
|
||||
nlohmann::json j;
|
||||
j["ip"] = res->body;
|
||||
j["status"] = res->status;
|
||||
|
||||
std::cout << j.dump(4) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user