Mac上編譯C 報錯

2022-05-05 10:33:12 字數 1676 閱讀 4074

今天在使用mac編譯c++檔案時,提示以下錯誤。

1 undefined symbols for

architecture x86_64:2"

std::__1::__vector_base_common::__throw_length_error() const

", referenced from:

3 void std::__1::vector>::__push_back_slow_path(e const&) in main-8b5a99.o4"

std::terminate()

", referenced from:

5 ___clang_call_terminate in main-8b5a99.o6"

operator delete(void*)

", referenced from:

7 std::__1::__vector_base>::~__vector_base() in main-8b5a99.o

8 std::__1::__split_buffer&>::~__split_buffer() in main-8b5a99.o9"

operator new(unsigned long)

", referenced from:

10 std::__1::__split_buffer&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in main-8b5a99.o11"

___cxa_begin_catch

", referenced from:

12 ___clang_call_terminate in main-8b5a99.o13"

___cxa_call_unexpected

", referenced from:

14 _main in main-8b5a99.o15"

___gxx_personality_v0

", referenced from:

16 _main in main-8b5a99.o

17 ___cxx_global_array_dtor in main-8b5a99.o

18 void std::__1::vector>::__push_back_slow_path(e const&) in main-8b5a99.o

19 dwarf exception unwind info (__eh_frame) in main-8b5a99.o

20ld: symbol(s) not found for

architecture x86_64

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

通過在stackoverflow翻閱找到相應的解決辦法。 發生這種狀況的原因是gcc預設檔案時c檔案,在編譯時不會鏈結c++標準庫。我們可以通過以下方式進行指定引入c++標準庫

gcc main.c -o macin -lstdc++

或者使用

g++ main.c -o main

在mac上編譯htk

解壓縮 後 cd htk 操作目錄都是在這個下 可能需要安裝的東西 1.gcc mac都自帶有的 但是如果這時候你直接去 make all 會出現沒有找到xlib的錯誤 2.command line tools 這個package包含很多命令列下的headers 包括xlib 一般情況下 只要安裝了...

在mac上編譯xlua

2.使用bash終端控制台 3.為cmake配置環境變數 export path cmake root 4.為xlua.build設定環境變數 這一步應該是可以忽略掉的 export path path users adeli desktop lua build path 5.為xlua.build...

c 編譯報錯積累

c 編譯報錯積累 toc 1.stdafx.h no such file or directory 這裡只需將你的 include stdafx.h 刪除掉。更換為 其所包含的內容。也就是 include include 2.getch theposixnameforthisitemisdeprec...