obs-browser icon indicating copy to clipboard operation
obs-browser copied to clipboard

Cannot build package: exit status 2

Open gaurav8297 opened this issue 5 years ago • 6 comments

Getting this error while trying to run plgo example/

2020/04/21 19:00:25 /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo381626588
runtime/cgo
command-line-arguments
# command-line-arguments
Undefined symbols for architecture x86_64:
  "_DirectFunctionCall1Coll", referenced from:
      _jsonb_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_jsonb_to_datum in _x003.o
  "_JsonbToCString", referenced from:
      _datum_to_jsonb_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_jsonb_cstring in _x003.o
  "_SPI_connect", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_connect in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_connect)
  "_SPI_execute_plan", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_execute_plan in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_execute_plan)
  "_SPI_finish", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_finish in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_finish)
  "_SPI_fname", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_fname in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_fname)
  "_SPI_getbinval", referenced from:
      _get_col_as_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_get_col_as_datum in _x003.o
  "_SPI_gettype", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_gettype in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_gettypeid, __cgo_9759c58d933a_Cfunc_SPI_gettype )
  "_SPI_gettypeid", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_gettypeid in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_gettypeid)
  "_SPI_prepare", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_prepare in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_prepare)
  "_SPI_processed", referenced from:
      __cgohack_SPI_processed in _cgo_main.o
     (maybe you meant: __cgohack_SPI_processed)
  "_SPI_result", referenced from:
      __cgohack_SPI_result in _cgo_main.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_result_code_string, __cgohack_SPI_result )
  "_SPI_result_code_string", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_result_code_string in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_result_code_string)
  "_SPI_tuptable", referenced from:
      __cgohack_SPI_tuptable in _cgo_main.o
     (maybe you meant: __cgohack_SPI_tuptable)
  "_construct_md_array", referenced from:
      _array_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_array_to_datum in _x003.o
  "_cstring_to_text", referenced from:
      _cstring_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_cstring_to_datum in _x003.o
  "_deconstruct_array", referenced from:
      _datum_to_array in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_array in _x003.o
  "_elog_finish", referenced from:
      _elog_notice in _x003.o
      __cgo_9759c58d933a_Cfunc_elog_notice in _x003.o
      _elog_error.cold.1 in _x003.o
  "_elog_start", referenced from:
      _elog_notice in _x003.o
      __cgo_9759c58d933a_Cfunc_elog_notice in _x003.o
      _elog_error.cold.1 in _x003.o
  "_get_call_expr_argtype", referenced from:
      __cgo_9759c58d933a_Cfunc_get_call_expr_argtype in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_get_call_expr_argtype)
  "_get_typlenbyvalalign", referenced from:
      _array_to_datum in _x003.o
      _datum_to_array in _x003.o
      __cgo_9759c58d933a_Cfunc_array_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_array in _x003.o
  "_getmissingattr", referenced from:
      _get_heap_getattr in _x003.o
  "_heap_form_tuple", referenced from:
      __cgo_9759c58d933a_Cfunc_heap_form_tuple in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_heap_form_tuple)
  "_heap_getsysattr", referenced from:
      _get_heap_getattr in _x003.o
  "_jsonb_in", referenced from:
      _jsonb_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_jsonb_to_datum in _x003.o
  "_nocachegetattr", referenced from:
      _get_heap_getattr in _x003.o
  "_palloc", referenced from:
      _bytes_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_bytes_to_datum in _x003.o
  "_palloc0", referenced from:
      _array_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_array_to_datum in _x003.o
  "_parseTypeString", referenced from:
      __cgo_9759c58d933a_Cfunc_parseTypeString in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_parseTypeString)
  "_pg_detoast_datum", referenced from:
      _jsonb_to_datum in _x003.o
      _datum_to_array in _x003.o
      _datum_to_jsonb_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_array in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_jsonb_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_jsonb_to_datum in _x003.o
  "_pg_detoast_datum_packed", referenced from:
      _datum_to_byteap in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_byteap in _x003.o
  "_text_to_cstring", referenced from:
      _datum_to_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_cstring in _x003.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Cannot build package: exit status 2

gaurav8297 avatar Apr 21 '20 13:04 gaurav8297

what prints this out? pg_config --includedir-server

microo8 avatar Apr 21 '20 14:04 microo8

