Xcode C project - linker command failed - c

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

Related

building for macOS-x86_64 but attempting to link with file built for macOS-arm64 compilation error on OpenMPI

I am trying to install and run OpenMPI on VSCode using this tutorial https://medium.com/#li.nguyen_15905/setting-up-vscode-for-mpi-programming-b6665da6b4ad
When I "Run build task" to compile the Hello.c file I receive this error:
(`Executing task: C/C++: mpicc build active file <
Starting build...
/Users/mohamad/opt/usr/local/bin/mpicc -g /Users/mohamad/opt/usr/local/bin/helloworld/.vscode/hello.c -o /Users/mohamad/opt/usr/local/bin/helloworld/.vscode/hello
ld: warning: ignoring file /Users/mohamad/opt/usr/local/lib/libmpi.dylib, **building for macOS-x86_64 but attempting to link with file built for macOS-arm64**
Undefined symbols for architecture x86_64:
"_MPI_Comm_rank", referenced from:
_main in hello-c829ad.o
"_MPI_Comm_size", referenced from:
_main in hello-c829ad.o
"_MPI_Finalize", referenced from:
_main in hello-c829ad.o
"_MPI_Get_processor_name", referenced from:
_main in hello-c829ad.o
"_MPI_Init", referenced from:
_main in hello-c829ad.o
"_ompi_mpi_comm_world", referenced from:
_main in hello-c829ad.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Build finished with error(s).
The terminal process failed to launch (exit code: -1).`)
Running the command mpirun -np 2 hello gives:
mpirun was unable to find the specified executable file, and therefore
did not launch the job. This error was first reported for process
rank 0; it may have occurred for other processes as well.
NOTE: A common cause for this error is misspelling a mpirun command
line parameter option (remember that mpirun interprets the first
unrecognized command line token as the executable).
Node: Mohamads-MBP
Executable: hello
--------------------------------------------------------------------------
2 total processes failed to start
Any suggestions that could resolve this issue?
Note: All configuration settings used are included in the link.

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

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?

Apple Mach-O Link (Id) Error

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.

Resources