Undefined symbols for architecture arm64
Kenneth Wolcott
kennethwolcott at gmail.com
Sat Mar 15 03:25:47 UTC 2025
Thank you, Brian.
I decided to use clang with two of the suggestions in the article you
shared.
The original version is maintained as is, and it fails, even with
optimazation disabled.
The second version redefines the inline functions as static inline, and
this works great.
The thrid version removes the inline concept entirely, and it works great
as well.
Thanks again,
Ken Wolcott
On Fri, Mar 14, 2025 at 7:33 PM brian <bholder+macports at gmail.com> wrote:
> See https://www.geeksforgeeks.org/inline-function-in-c/ for various
> solutions.
>
> Thanks.
>
> On Fri, Mar 14, 2025 at 6:53 PM Kenneth Wolcott <kennethwolcott at gmail.com>
> wrote:
>
>> Hi;
>>
>> Problem: Undefined symbols for architecture arm64
>>
>> MacOS Sequoia (arm64). Ports are up-to-date.
>>
>> I was compiling a C example of a Rosetta Code task recently..
>>
>> https://rosettacode.org/wiki/Vampire_number#C
>>
>> Here's my clang error(s):
>> clang -lm -o ./vampire_number ./vampire_number.c
>> Undefined symbols for architecture arm64:
>> "_dtally", referenced from:
>> _fangs in vampire_number-2cd7e6.o
>> _fangs in vampire_number-2cd7e6.o
>> _fangs in vampire_number-2cd7e6.o
>> "_max", referenced from:
>> _fangs in vampire_number-2cd7e6.o
>> "_min", referenced from:
>> _fangs in vampire_number-2cd7e6.o
>> "_ndigits", referenced from:
>> _fangs in vampire_number-2cd7e6.o
>> ld: symbol(s) not found for architecture arm64
>> clang: error: linker command failed with exit code 1 (use -v to see
>> invocation)
>>
>> Here's my gcc errors:
>> /opt/local/bin/gcc-mp-14 -lm-o ./vampire_number ./vampire_number.c
>> Undefined symbols for architecture arm64:
>> "_dtally", referenced from:
>> _fangs in ccjmm7mz.o
>> _fangs in ccjmm7mz.o
>> _fangs in ccjmm7mz.o
>> "_max", referenced from:
>> _fangs in ccjmm7mz.o
>> "_min", referenced from:
>> _fangs in ccjmm7mz.o
>> "_ndigits", referenced from:
>> _fangs in ccjmm7mz.o
>> ld: symbol(s) not found for architecture arm64
>> collect2: error: ld returned 1 exit status
>>
>> Here's the source I was trying to compile:
>>
>> #include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <math.h>
>> typedef uint64_t xint;typedef unsigned long long ull;
>> xint tens[20];
>> inline xint max(xint a, xint b) { return a > b ? a : b; }inline xint min(xint a, xint b) { return a < b ? a : b; }inline int ndigits(xint x){ int n = 0; while (x) n++, x /= 10; return n;}
>> inline xint dtally(xint x){ xint t = 0; while (x) t += 1<<((x%10) * 6), x /= 10;
>> return t;}
>> int fangs(xint x, xint *f){ int n = 0; int nd = ndigits(x); if (nd & 1) return 0; nd /= 2;
>> xint lo, hi; lo = max(tens[nd-1], (x + tens[nd] - 2)/ (tens[nd] - 1)); hi = min(x / lo, sqrt(x));
>> xint a, b, t = dtally(x); for (a = lo; a <= hi; a++) { b = x / a; if (a * b == x && ((a%10) || (b%10)) && t == dtally(a) + dtally(b)) f[n++] = a; }
>> return n;}
>> void show_fangs(xint x, xint *f, xint cnt){ printf("%llu", (ull)x); int i; for (i = 0; i < cnt; i++) printf(" = %llu x %llu", (ull)f[i], (ull)(x / f[i])); putchar('\n');}
>> int main(void){ int i, j, n; xint x, f[16], bigs[] = {16758243290880ULL, 24959017348650ULL, 14593825548650ULL, 0};
>> tens[0] = 1; for (i = 1; i < 20; i++) tens[i] = tens[i-1] * 10;
>> for (x = 1, n = 0; n < 25; x++) { if (!(j = fangs(x, f))) continue; printf("%2d: ", ++n); show_fangs(x, f, j); }
>> putchar('\n'); for (i = 0; bigs[i]; i++) { if ((j = fangs(bigs[i], f))) show_fangs(bigs[i], f, j); else printf("%llu is not vampiric\n", (ull)bigs[i]); }
>> return 0;}
>>
>> So, what am I missing?
>>
>> What more information do you need to diagnose the problem?
>>
>> Thanks,
>>
>> Ken Wolcott
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20250314/685d5675/attachment.htm>
More information about the macports-users
mailing list