在mac下編譯c++

代碼

/*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 <可執行文件名>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章