ld:未找到架构 x86_64 的符号
我正在使用 C++ 学习原理和实践,并且在链接到正确的架构时遇到问题我当前使用的是 Apple 计算机,我的编译器是 gcc 版本 4.2.1(基于 Apple Inc. build 5658)(LLVM build 2336.1.00 ), 当我
file /usr/lib/libffi.dylib
/usr/lib/libffi.dylib: Mach-O universal binary with 2 architectures
/usr/lib/libffi.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libffi.dylib (for architecture i386): Mach-O dynamically linked shared library i386
同时拥有可用的架构/库时,这就是我用来编译程序的内容,
g++ -Wall chapter.12.3.cpp -o chapter.12.3
In file included from GUI.h:11,
from Simple_window.h:10,
from chapter.12.3.cpp:7:
Graph.h: In constructor ‘Graph_lib::Color::Color(Graph_lib::Color::Color_type)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:45: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Color::Color(Graph_lib::Color::Color_type, Graph_lib::Color::Transparency)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:46: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Color::Color(int)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:47: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Color::Color(Graph_lib::Color::Transparency)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:48: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Rectangle::Rectangle(Point, int, int)’:
Graph.h:211: warning: ‘Graph_lib::Rectangle::w’ will be initialized after
Graph.h:210: warning: ‘int Graph_lib::Rectangle::h’
Graph.h:194: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Rectangle::Rectangle(Point, Point)’:
Graph.h:211: warning: ‘Graph_lib::Rectangle::w’ will be initialized after
Graph.h:210: warning: ‘int Graph_lib::Rectangle::h’
Graph.h:200: warning: when initialized here
In file included from Simple_window.h:10,
from chapter.12.3.cpp:7:
GUI.h: In member function ‘virtual void Graph_lib::Menu::show()’:
GUI.h:107: warning: comparison between signed and unsigned integer expressions
GUI.h: In member function ‘virtual void Graph_lib::Menu::hide()’:
GUI.h:112: warning: comparison between signed and unsigned integer expressions
GUI.h: In member function ‘virtual void Graph_lib::Menu::move(int, int)’:
GUI.h:117: warning: comparison between signed and unsigned integer expressions
Graph.h: In destructor ‘Graph_lib::Vector_ref<T>::~Vector_ref() [with T = Graph_lib::Button]’:
GUI.h:96: instantiated from here
Graph.h:130: warning: comparison between signed and unsigned integer expressions
Undefined symbols for architecture x86_64:
"Simple_window::Simple_window(Point, int, int, String const&)", referenced from:
_main in ccarbqNp.o
"Graph_lib::Polygon::add(Point)", referenced from:
_main in ccarbqNp.o
"Simple_window::wait_for_button()", referenced from:
_main in ccarbqNp.o
"Graph_lib::Shape::Shape()", referenced from:
Graph_lib::Open_polyline::Open_polyline()in ccarbqNp.o
"vtable for Graph_lib::Open_polyline", referenced from:
Graph_lib::Open_polyline::Open_polyline()in ccarbqNp.o
"vtable for Graph_lib::Open_polyline", referenced from:
Graph_lib::Open_polyline::Open_polyline()in ccarbqNp.o
Graph_lib::Open_polyline::~Open_polyline()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Closed_polyline", referenced from:
Graph_lib::Closed_polyline::Closed_polyline()in ccarbqNp.o
Graph_lib::Closed_polyline::~Closed_polyline()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Polygon", referenced from:
Graph_lib::Polygon::Polygon()in ccarbqNp.o
Graph_lib::Polygon::~Polygon()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Shape", referenced from:
Graph_lib::Shape::~Shape()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Button", referenced from:
Graph_lib::Button::~Button()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Window", referenced from:
Graph_lib::Window::~Window()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"Fl_Window::~Fl_Window()", referenced from:
Graph_lib::Window::~Window()in ccarbqNp.o
"Graph_lib::Window::draw()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::handle(int)", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::resize(int, int, int, int)", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::show()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::hide()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::flush()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"typeinfo for Graph_lib::Window", referenced from:
typeinfo for Simple_windowin ccarbqNp.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Compilation exited abnormally with code 1 at Fri Oct 21 12:48:23
似乎我正在使用的库 libbookgui.a 没有编译为正确的架构,但我可能是不正确的。
当我检查 lib 文件构建的架构时,我得到:
/usr/local/lib/libbookgui.a: current ar archive random library
I'm studying Principles and Practices using C++ and am having issues linking to the proper architecture I'm currently using an Apple computer, my compiler is gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00),
when I
file /usr/lib/libffi.dylib
/usr/lib/libffi.dylib: Mach-O universal binary with 2 architectures
/usr/lib/libffi.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libffi.dylib (for architecture i386): Mach-O dynamically linked shared library i386
in which I have both architectures/libraries available here's what I'm using to compile my program
g++ -Wall chapter.12.3.cpp -o chapter.12.3
In file included from GUI.h:11,
from Simple_window.h:10,
from chapter.12.3.cpp:7:
Graph.h: In constructor ‘Graph_lib::Color::Color(Graph_lib::Color::Color_type)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:45: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Color::Color(Graph_lib::Color::Color_type, Graph_lib::Color::Transparency)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:46: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Color::Color(int)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:47: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Color::Color(Graph_lib::Color::Transparency)’:
Graph.h:56: warning: ‘Graph_lib::Color::c’ will be initialized after
Graph.h:55: warning: ‘char Graph_lib::Color::v’
Graph.h:48: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Rectangle::Rectangle(Point, int, int)’:
Graph.h:211: warning: ‘Graph_lib::Rectangle::w’ will be initialized after
Graph.h:210: warning: ‘int Graph_lib::Rectangle::h’
Graph.h:194: warning: when initialized here
Graph.h: In constructor ‘Graph_lib::Rectangle::Rectangle(Point, Point)’:
Graph.h:211: warning: ‘Graph_lib::Rectangle::w’ will be initialized after
Graph.h:210: warning: ‘int Graph_lib::Rectangle::h’
Graph.h:200: warning: when initialized here
In file included from Simple_window.h:10,
from chapter.12.3.cpp:7:
GUI.h: In member function ‘virtual void Graph_lib::Menu::show()’:
GUI.h:107: warning: comparison between signed and unsigned integer expressions
GUI.h: In member function ‘virtual void Graph_lib::Menu::hide()’:
GUI.h:112: warning: comparison between signed and unsigned integer expressions
GUI.h: In member function ‘virtual void Graph_lib::Menu::move(int, int)’:
GUI.h:117: warning: comparison between signed and unsigned integer expressions
Graph.h: In destructor ‘Graph_lib::Vector_ref<T>::~Vector_ref() [with T = Graph_lib::Button]’:
GUI.h:96: instantiated from here
Graph.h:130: warning: comparison between signed and unsigned integer expressions
Undefined symbols for architecture x86_64:
"Simple_window::Simple_window(Point, int, int, String const&)", referenced from:
_main in ccarbqNp.o
"Graph_lib::Polygon::add(Point)", referenced from:
_main in ccarbqNp.o
"Simple_window::wait_for_button()", referenced from:
_main in ccarbqNp.o
"Graph_lib::Shape::Shape()", referenced from:
Graph_lib::Open_polyline::Open_polyline()in ccarbqNp.o
"vtable for Graph_lib::Open_polyline", referenced from:
Graph_lib::Open_polyline::Open_polyline()in ccarbqNp.o
"vtable for Graph_lib::Open_polyline", referenced from:
Graph_lib::Open_polyline::Open_polyline()in ccarbqNp.o
Graph_lib::Open_polyline::~Open_polyline()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Closed_polyline", referenced from:
Graph_lib::Closed_polyline::Closed_polyline()in ccarbqNp.o
Graph_lib::Closed_polyline::~Closed_polyline()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Polygon", referenced from:
Graph_lib::Polygon::Polygon()in ccarbqNp.o
Graph_lib::Polygon::~Polygon()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Shape", referenced from:
Graph_lib::Shape::~Shape()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Button", referenced from:
Graph_lib::Button::~Button()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for Graph_lib::Window", referenced from:
Graph_lib::Window::~Window()in ccarbqNp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"Fl_Window::~Fl_Window()", referenced from:
Graph_lib::Window::~Window()in ccarbqNp.o
"Graph_lib::Window::draw()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::handle(int)", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::resize(int, int, int, int)", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::show()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::hide()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"Fl_Window::flush()", referenced from:
vtable for Simple_windowin ccarbqNp.o
"typeinfo for Graph_lib::Window", referenced from:
typeinfo for Simple_windowin ccarbqNp.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Compilation exited abnormally with code 1 at Fri Oct 21 12:48:23
it seems as though the library that I'm using libbookgui.a isn't compiled to the proper architecture but I could be incorrect.
when I check what the architecture the lib file is built I get:
/usr/local/lib/libbookgui.a: current ar archive random library
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论