Compiling Requires threads, which may not be auto-detected by toolchain linker. Thus use: g++ -pthread -O3 q3api.cpp -o q3api