How to add search path with cgo

Current problem : Can’t compile this item with c code.

my project structure:

 ----item
     ----goModule  #go module
     ----include      #include .c .h .cxx file
 main.go

I just run the command

go build -x 

get results

TERM='dumb' gcc -I /home/dylan/code/demo/test -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b002=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -DCGO_OS_LINUX=0 -I/home/dylan/code/demo/test/../include -o ./_cgo_main.o -c _cgo_main.c
cd /home/dylan/code/demo
TERM='dumb' gcc -I ./goModule -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b002=/tmp/go-build -gno-record-gcc-switches -o $WORK/b002/_cgo_.o $WORK/b002/_cgo_main.o $WORK/b002/_x001.o $WORK/b002/_x002.o -g -O2 -L/home/dylan/code/demo/goModule/../lib/linux.x64 -lsomelib
/usr/bin/ld: $WORK/b002/_x002.o: in function `function':
/tmp/go-build/cgo-gcc-prolog:52: undefined reference to `function'

How could I add “-I ./include” on the second execute statement.

If I mv all include/ file to the ./goModule dir,it builds success

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.