I always get an error on VS code when I code in c - c

I have just started coding in c on my MacBook Air(m1). But whenever I code anything on VS code it throws the following error.
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)
I have installed all the extensions and the clang as well but it always shows this error. I am new to coding and have very little idea about it.

Related

Cross Compiling for x64 on ARM (Apple Silicon)

It is definitely possible to target Intel when compiling on an Apple Silicon (ARM64) system, as Xcode does that all the time when building universal bundles of an app. However, I am unable to replicate this compiling a C program with make (specifically Stockfish).
What I've tried
I'm invoking make like so: make build ARCH=x86-64-modern COMP=clang (the same command works when I substitute x86-64-modern for apple-silicon). I've tried using the gcc compiler, which also worked when targeting the apple-silicon arch.
The problem
The make build command terminates with a bunch of errors, most importantly:
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)
Above the error is a bunch of lines complaining that a file was built for an "unknown bitcode architecture:
ld: warning: ignoring file <name>.o, lto file was built for unknown bitcode architecture which is not the architecture being linked (x86_64): <name>.o
So, it seems like the compilation phase succeeds, but the linking phase fails due to missing symbols. How would I acquire and provide the missing symbols to ld such that it can link successfully?

Installing C API for Tensorflow on Macbook M1

I am trying to install C API of tensorflow on Macbook M1 to execute it in Go. I followed this guide by tensorflow developers but got stuck when running the hello_tf.c file with this command gcc hello_tf.c -ltensorflow -o hello_tf.
This is hello_tf.c file
#include <stdio.h>
#include <tensorflow/c/c_api.h>
int main() {
printf("Hello from TensorFlow C library version %s\n", TF_Version());
return 0;
}
And this is the error log:
ld: warning: ignoring file /usr/local/lib/libtensorflow.2.7.0.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_TF_Version", referenced from:
_main in hello_tf-6f1778.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation
Any suggestions on how to get the compilation fixed?

Connecting to Couchbase Server using C SDK

I've been trying to connect to a Couchbase. cluster using the C SDK but have been getting this error :
"_lcb_createopts_connstr", referenced from:
_main in minimal.c.o
"_lcb_createopts_create", referenced from:
_main in minimal.c.o
"_lcb_createopts_credentials", referenced from:
_main in minimal.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
OS : macOS Big Sur.
Any help would be greatly appreciated.
The error occurs during the linking phase. Ensure that you have properly configure your linker to use the libcouchbase.

I installed gcc but when i compile my code there is a problem with clang

I installed gcc on my mac os but i don't it doesn't work due to a clang module, i used gcc my_program.c -Wall -o prog.
I have tried to reinstall and to follow some answers online , it doesn't work
When i compiled i got this in my terminal :
Undefined symbols for architecture x86_64:
"_omp_get_thread_num", referenced from:
_tri_pair_impair in tri_pair_impair-a7c555.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 except to be able to compile my C code with gcc to do parallel computing

Linking error using TensorFlow for C on Mac: Undefined symbols for architecture x86_64: "_TF_Version", referenced from: _main in main.o

I am working on Mac and I installed TensorFlow for C following this tutorial: https://www.tensorflow.org/install/install_c
When I try to validate the installation by running the tutorial example "hello_tf.c" I get the following message error:
Undefined symbols for architecture x86_64:
"_TF_Version", 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)
I installed TensorFlow by looking this tutorial here https://www.tensorflow.org/install/install_mac and the validation was successful.
How can I fix this problem? I would be also interested to know the reasons for this issue

Resources