when I developed the chaincode of fabric, I used cgo. The structure of the code is as follows
./my_cc
vendor
somecgopkg
build
interface.o
test
test.o
lib
libxxx.so
mypkg.go
mypkg_test.go
src
mycfile.cpp
mycfile.hpp
my_cc.go
my_cc_test.go
the code snippet of the mypkg.go file is as follows
package somecgopkg
/*
-sharpcgo CFLAGS: -I./src
-sharpcgo LDFLAGS: -L./lib -lxxx
-sharpinclude "mycfile.hpp"
-sharpinclude <stdlib.h>
*/
import "C"
func SomeFunc() {
...
}
...
when I run the command to install chaincode in the cli image of fabric, it returns OK, but from the log point of view, some directories have been skipped:
root@5fd8cb9033c8:/opt/gopath/src/github.com/hyperledger/fabric/peer-sharp peer chaincode install -n mycc_a -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/my_cc/
2019-02-13 02:16:46.505 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2019-02-13 02:16:46.505 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2019-02-13 02:16:46.506 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2019-02-13 02:16:46.506 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2019-02-13 02:16:46.802 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/my_cc/
2019-02-13 02:16:47.580 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package bytes
2019-02-13 02:16:47.580 UTC [golang-platform] func1 -> DEBU 007 Discarding GOROOT package crypto/rand
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 008 Discarding GOROOT package crypto/rsa
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package crypto/sha256
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 00a Discarding GOROOT package crypto/x509
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 00b Discarding GOROOT package encoding/gob
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 00c Discarding GOROOT package encoding/hex
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 00d Discarding GOROOT package encoding/json
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 00e Discarding GOROOT package encoding/pem
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 00f Discarding GOROOT package errors
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 010 Discarding GOROOT package fmt
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 011 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 012 Discarding provided package github.com/hyperledger/fabric/protos/peer
2019-02-13 02:16:47.581 UTC [golang-platform] func1 -> DEBU 013 Accepting import: github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/somecgopkg
2019-02-13 02:16:47.700 UTC [golang-platform] func1 -> DEBU 014 skipping dir: /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor
2019-02-13 02:16:47.701 UTC [golang-platform] GetDeploymentPayload -> DEBU 015 processing dep: runtime/cgo
2019-02-13 02:16:47.701 UTC [golang-platform] GetDeploymentPayload -> DEBU 016 checking: /opt/gopath/src/runtime/cgo exists: false
2019-02-13 02:16:47.708 UTC [golang-platform] GetDeploymentPayload -> DEBU 017 processing dep: runtime/internal/sys
2019-02-13 02:16:47.708 UTC [golang-platform] GetDeploymentPayload -> DEBU 018 checking: /opt/gopath/src/runtime/internal/sys exists: false
2019-02-13 02:16:47.708 UTC [golang-platform] GetDeploymentPayload -> DEBU 019 processing dep: strings
2019-02-13 02:16:47.708 UTC [golang-platform] GetDeploymentPayload -> DEBU 01a checking: /opt/gopath/src/strings exists: false
2019-02-13 02:16:47.708 UTC [golang-platform] GetDeploymentPayload -> DEBU 01b processing dep: syscall
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 01c checking: /opt/gopath/src/syscall exists: false
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 01d processing dep: github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/somecgopkg
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 01e checking: /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/somecgopkg exists: true
2019-02-13 02:16:47.709 UTC [golang-platform] func1 -> DEBU 020 skipping dir: /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/snark/build
2019-02-13 02:16:47.709 UTC [golang-platform] func1 -> DEBU 021 skipping dir: /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/snark/lib
2019-02-13 02:16:47.709 UTC [golang-platform] func1 -> DEBU 022 skipping dir: /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/snark/src
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 023 processing dep: io/ioutil
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 024 checking: /opt/gopath/src/io/ioutil exists: false
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 025 processing dep: os
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 026 checking: /opt/gopath/src/os exists: false
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 027 processing dep: unicode/utf8
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 028 checking: /opt/gopath/src/unicode/utf8 exists: false
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 029 processing dep: bytes
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 02a checking: /opt/gopath/src/bytes exists: false
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 02b processing dep: io
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 02c checking: /opt/gopath/src/io exists: false
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 02d processing dep: runtime
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 02e checking: /opt/gopath/src/runtime exists: false
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 02f processing dep: sync/atomic
2019-02-13 02:16:47.709 UTC [golang-platform] GetDeploymentPayload -> DEBU 030 checking: /opt/gopath/src/sync/atomic exists: false
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 031 processing dep: time
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 032 checking: /opt/gopath/src/time exists: false
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 033 processing dep: unicode
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 034 checking: /opt/gopath/src/unicode exists: false
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 035 processing dep: internal/race
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 036 checking: /opt/gopath/src/internal/race exists: false
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 037 processing dep: math
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 038 checking: /opt/gopath/src/math exists: false
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 039 processing dep: sort
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 03a checking: /opt/gopath/src/sort exists: false
2019-02-13 02:16:47.710 UTC [golang-platform] GetDeploymentPayload -> DEBU 03b processing dep: reflect
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 03c checking: /opt/gopath/src/reflect exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 03d processing dep: runtime/internal/atomic
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 03e checking: /opt/gopath/src/runtime/internal/atomic exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 03f processing dep: strconv
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 040 checking: /opt/gopath/src/strconv exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 041 processing dep: sync
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 042 checking: /opt/gopath/src/sync exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 043 processing dep: unsafe
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 044 checking: /opt/gopath/src/unsafe exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 045 processing dep: errors
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 046 checking: /opt/gopath/src/errors exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 047 processing dep: fmt
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 048 checking: /opt/gopath/src/fmt exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 049 processing dep: path/filepath
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 04a checking: /opt/gopath/src/path/filepath exists: false
2019-02-13 02:16:47.711 UTC [golang-platform] GetDeploymentPayload -> DEBU 04b done
2019-02-13 02:16:47.740 UTC [msp/identity] Sign -> DEBU 04c Sign: plaintext: 0A8A070A5C08031A0C088FFC8DE30510...093FFF3F0000FFFFE5FA921700C00000
2019-02-13 02:16:47.740 UTC [msp/identity] Sign -> DEBU 04d Sign: digest: 4529734ACA754DF88840CCAD000157DF23B5A487A3C9EB5F08E995A0FF29BB13
2019-02-13 02:16:47.756 UTC [chaincodeCmd] install -> DEBU 04e Installed remotely response:<status:200 payload:"OK" >
2019-02-13 02:16:47.756 UTC [main] main -> INFO 04f Exiting.....
then I instantiate the chaincode
root@5fd8cb9033c8:/opt/gopath/src/github.com/hyperledger/fabric/peer-sharp peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -v 1.0 -c "{"Args":["init",""]}" -P "OR ("Org1MSP.member","Org2MSP.member")"
2019-02-13 02:33:33.373 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2019-02-13 02:33:33.373 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2019-02-13 02:33:33.425 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2019-02-13 02:33:33.425 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2019-02-13 02:33:33.464 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C08FD838EE30510...324D53500A04657363630A0476736363
2019-02-13 02:33:33.465 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 196D6DA2D9A01A1E1E7E788C23145D21281905DCB190C676533B86987A846715
Error: Error endorsing chaincode: rpc error: code = Unknown desc = Error starting container: Failed to generate platform-specific docker build: Error returned from build: 2 "-sharp github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/somecgopkg
chaincode/input/src/github.com/hyperledger/fabric/examples/chaincode/go/my_cc/vendor/somecgopkg/mypkg.go:6:25: fatal error: mycfile.hpp: No such file or directory
first of all, to test the somecgopkg in vendor locally, all the functions related to cgo are working normally. When I use this package as a third-party package, there will be a problem that I can"t find mycfile.hpp. I would like to ask you if you can use cgo in fabric"s chaincode. If so, what is the problem on my side? Thank you