Apple Mach-O Link (Id) Error - c

My code is identical to this question I asked earlier so there's no point in duplicating it here
This is the error I am getting:
Undefined symbols for architecture x86_64:
"_stdscr", referenced from:
_screen_init in screen.o
"_werase", referenced from:
_screen_init in screen.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've had this error in the past and I feel like it has something to do with a duplicate function name or something, but I have no idea how to debug this.
EDIT:
After adding the libncurses.dylib file to my project, the errors discussed above have disappeared, but a new error has emerged when I call screen_init(); in my main.cpp:
// main.cpp
#include "screen.h"
int main(){
screen_init();
}
// new error
Undefined symbols for architecture x86_64:
"screen_init()", 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)
Pretty much the same error except now in my main. Is there another library I am missing? These errors are very mysterious and not very helpful.

I guess you need to add the library to your link phase, if you are going with XCode you should add it in project details:
choose project details
choose build phases tab
open link binary with libraries part
click the plus symbol
add libncurses.dylib to your project.

Related

How to fix " Undefined symbols for architecture x86_64 " in C?

I have a header file included in the main but when I compile the main, I have an error saying that the linker failed.
I tried to find the object files but I cannot find them.
I think the problem may come from my machine. I am kind of a beginner so I don't know how to solve this
When I try compiling my code I get this error:
Undefined symbols for architecture x86_64:
"_intClassic", referenced from:
_main in main-53b7e4.o
"_intQuadrature", referenced from:
_main in main-53b7e4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#zwol #JonathanLeffer I have 3 files in my project main.c, integral.h
and integral.c. integral.c contains the code of the functions
intClassic and intQuadrature that allow me to calculate different
types of integral. In integral.h I declared the functions and
structures I use. Finally in the main I included integral.h .
Also $ gcc -o output file1.o file2.o can this command help me ?
In the same directory as your files, try running the command
gcc main.c integral.c -o integral
This should take the 2 files and compile them into a program called ./integral

Xcode C project - linker command failed

The problem is as follows.
I am trying to add two simple .obj files to my project. I have added a header file and I can see that obj is valid as Ttime structure, which is a part of obj is working. However, whenever I try to execute any function I get this error:
Undefined symbols for architecture x86_64:
"_printRES", 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)
Error Screenshot

Symbol(s) not found for architecture x86_64 while compiling a C file

I tried to run a c file using Mac Terminal. So I put the following command in the Terminal.
gcc main.c
And the following message was shown.
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Prior to this, I also tried to build a C project in Eclipse, but this also showed an error. It says there is one error which is symbol(s) not found for architecture x86_64.
your program is missing the entry point (main function), you have to add this function to your code source.
int main(void){
printf("Hello World");
}

Gstreamer first steps - "Undefined symbols..." error

Probably a noob question but I can't find an answer to this. I've downloaded and installed Gstreamer for Mac from http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-init.html
I copied the code for example 4.1, to initialize GStreamer, from
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-init.html into a file called eg41.c
and used the terminal command gcc eg41.c -I/Library/Frameworks/GStreamer.framework/Headers
. The output was:
Undefined symbols for architecture x86_64:
"_gst_init", referenced from: _main in eg41-9814a5.o
"_gst_version", referenced from: _main in eg41-9814a5.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?

Reachability Errors

Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Reachability", referenced from:
objc-class-ref in FirstViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've looked over FirstViewController, reachability.h and reachability.m - It's clearly defined! And I've even added SystemConfiguration.Framework, as well as Reachability.m is in the compile list.
Any ideas? I'm losing my mind!
Pic attached.
http://i.imgur.com/uw4Zb.png
Try to remove references to Reachability.h and Reachability.m files from your xCode project. - Make sure it disappears from Compile Sources.
Search you project's folder to make sure you don't have duplicates for Reachability.h and Reachability.m files in it
Command+Shift+K to clean the project;
Add Reachability.h and Reachability.m back to the xCode project;
Hope this will help.

Resources