I'm trying to find a way to share a way to share a global function between executables which are in the same project.
In the first executable I ask the user for their name through std::cin and store it in a string nome variable, while in the second one I try and cout the nome variable.
I've already tried using extern in an header variable I then included in the second program, but I get this error:
Undefined symbols for architecture x86_64:
"_Nome", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Also tried externing the pointer, both while defining it in the first program and not, but it still doesn't compile.
Is there a way I can make it work, maybe by saving the value in an external file or by keeping it allocated after I terminate the first program?