Looking for a good a explanation on behaviour of cgo during go build vs go test.

63 views
Skip to first unread message

Ullas HV

unread,
Feb 10, 2025, 1:48:47 PM2/10/25
to golang-nuts
I recently ran into a problem where go build (with cgo) was successfull but go test of a function reported an error stated below.

"error while loading shared libraries: libtcmalloc.so.4: cannot open shared object file: No such file or directory
exit status 127"




Kurtis Rader

unread,
Feb 10, 2025, 2:07:54 PM2/10/25
to Ullas HV, golang-nuts
Just guessing but it is likely due to environment variables, such as LD_LIBRARY_PATH, present when you run your binary but not when you run "go test". Possibly because "go test" doesn't pass the env var to the code being tested. 

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/fb54f400-48b3-4a4e-ba25-ae1516dd8308n%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
Reply all
Reply to author
Forward
0 new messages