Multiple Definition Error when using whole-archive linker option

338 views
Skip to first unread message

Athith [Outlook] Amarnath

unread,
Jul 28, 2020, 10:48:04 PM7/28/20
to golang-nuts
Hello,

I am working on upgrading go version on our service from 1.9.6 to 1.14.6. We are linking static libraries to the executable using the following makefile script. 

export CGO_LDFLAGS="-Wl,--start-group -Wl,--whole-archive -lsmuxed_a -Wl,--no-whole-archive -l:libx265.a $(addprefix -l,${GO_LIBS}) -Wl,--end-group $(addprefix -L,${GO_LIB_PATHS})"; \
cd ${OUT} && ${CURDIR}/${GO_PATH}/bin/go build -x -ldflags '-X dynaserve.version=$(strip $(shell cat version.txt))' -o dynapackd ${CURDIR}/src/server.go

Archive in question - libsmuxed.a - whole-archive option is required for the executable to work. 

GO_LIBS = does not include libsmuxed.a

The above script works fine on go 1.9.6. 

After updating to 1.14.6, I am facing multiple definition issues for the whole libsmuxed.a static library. From the errors, It seems like the library in linked twice. 

I am able to successfully test the executable only if --allow-multiple-definition option is added to CGO_LDFLAGS. I think this can be a temporary solution until i figure out why go build linker is linking libraries with whole-archive twice.

Could you please let me know how to solve this issue? 

Thanks,

Best,
Athith
Reply all
Reply to author
Forward
0 new messages