ld: symbol(s) not found for architecture x86_64
I've always thought this message to be confusing as people tend to focus on the "for architecture x86_64" part of the message. The actual problem here is that a symbol is not found. So, practically, what does this mean?
If we create a class and declare a function, but don't implement that function's body, the same error will be presented, as the compilation/linker process has been told that a function exists, but can't find it.
The line below the symbol(s) not found for achitecture x86_4 will usually identify what has not been found.
Let's look at an example: -
class PGGui
{
public:
PGGui::PGGui(QObject*)
{
DoSomeStuff();
}
private:
DoSomeStuff();
};
This tells us that a class PGGui
has declared a function DoStuff
, which was referenced from the PGGui
constructor: PGGui::PGGui(QObject*)
, but the function body can't be found.
As you can see, here, just looking at the first line of the error message doesn't help very much. You need to read the rest of the error to see what is missing, which may be the body of a function, or the inclusion of a library or some other object.
You'll find software development easier if you begin by trying to understand error messages, rather than simply searching the web for the error and hoping someone else's problem and solution matches your own.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…