0

Following this question, I'm trying to compile this code, where I get this error message:

Undefined symbols for architecture x86_64: "_<someFunction>", referenced from: _<someOtherFunction> in <someFile>.o _<yetAnotherFunction> <someOtherFile>.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [<someApp>.app/Contents/MacOS/<someApp>] Error 1

which you may see the complete version here.

I installed libelf via HomeBrew. and modified the .pro file to:

macx {
    DEFINES += __LIBELF_INTERNAL__
    INCLUDEPATH += /usr/local/Cellar/libelf/0.8.13_1/include/libelf/ 
    QMAKE_LIBS += -L/usr/local/Cellar/libelf/0.8.13_1/lib/
} else {
    QMAKE_LIBS += -lelf
}

But didn't help. I have also tried downloading and compiling different versions of the libelf library with no avail.

I would appreciate it if you could help me know:

  1. what does this error message mean? Is there a problem in the qmake .pro file here? Or the installed/compiled library is not X64 compatible?
  2. How can I solve this specific problem?

P.S.1. I deliberately exclude the complete error message because I primarily want to understand the meaning of this error message rather than solving the specific problem. I tried to avoid cluttering my question in favor of conciseness and readability.

P.S.2. running the lipo -info /path/to/libelf.a returns

Non-fat file: /path/to/libelf.a is architecture: x86_64

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
  • 1
    Sure that _libelf_ doesn't depend on other libraries? How are these missing symbols are appearing in that library when you inspect them with `nm` or a similar tool? Regarding to the meaning of the error message there's a detauked description of possible causes here: https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix – πάντα ῥεῖ Oct 05 '20 at 22:01
  • @πάνταῥεῖ 1. I suppose it doesn't have any dependencies as both the HomeBrew installation and the manual compile finish successfully with no errors. 2. I have no idea what the `nm` tool is. give me some clue, please. !. will look into the link. thanks. – Foad S. Farimani Oct 05 '20 at 22:05
  • @PhillipMills checked both HomeBrew and the manual compiled version with `file libelf.a`, both return `current ar archive random library`. No idea what that means! – Foad S. Farimani Oct 05 '20 at 22:07
  • 1
    Well, the exact name of that tool depends on your toolchain. You can find more information about `nm` (part of the GNU toolchain) here: https://ftp.gnu.org/old-gnu/Manuals/binutils-2.12/html_node/binutils_4.html – πάντα ῥεῖ Oct 05 '20 at 22:10
  • 1
    Sorry about misleading you. Seems `file` only works if the library has multiple architectures. In that case it lists each of them. – Phillip Mills Oct 05 '20 at 22:14
  • @PhillipMills you actually helped me find the `lipo`. so thanks, buddy. – Foad S. Farimani Oct 05 '20 at 22:15
  • @πάνταῥεῖ running the `nm -arch x86_64 libelf.a` dumps a whole bunch of outputs to the terminal. How should I interpret that? – Foad S. Farimani Oct 05 '20 at 22:16
  • 1
    @Foad There's an option (`-u` IIRC) to output the referenced externals only. Also there's a more detailed description in the `man` page I linked in my comment. – πάντα ῥεῖ Oct 05 '20 at 22:19

0 Answers0