-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/cgo: ld: symbol(s) not found for architecture x86_64 #31409
Comments
@ianlancetaylor @bcmills Can you please help me on this ? |
@bradfitz can I get help on this ? |
clang --version |
@nitishsaboo, you gave this only 8 hours before you started pinging everybody. Please be patient. Especially because your bug report looks more like a question (perhaps better suited to golang-nuts@ or another https://golang.org/wiki/Questions forum) than a bug report. |
I can't reproduce the failure (on Linux with a much older
Often with issues on MacOS we find that the problem is some issue with either a bad XCode installation or some additional (interfering) C toolchain installed somewhere in As a diagnostic step, could you try setting You could also try running |
If that doesn't help show us the complete output of |
I did not make any changes to CC environment variable. How did it work this time ? Output of go build -xWORK=/var/folders/3n/gnx8m6wx6zndptdxj3z3n61mfnyqn2/T/go-build101211381 But,
|
In the context of a cgo build, |
@bcmills Thanks for the clarification.So if my C libraries are not compiled and I use 'go build' to build the program and it generates a file(like greetings in above case), does it mean that I have no issues on MacOS with respect to environment and C compiler ? |
Probably yes. Your problems more likely have something to do with how the program is being built. |
i my case i put declartion of function in #ifndef _GREETER_H
#define _GREETER_H
int greet(const char *name, int year, char *out) {
int n;
n = sprintf(out, "Greetings, %s from %d! We come in peace :)", name, year);
return n;
}
#endif something like that. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Not Sure
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
greeter.c
greeter.h
maing.go
What did you expect to see?
I thought the code would build succesfully
What did you see instead?
command-line-arguments
Undefined symbols for architecture x86_64:
"_greet", referenced from:
__cgo_d6ff402930ca_Cfunc_greet in _x002.o
(maybe you meant: __cgo_d6ff402930ca_Cfunc_greet)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The text was updated successfully, but these errors were encountered: