Make Error: Undefined symbols for architecture x86_64

試著忘記壹切 提交于 2019-11-28 09:31:56

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/33488801/make-error-undefined-symbols-for-architecture-x86-64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!