Last active
June 21, 2020 23:27
-
-
Save caiorss/0557cd0fa1d5370723b015e443a7c036 to your computer and use it in GitHub Desktop.
Portable Linux Binaries - GLIBC Hell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.9) | |
project(Simple_Cmake_Project) | |
set(CMAKE_CXX_STANDARD 17) | |
set(CMAKE_VERBOSE_MAKEFILE ON) | |
#========== Targets Configurations ============# | |
add_executable( filesys filesys.cpp ) | |
target_link_libraries( filesys stdc++fs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ docker run -it --rm -v $PWD:/work -w /work phusion/holy-build-box-64:latest bash | |
FROM phusion/holy-build-box-64:latest | |
ENTRYPOINT [ "/hbb_exe/activate-exec", "bash" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <iterator> | |
#include <iomanip> | |
#include <filesystem> | |
namespace fs = std::filesystem; | |
template<typename Range, typename Function> | |
auto dotimes(size_t n, Range&& iterable, Function fun) | |
{ | |
size_t i = 0; | |
auto it = fs::begin(iterable); | |
auto end = fs::end(iterable); | |
while(i < n && it != end ){ | |
fun(it); | |
++it; | |
i++; | |
} | |
} | |
int main(){ | |
std::cout << std::boolalpha; | |
std::cout << "\n ===== Listing directory /etc =====" << std::endl; | |
// Show first 10 files of directory /etc | |
dotimes(10, fs::directory_iterator("/etc"), | |
[](auto p){ | |
auto path = p->path(); | |
std::cout << std::left | |
<< std::setw(0) << path.filename().string() | |
<< " " << std::setw(35) | |
<< std::right << std::setw(40) << path | |
<< std::endl; | |
}); | |
return EXIT_SUCCESS; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build: | |
cmake --config Debug -H. -B_build2 | |
cmake --build _build2 --target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest | |
RUN apk add musl cmake make g++ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment