在mac terminal 執行 gcc Source.cpp 出現以下回報
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
目前資料夾中有三個file, 分別都有引用到。 不知道是什麼問題。
Source.cpp
2. {#include
#include
#include "Rectangle.h"}
Rectangle.h
3. {#ifndef RECTANGLE_H
#define RECTANGLE_H
class Rectangle..
#endif}
Rectangle.cpp
4. {#include "Rectangle.h"}
感謝查看!!!
試試看一次 gcc 兩個檔案gcc Source.cpp Rectangle.cpp
mac$ gcc Source.cpp
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)
mac$ gcc Source.cpp Rectangle.cpp
mac$ ls -al a.*
-rwxr-xr-x 1 mac staff 16536 2 9 08:53 a.out
mac$
目前狀況是,若直接由vscode 上面執行
會出現以下feedback。
Undefined symbols for architecture x86_64:
"Rectangle::getPerimeter()", referenced from:
_main in Source-673073.o
"Rectangle::getArea()", referenced from:
_main in Source-673073.o
"Rectangle::Rectangle(double, double)", referenced from:
_main in Source-673073.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
但若是由cmd 執行 gcc Source.cpp Rectangle.cpp
會出現以下feedback.
Undefined symbols for architecture x86_64:
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
std::__1::ctype const& std::__1::use_facet<std::__1::ctype >(std::__1::locale const&) in Source-9206a8.o
"std::__1::ios_base::getloc() const", referenced from:
std::__1::basic_ios<char, std::__1::char_traits >::widen(char) const in Source-9206a8.o
.....
Dwarf Exception Unwind Info (__eh_frame) in Source-9206a8.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
太長就貼了一部分而已。
非常感謝你的回答與時間!!!
我模擬不出跟你一樣的錯誤訊息
幫不上忙
沒事~謝謝你的幫忙!!!