I compiled a Zig project using -Doptimize=ReleaseSmall to a library file. When I link against this file using gcc I get an error message from my linker saying undefined reference to '\__zig_probe_stack’
However, when I compile with any other optimize mode, I don’t receive this error. Moreover, when I compile with zig cc, I also don’t receive it.
How can I make this symbol “available” (forgive me, linkers aren’t my forte so I don’t know the correct term) to my linker?
Notes:
- my
zig versionis “0.15.2” - my OS is “Linux Mint 22.2 x86_64”
- The library file is compiled with this command:
zig build install -Dtarget=x86_64-linux-gnu -Doptimize=ReleaseSafe - The source code is linked with this command:
gcc demo-anyline.c -o demo-anyline libanyline.a - The library code can be found here.
- The source code being linked:
//demo-anyline.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "anyline.h"
int main(void)
{
using_history();
char *filename = "/home/theshinx317/Coding/C/anyline-export/.demo_history";
read_history(filename);
for (;;) {
char *line = readline(">> ");
if(strcmp(line, ".exit") == 0) {
break;
}
add_history(line);
}
write_history(filename);
return 0;
}
//anyline.h
extern char *readline (const char *prompt);
extern void add_history (const char *line);
extern int read_history (const char *filename);
extern int write_history (const char *filename);
extern void using_history(void);