This is the path /usr/local/Cellar/[email protected]/9.6.17/include/server

gaurav8297 avatar Apr 21 '20 14:04 gaurav8297

on pg9 it will not work. try to install pg12

microo8 avatar Apr 21 '20 14:04 microo8

@microo8 Getting the same error with pg 12

2020/04/21 20:16:13 /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo155257375
WORK=/var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/go-build501198397
mkdir -p $WORK/b045/
cd /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/cgo
CGO_LDFLAGS='"-g" "-O2" "-lpthread"' /usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64/cgo -objdir $WORK/b045/ -importpath runtime/cgo -import_runtime_cgo=false -import_syscall=false -exportheader=$WORK/b045/_cgo_install.h -- -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror ./cgo.go
cd $WORK
clang -fno-caret-diagnostics -c -x c - -o /dev/null || true
clang -Qunused-arguments -c -x c - -o /dev/null || true
clang -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
clang -gno-record-gcc-switches -c -x c - -o /dev/null || true
cd $WORK/b045
TERM='dumb' clang -I /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/cgo -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -Wno-nullability-completeness -Wall -Werror -o ./_x001.o -c _cgo_export.c
TERM='dumb' clang -I /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/cgo -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -Wno-nullability-completeness -Wall -Werror -o ./_x002.o -c cgo.cgo2.c
cd /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/cgo
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b045/_x003.o -c gcc_context.c
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b045/_x004.o -c gcc_darwin_amd64.c
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b045/_x005.o -c gcc_libinit.c
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b045/_x006.o -c gcc_setenv.c
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b045/_x007.o -c gcc_traceback.c
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b045/_x008.o -c gcc_util.c
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b045/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b045/_x009.o -c gcc_amd64.S
cd $WORK/b045
TERM='dumb' clang -I /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/cgo -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -Wno-nullability-completeness -Wall -Werror -o ./_cgo_main.o -c _cgo_main.c
cd /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/cgo
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b045=/tmp/go-build -gno-record-gcc-switches -fno-common -o $WORK/b045/_cgo_.o $WORK/b045/_cgo_main.o $WORK/b045/_x001.o $WORK/b045/_x002.o $WORK/b045/_x003.o $WORK/b045/_x004.o $WORK/b045/_x005.o $WORK/b045/_x006.o $WORK/b045/_x007.o $WORK/b045/_x008.o $WORK/b045/_x009.o -g -O2 -lpthread
TERM='dumb' /usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64/cgo -dynpackage cgo -dynimport $WORK/b045/_cgo_.o -dynout $WORK/b045/_cgo_import.go -dynlinker
mkdir -p $WORK/b001/
cd /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo155257375
CGO_LDFLAGS='"-g" "-O2" "-shared"' /usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64/cgo -objdir $WORK/b001/ -importpath command-line-arguments -exportheader=$WORK/b001/_cgo_install.h -- -I $WORK/b001/ -g -O2 -I/usr/local/include/postgresql/server -fpic ./methods.go ./pl.go
cd $WORK/b001
TERM='dumb' clang -I /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo155257375 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -I/usr/local/include/postgresql/server -fpic -o ./_x001.o -c _cgo_export.c
TERM='dumb' clang -I /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo155257375 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -I/usr/local/include/postgresql/server -fpic -o ./_x002.o -c methods.cgo2.c
TERM='dumb' clang -I /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo155257375 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -I/usr/local/include/postgresql/server -fpic -o ./_x003.o -c pl.cgo2.c
TERM='dumb' clang -I /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo155257375 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -I/usr/local/include/postgresql/server -fpic -o ./_cgo_main.o -c _cgo_main.c
cd /var/folders/fx/2b_wyk0s123gqqlhvgk3g98svm9dbl/T/plgo155257375
TERM='dumb' clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -o $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o $WORK/b001/_x002.o $WORK/b001/_x003.o -g -O2 -shared
# command-line-arguments
Undefined symbols for architecture x86_64:
  "_DirectFunctionCall1Coll", referenced from:
      _jsonb_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_jsonb_to_datum in _x003.o
  "_JsonbToCString", referenced from:
      _datum_to_jsonb_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_jsonb_cstring in _x003.o
  "_SPI_connect", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_connect in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_connect)
  "_SPI_execute_plan", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_execute_plan in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_execute_plan)
  "_SPI_finish", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_finish in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_finish)
  "_SPI_fname", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_fname in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_fname)
  "_SPI_getbinval", referenced from:
      _get_col_as_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_get_col_as_datum in _x003.o
  "_SPI_gettype", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_gettype in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_gettypeid, __cgo_9759c58d933a_Cfunc_SPI_gettype )
  "_SPI_gettypeid", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_gettypeid in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_gettypeid)
  "_SPI_prepare", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_prepare in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_prepare)
  "_SPI_processed", referenced from:
      __cgohack_SPI_processed in _cgo_main.o
     (maybe you meant: __cgohack_SPI_processed)
  "_SPI_result", referenced from:
      __cgohack_SPI_result in _cgo_main.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_result_code_string, __cgohack_SPI_result )
  "_SPI_result_code_string", referenced from:
      __cgo_9759c58d933a_Cfunc_SPI_result_code_string in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_SPI_result_code_string)
  "_SPI_tuptable", referenced from:
      __cgohack_SPI_tuptable in _cgo_main.o
     (maybe you meant: __cgohack_SPI_tuptable)
  "_construct_md_array", referenced from:
      _array_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_array_to_datum in _x003.o
  "_cstring_to_text", referenced from:
      _cstring_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_cstring_to_datum in _x003.o
  "_deconstruct_array", referenced from:
      _datum_to_array in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_array in _x003.o
  "_elog_finish", referenced from:
      _elog_notice in _x003.o
      __cgo_9759c58d933a_Cfunc_elog_notice in _x003.o
      _elog_error.cold.1 in _x003.o
  "_elog_start", referenced from:
      _elog_notice in _x003.o
      __cgo_9759c58d933a_Cfunc_elog_notice in _x003.o
      _elog_error.cold.1 in _x003.o
  "_get_call_expr_argtype", referenced from:
      __cgo_9759c58d933a_Cfunc_get_call_expr_argtype in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_get_call_expr_argtype)
  "_get_typlenbyvalalign", referenced from:
      _array_to_datum in _x003.o
      _datum_to_array in _x003.o
      __cgo_9759c58d933a_Cfunc_array_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_array in _x003.o
  "_getmissingattr", referenced from:
      _get_heap_getattr in _x003.o
  "_heap_form_tuple", referenced from:
      __cgo_9759c58d933a_Cfunc_heap_form_tuple in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_heap_form_tuple)
  "_heap_getsysattr", referenced from:
      _get_heap_getattr in _x003.o
  "_jsonb_in", referenced from:
      _jsonb_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_jsonb_to_datum in _x003.o
  "_nocachegetattr", referenced from:
      _get_heap_getattr in _x003.o
  "_palloc", referenced from:
      _bytes_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_bytes_to_datum in _x003.o
  "_palloc0", referenced from:
      _array_to_datum in _x003.o
      __cgo_9759c58d933a_Cfunc_array_to_datum in _x003.o
  "_parseTypeString", referenced from:
      __cgo_9759c58d933a_Cfunc_parseTypeString in _x003.o
     (maybe you meant: __cgo_9759c58d933a_Cfunc_parseTypeString)
  "_pg_detoast_datum", referenced from:
      _jsonb_to_datum in _x003.o
      _datum_to_array in _x003.o
      _datum_to_jsonb_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_array in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_jsonb_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_jsonb_to_datum in _x003.o
  "_pg_detoast_datum_packed", referenced from:
      _datum_to_byteap in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_byteap in _x003.o
  "_text_to_cstring", referenced from:
      _datum_to_cstring in _x003.o
      __cgo_9759c58d933a_Cfunc_datum_to_cstring in _x003.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Cannot build package: exit status 2

Postgres version: psql (PostgreSQL) 12.2

gaurav8297 avatar Apr 21 '20 14:04 gaurav8297

I don't have a macos to run it on. And I think that clang wants some additional treatment. So it would be helpfull if you can find out what clang needs, or try to use gcc.

microo8 avatar Apr 23 '20 06:04 microo8

solution,

CGO_LDFLAGS="-Wl,-undefined,dynamic_lookup"  plgo .

ref, build plgo example under macOS

alitrack avatar Aug 11 '20 04:08 alitrack