Hyperledger-fabric1.0.0 version make docker Times error

because of the need of the project, we changed the core/chaincode/shim code of fabric1.0.0. The tree structure of the corresponding shim is as follows:

shim
 chaincode.go
 handler.go
 inprocstream.go
 interfaces.go
 java
  
 mockstub.go
 mockstub_test.go
 response.go
 myxxxutil.go
 shim_test.go
 myxxx.go

some of these functions require cgo, and then this part of the code is implemented using cPP. The corresponding code snippet is as follows:

///hyperledger/fabric/core/chaincode/shim/myxxx.go
package shim

/*
-sharpcgo CFLAGS: -I/opt/xxxsrc
-sharpcgo LDFLAGS: -L/usr/lib -lmyxxx
-sharpinclude "interface.hpp"
-sharpinclude <stdlib.h>
*/
import "C"

func SomeFucn() {
    
    ///opt/xxxsrccPPinterface.hpp/usr/liblibmyxxx.so
}

then, I use the make docker command under the fabric directory to make a peer image based on hyperledger/fabric-baseimage:x86_64-0.3.1. This hyperledger/fabric-baseimage:x86_64-0.3.1 has been modified by me. I put the libmyxxx.so file in the / usr/lib directory of the image, and the xxxsrc in the / opt/xxxsrc directory of the image. Then the corresponding execution log is as follows

.
Building build/docker/bin/peer

(docker:
docker run -i --rm --user=0 -v /home/my/gopath/src/github.com/hyperledger/fabric:/opt/gopath/src/github.com/hyperledger/fabric -w /opt/gopath/src/github.com/hyperledger/fabric -v /home/my/gopath/src/github.com/hyperledger/fabric/build/docker/bin:/opt/gopath/bin -v /home/my/gopath/src/github.com/hyperledger/fabric/build/docker/peer/pkg:/opt/gopath/pkg hyperledger/fabric-baseimage:x86_64-0.3.1 
go install -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.0 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.1 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger -linkmode external -extldflags -static -lpthread" github.com/hyperledger/fabric/peer
)

github.com/hyperledger/fabric/core/chaincode/shim
mkdir -p $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
CGO_LDFLAGS="-g" "-O2" "-L/usr/lib" "-lmyxxx" "-L/usr/lib" "-lmyxxx" /opt/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -importpath github.com/hyperledger/fabric/core/chaincode/shim -- -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -I/opt/xxxsrc -I/opt/xxxsrc myxxxutil.go myxxx.go
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_main.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_main.c
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/xxx.cgo2.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/xxx.cgo2.c
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_main.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxx.cgo2.o -g -O2 -L/usr/lib -lmyxxx -L/usr/lib -lmyxxx
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
/opt/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -dynpackage shim -dynimport $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_.o -dynout $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_import.go
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_all.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxx.cgo2.o -g -O2 -L/usr/lib -L/usr/lib -Wl,-r -nostdlib -no-pie -Wl,--build-id=none
/opt/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim.a -trimpath $WORK -p github.com/hyperledger/fabric/core/chaincode/shim -buildid 2ee9889b3f3fdd6fc02e5029d94e8c287f977ccb -importmap github.com/golang/protobuf/proto=github.com/hyperledger/fabric/vendor/github.com/golang/protobuf/proto -importmap github.com/golang/protobuf/ptypes/timestamp=github.com/hyperledger/fabric/vendor/github.com/golang/protobuf/ptypes/timestamp -importmap github.com/looplab/fsm=github.com/hyperledger/fabric/vendor/github.com/looplab/fsm -importmap github.com/op/go-logging=github.com/hyperledger/fabric/vendor/github.com/op/go-logging -importmap github.com/spf13/viper=github.com/hyperledger/fabric/vendor/github.com/spf13/viper -importmap golang.org/x/net/context=github.com/hyperledger/fabric/vendor/golang.org/x/net/context -importmap google.golang.org/grpc=github.com/hyperledger/fabric/vendor/google.golang.org/grpc -D _/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim -I $WORK -I /opt/gopath/pkg/linux_amd64 -pack ./chaincode.go ./fileIO.go ./handler.go ./inprocstream.go ./interfaces.go ./mockstub.go ./response.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_gotypes.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo1.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxx.cgo1.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_import.go
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
pack r $WORK/github.com/hyperledger/fabric/core/chaincode/shim.a $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_all.o -sharp internal
cp $WORK/github.com/hyperledger/fabric/core/chaincode/shim.a /opt/gopath/pkg/linux_amd64/github.com/hyperledger/fabric/core/chaincode/shim.a
/opt/go/pkg/tool/linux_amd64/link -o $WORK/github.com/hyperledger/fabric/peer/_obj/exe/a.out -L $WORK -L /opt/gopath/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=c7ee3188106eddcbae7255ad032536402bc38b29 -X github.com/hyperledger/fabric/common/metadata.Version=1.0.0 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.1 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger -linkmode external -extldflags "-static -lpthread" $WORK/github.com/hyperledger/fabric/peer.a
-sharp github.com/hyperledger/fabric/peer
/opt/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lmyxxx
/usr/bin/ld: cannot find -lmyxxx
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libltdl.a(dlopen.o): In function `vm_open":
(.text+0x5e): warning: Using "dlopen" in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-940349017/000001.o: In function `_cgo_7a2d42f1a351_C2func_getaddrinfo":
/tmp/workdir/go/src/net/cgo_unix.go:66: warning: Using "getaddrinfo" in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status

Makefile:197: recipe for target "build/docker/bin/peer" failed
make: *** [build/docker/bin/peer] Error 2

I have tried to add the path to the / etc/ld.so.conf file and execute ldconfig, and I have also tried to add the path to the environment variables LD_LIBRARY_PATH and LIBRARY_PATH, but the problem still reappears, so I would like to ask each god if there is any solution. Thank you

here.
Jun.28,2022
Menu