You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a C++ shared library in /opt/xx/lib64. Headers are in C. In my go code, I am including proper header and linker options using CPPFLAGS/CFLAGS and LDFLAGS. Still while building go I am getting 'undefined reference` error.
/tmp/go-build609413262/b163/_x002.o: In function `_cgo_e38947506e9d_Cfunc_um_get_lastlogin_info':
/tmp/go-build/cgo-gcc-prolog:52: undefined reference to `um_get_lastlogin_info'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:48: vet] Error 2
Library is exist in the right path and do contain the required method. Not sure why this error.
cgo is integrating C and Go, not C++ and Go. You can compile and use C++ sources/libs but to use those inside Go sources you need to make it into something you can call from C.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have a C++ shared library in /opt/xx/lib64. Headers are in C. In my go code, I am including proper header and linker options using CPPFLAGS/CFLAGS and LDFLAGS. Still while building go I am getting 'undefined reference` error.
What did you expect to see?
successful build
What did you see instead?
I am getting this linking errors:
Library is exist in the right path and do contain the required method. Not sure why this error.
Also tried using the pkg-config with cgo. Still the same linking error appears.
The text was updated successfully, but these errors were encountered: