I am having a problem with object link files on Mac OS X. Tracking the problem, here is my worldwide C hello program
#include <stdio.h> int main(){ printf("Hello, world!\n"); return 0; }
// Compile with gcc (clang LLVM compiler on Mac)
$ gcc -c hello.c
The output file is a hello.o link to gcc and the launch of the executable
$ gcc hello.o -o hello $ ./hello
Now I have to use the lc or ld program for the mac linker to link the object files instead of gcc. In this case, what arguments should be passed to the ld program to run the program? A simple pass in the name of the object file, i.e.
$ ld hello.o
resulting in
ld: warning: -macosx_version_min not specified, assuming 10.6 Undefined symbols for architecture x86_64: "_printf", referenced from: _main in hello.o "start", referenced from: implicit entry/start for main executable ld: symbol(s) not found for inferred architecture x86_64
So, what other files that I need to include in the link or architecture information that I need to specify? Thank you
gcc x86-64 linker ld macos
Skyoasis
source share