代碼
/*main.cpp*/
#include <iostream>
#include <stdio.h>
#include <filesystem>
namespace fs = std::__fs::filesystem;
int main(int argc, const char * argv[]) {
FILE *f = fopen("hello.txt", "w");
if(f == NULL){
std::cout << "Fail" << std::endl;
}
std::cout << fs::absolute("hello.txt")<< std::endl;
char* hello = "hello world\n";
fputs(hello, f);
fclose(f);
std::cout << "hello" << std::endl;
return 0;
}
編譯
$ g++ -std=c++11 main.cpp -o hello
g++: clang++的別名
-std: 指定標準庫版本
-o: 指定輸出文件名
查看可執行文件依賴哪些庫
$ otool -L <可執行文件名>