首次在mac上編譯c++的一個問題:沒有擴展名的代碼文件


ld: warning: ignoring file c, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x23 0x69 0x6E 0x63 0x6C 0x75 0x64 0x65 0x3C 0x69 0x6F 0x73 0x74 0x72 0x65 0x61 )

Undefined symbols for architecture x86_64:

  "_main", referenced from:

     implicit entry/start for main executable

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


 

分析原因:在編譯時用了

g++ a

問題:a這個文件沒有擴展名

改正:將a重命名為a.cpp即可

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM