Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
799 views
in Technique[技术] by (71.8m points)

c++ - Make Error: Undefined symbols for architecture x86_64

I'm a pretty novice programmer (as in I only code when I need to), but I mostly work in television. I've been trying to compile a tool I downloaded (bmdtools) for compilation on OSX because we (for whatever reason) are not allowed to use Linux machines.

So, after installing all the libraries and linking what I need to, I ran "make" and got the error message:

ld: symbol(s) not found for architecture x86_64

I had then read that adding -stdlib=libc++ would fix whatever issue was being reflected. And this time it finishes, creating all three files that should be created. However, those three files are completely blank. Zero bytes.

Any help or insight would be greatly appreciated. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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();
};

enter image description here

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...