Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile:5: recipe for target 'install' failed #10

Closed
vbmade2000 opened this issue Jan 18, 2018 · 17 comments
Closed

Makefile:5: recipe for target 'install' failed #10

vbmade2000 opened this issue Jan 18, 2018 · 17 comments

Comments

@vbmade2000
Copy link

I am trying to build gi.
Steps I followed:

$ go get -t -u -v github.com/gijit/gi/...
$ cd $GOPATH/src/github.com/gijit/gi && make

I am getting

Makefile:5: recipe for target 'install' failed

Following are logs of make

cd cmd/gi && make onetime && make install
make[1]: Entering directory '/home/vbmade2000/go/src/github.com/gijit/gi/cmd/gi'
cd ../../vendor/github.com/LuaJIT/LuaJIT && make clean && make
make[2]: Entering directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT'
make -C src clean
make[3]: Entering directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT/src'
rm -f luajit libluajit.a libluajit.so host/minilua host/buildvm lj_vm.S lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h jit/vmdef.lua *.o host/*.o *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
make[3]: Leaving directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT/src'
make[2]: Leaving directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT'
make[2]: Entering directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT'
==== Building LuaJIT 2.1.0-beta3 ====
make -C src
make[3]: Entering directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT/src'
HOSTCC    host/minilua.o
HOSTLINK  host/minilua
DYNASM    host/buildvm_arch.h
HOSTCC    host/buildvm.o
HOSTCC    host/buildvm_asm.o
HOSTCC    host/buildvm_peobj.o
HOSTCC    host/buildvm_lib.o
HOSTCC    host/buildvm_fold.o
HOSTLINK  host/buildvm
BUILDVM   lj_vm.S
ASM       lj_vm.o
CC        lj_gc.o
BUILDVM   lj_ffdef.h
CC        lj_err.o
CC        lj_char.o
BUILDVM   lj_bcdef.h
CC        lj_bc.o
CC        lj_obj.o
CC        lj_buf.o
CC        lj_str.o
CC        lj_tab.o
CC        lj_func.o
CC        lj_udata.o
CC        lj_meta.o
CC        lj_debug.o
CC        lj_state.o
CC        lj_dispatch.o
CC        lj_vmevent.o
CC        lj_vmmath.o
CC        lj_strscan.o
CC        lj_strfmt.o
CC        lj_strfmt_num.o
CC        lj_api.o
CC        lj_profile.o
CC        lj_lex.o
CC        lj_parse.o
CC        lj_bcread.o
CC        lj_bcwrite.o
CC        lj_load.o
CC        lj_ir.o
CC        lj_opt_mem.o
BUILDVM   lj_folddef.h
CC        lj_opt_fold.o
CC        lj_opt_narrow.o
CC        lj_opt_dce.o
CC        lj_opt_loop.o
CC        lj_opt_split.o
CC        lj_opt_sink.o
CC        lj_mcode.o
CC        lj_snap.o
CC        lj_record.o
CC        lj_crecord.o
BUILDVM   lj_recdef.h
CC        lj_ffrecord.o
CC        lj_asm.o
CC        lj_trace.o
CC        lj_gdbjit.o
CC        lj_ctype.o
CC        lj_cdata.o
CC        lj_cconv.o
CC        lj_ccall.o
CC        lj_ccallback.o
CC        lj_carith.o
CC        lj_clib.o
CC        lj_cparse.o
CC        lj_lib.o
CC        lj_alloc.o
CC        lib_aux.o
CC        luajit-ffi-ctypeid.o
BUILDVM   lj_libdef.h
CC        lib_base.o
CC        lib_math.o
CC        lib_bit.o
CC        lib_string.o
CC        lib_table.o
CC        lib_io.o
CC        lib_os.o
CC        lib_package.o
CC        lib_debug.o
CC        lib_jit.o
CC        lib_ffi.o
CC        lib_init.o
AR        libluajit.a
CC        luajit.o
BUILDVM   jit/vmdef.lua
DYNLINK   libluajit.so
LINK      luajit
OK        Successfully built LuaJIT
make[3]: Leaving directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT/src'
==== Successfully built LuaJIT 2.1.0-beta3 ====
make[2]: Leaving directory '/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT'
make[1]: Leaving directory '/home/vbmade2000/go/src/github.com/gijit/gi/cmd/gi'
make[1]: Entering directory '/home/vbmade2000/go/src/github.com/gijit/gi/cmd/gi'
make build
make[2]: Entering directory '/home/vbmade2000/go/src/github.com/gijit/gi/cmd/gi'
go build -ldflags "-X main.LastGitCommitHash=f3076e690ebedbfa1a830b27d9a7e7acd872b821 -X main.BuildTimeStamp=2018-01-18T04:57:53-0800 -X main.GitBranch=master -X main.NearestGitTag=v0.6.1  -X main.GoVersion=go_version_go1.9.2_linux/amd64  -X main.LuajitVersion=" -o gi
Makefile:29: recipe for target 'build' failed
make[2]: Leaving directory '/home/vbmade2000/go/src/github.com/gijit/gi/cmd/gi'
Makefile:33: recipe for target 'install' failed
make[1]: Leaving directory '/home/vbmade2000/go/src/github.com/gijit/gi/cmd/gi'
Makefile:5: recipe for target 'install' failed
@glycerine
Copy link
Contributor

glycerine commented Jan 20, 2018

@vbmade2000 Hey! Sorry for the delay in replying. Github didn't ping me, strangely. Feel free to gmail me directly if you need assistance or file a new issue.

The transcript doesn't tell me why go build failed. Can you run cd $GOPATH/src/github.com/gijit/gi/cmd/gi; go build manually to see what the problem was?

If that doesn't let you fix it immediately, try go build -x which will tell you the exact commands the compile and link is trying. If you still have issues, post the output of the go build -x.

@glycerine
Copy link
Contributor

Also, what operating system are you building on?

@vbmade2000
Copy link
Author

Sure. The OS is Ubuntu 17.

@glycerine
Copy link
Contributor

Sure. The OS is Ubuntu 17.

Perfect. This should work. I just verified on a linux box I have, and it built. Though it was centos7.3.

What does go build -x, when run in the cmd/gi subdirectory, say?

@glycerine
Copy link
Contributor

glycerine commented Jan 20, 2018

Ah. luajit wasn't being installed, only built. So then asking luajit for its version failed. I pushed a fix for this just now, in v0.6.3, so that we really don't require installation of luajit--so that users won't have any existing luajit overwritten with our version. git pull origin master --tags and then try again.

For developing, you will definitely want to install LuaJIT. So just cd $GOPATH/src/github.com/gijit/gi/vendor/github.com/LuaJIT/LuaJIT/src and then make install or sudo make install if need be.

@vbmade2000
Copy link
Author

Correct. luajit was not being installed. It was being built only. I manually copied it to $PATH and then tried building but still failed.

Now I am going to build gi again after pulling latest changes.

@vbmade2000
Copy link
Author

Tried building after pulling latest changes but still facing same issue. Following is an output of go build -x.

WORK=/tmp/go-build197448566
mkdir -p $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/
mkdir -p $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/
cd /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua
CGO_LDFLAGS="-g" "-O2" "-lm" "-ldl" "/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a" "/home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/ -importpath github.com/gijit/gi/vendor/github.com/glycerine/golua/lua -- -I $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/ -g -O2 -I ./../../../LuaJIT/LuaJIT/src -I ./../../../LuaJIT/LuaJIT/src -I ./../../../LuaJIT/LuaJIT/src golua.go lauxlib.go lua.go lua_defs.go
cd $WORK
gcc -fdebug-prefix-map=a=b -c trivial.c
gcc -gno-record-gcc-switches -c trivial.c
cd $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj
gcc -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -o ./_cgo_export.o -c _cgo_export.c
gcc -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -o ./golua.cgo2.o -c golua.cgo2.c
gcc -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -o ./lauxlib.cgo2.o -c lauxlib.cgo2.c
gcc -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -o ./lua.cgo2.o -c lua.cgo2.c
gcc -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -o ./lua_defs.cgo2.o -c lua_defs.cgo2.c
cd /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/ -g -O2 -I ./../../../LuaJIT/LuaJIT/src -I ./../../../LuaJIT/LuaJIT/src -I ./../../../LuaJIT/LuaJIT/src -o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/c-golua.o -c c-golua.c
cd $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj
gcc -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -I /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src -o ./_cgo_main.o -c _cgo_main.c
cd /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_main.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_export.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/golua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lauxlib.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua_defs.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/c-golua.o -g -O2 -lm -ldl ./../../../LuaJIT/LuaJIT/src/libluajit.a ./../../../LuaJIT/LuaJIT/src/libluajit.a
# github.com/gijit/gi/vendor/github.com/glycerine/golua/lua
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_clib.o): In function `lj_clib_index':
lj_clib.c:(.text+0x183): undefined reference to `dlsym'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_clib.o): In function `lj_clib_load':
lj_clib.c:(.text+0x281): undefined reference to `dlopen'
lj_clib.c:(.text+0x309): undefined reference to `dlerror'
lj_clib.c:(.text+0x418): undefined reference to `dlopen'
lj_clib.c:(.text+0x429): undefined reference to `dlerror'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_clib.o): In function `lj_clib_unload':
lj_clib.c:(.text+0x45d): undefined reference to `dlclose'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_clib.o): In function `clib_error_':
lj_clib.c:(.text.unlikely+0x5): undefined reference to `dlerror'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lib_math.o): In function `lj_ffh_math_log':
lib_math.c:(.text+0xe2): undefined reference to `log2'
lib_math.c:(.text+0xf6): undefined reference to `log2'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lib_package.o): In function `ll_loadfunc':
lib_package.c:(.text+0x7fd): undefined reference to `dlsym'
lib_package.c:(.text+0x857): undefined reference to `dlopen'
lib_package.c:(.text+0x8aa): undefined reference to `dlsym'
lib_package.c:(.text+0x8b8): undefined reference to `dlerror'
lib_package.c:(.text+0x8e1): undefined reference to `dlsym'
lib_package.c:(.text+0x931): undefined reference to `dlerror'
lib_package.c:(.text+0x953): undefined reference to `dlerror'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lib_package.o): In function `lj_cf_package_loader_preload':
lib_package.c:(.text+0xb28): undefined reference to `dlsym'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lib_package.o): In function `lj_cf_package_unloadlib':
lib_package.c:(.text+0xd1e): undefined reference to `dlclose'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_BC_POW':
buildvm_x86.dasc:(.text+0x8ec): undefined reference to `pow'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_log':
buildvm_x86.dasc:(.text+0x2791): undefined reference to `log'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_log10':
buildvm_x86.dasc:(.text+0x27b9): undefined reference to `log10'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_exp':
buildvm_x86.dasc:(.text+0x27e1): undefined reference to `exp'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_sin':
buildvm_x86.dasc:(.text+0x2809): undefined reference to `sin'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_cos':
buildvm_x86.dasc:(.text+0x2831): undefined reference to `cos'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_tan':
buildvm_x86.dasc:(.text+0x2859): undefined reference to `tan'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_asin':
buildvm_x86.dasc:(.text+0x2881): undefined reference to `asin'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_acos':
buildvm_x86.dasc:(.text+0x28a9): undefined reference to `acos'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_atan':
buildvm_x86.dasc:(.text+0x28d1): undefined reference to `atan'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_sinh':
buildvm_x86.dasc:(.text+0x28f9): undefined reference to `sinh'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_cosh':
buildvm_x86.dasc:(.text+0x2921): undefined reference to `cosh'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_tanh':
buildvm_x86.dasc:(.text+0x2949): undefined reference to `tanh'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_pow':
buildvm_x86.dasc:(.text+0x2983): undefined reference to `pow'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_atan2':
buildvm_x86.dasc:(.text+0x29bd): undefined reference to `atan2'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vm.o): In function `lj_ff_math_fmod':
buildvm_x86.dasc:(.text+0x29f7): undefined reference to `fmod'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vmmath.o): In function `lj_vm_foldfpm':
lj_vmmath.c:(.text+0x1b8): undefined reference to `sqrt'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vmmath.o): In function `lj_vm_foldarith':
lj_vmmath.c:(.text+0xa1): undefined reference to `pow'
lj_vmmath.c:(.text+0xc9): undefined reference to `atan2'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_vmmath.o): In function `lj_vm_foldfpm':
lj_vmmath.c:(.text+0x141): undefined reference to `cos'
lj_vmmath.c:(.text+0x149): undefined reference to `tan'
lj_vmmath.c:(.text+0x181): undefined reference to `exp'
lj_vmmath.c:(.text+0x189): undefined reference to `exp2'
lj_vmmath.c:(.text+0x191): undefined reference to `log'
lj_vmmath.c:(.text+0x199): undefined reference to `log2'
lj_vmmath.c:(.text+0x1a1): undefined reference to `log10'
lj_vmmath.c:(.text+0x1a9): undefined reference to `sin'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x240): undefined reference to `sinh'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x250): undefined reference to `cosh'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x260): undefined reference to `tanh'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x2e0): undefined reference to `exp'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x2f0): undefined reference to `exp2'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x300): undefined reference to `log'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x310): undefined reference to `log2'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x320): undefined reference to `log10'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x330): undefined reference to `sin'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x340): undefined reference to `cos'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x350): undefined reference to `tan'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x370): undefined reference to `pow'
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_ir.o):(.data.rel.ro+0x380): undefined reference to `atan2'
collect2: error: ld returned 1 exit status

@glycerine
Copy link
Contributor

glycerine commented Jan 20, 2018

So you can follow along, here are the details:

This is a link command that is failing:

gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_main.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_export.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/golua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lauxlib.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua_defs.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/c-golua.o -g -O2 -lm -ldl ./../../../LuaJIT/LuaJIT/src/libluajit.a ./../../../LuaJIT/LuaJIT/src/libluajit.a

The libraries libm.so (the math library) and libdl.so (the dynamic loading library) are linked in with the -lm and -ldl flags, towards the very end of the line.

However, the linker cannot locate those libraries on your system. That's what is meant by "undefined reference". The header files where there, just fine, to compile against. But when it came time to link against the actual libraries, the dynamic linker couldn't find them.

That's what this lines means:

# github.com/gijit/gi/vendor/github.com/glycerine/golua/lua
../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lj_clib.o): In function `lj_clib_index':
lj_clib.c:(.text+0x183): undefined reference to `dlsym'

The above line refers to a dl function, in the library for dynamically loading binary code into a running process.

../../vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a(lib_math.o): In function `lj_ffh_math_log':
lib_math.c:(.text+0xe2): undefined reference to `log2'

The above errors and the others about pow tell us that the math library couldn't be located by the linker.

Now both these libraries probably exist on your system. It's just a small matter of telling the linker where to find them.

This is typically controlled on a linux system by the ld.so.conf file, somewhere in the /etc directory.

Step 1, locate the libraries:

$cd /
$find . -name 'libm.so' -print # note where it is found
$find . -name 'libdl.so' -print # ditto

Step 2

Then add directories to the ld.so.conf

Step 3
run ldconfig as root to pick up the changes.

Then try again.

@glycerine
Copy link
Contributor

There is one other possibility, that the link line is out of order. Since go build is constructing it, I consider this unlikely. But you could test it by manually invoking the same link line and putting the -lm and -ldl flags toward the front of the command:

cd /home/vbmade2000/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua

gcc  -lm -ldl -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_main.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_export.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/golua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lauxlib.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua_defs.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/c-golua.o -g -O2 -lm -ldl ./../../../LuaJIT/LuaJIT/src/libluajit.a ./../../../LuaJIT/LuaJIT/src/libluajit.a

If that builds cleanly, then it was an order problem, the flags came in the wrong order.

@glycerine
Copy link
Contributor

glycerine commented Jan 20, 2018

As you are adjusting the linker, a quick test would be to try and compile and link a small C program. This will give you an independent test that the linker is now working.

Make a test.c file:

#include <stdio.h>
#include <math.h>
int main(void)
{
  double x = 0.5;
  double result = sqrt(x);
  printf("The square root of %lf is %lf\n", x, result);
  return 0;
}

compile and link and run it

gcc test.c -o test -lm && ./test

If it doesn't find the math library (libm.so), then keep changing the ld.so.conf file until it does. Remember to run sudo ldconfig after each change, or the change may not take effect.

@glycerine
Copy link
Contributor

I grabbed a docker container from dockerhub of Ubuntu17, ubuntu:artful-20180112

It looks like /etc/ld.so.conf is right there in /etc. The libraries you need are in /lib/x86_64-linux-gnu.

root@cce186d9e685:/lib/x86_64-linux-gnu# ls -al|grep libdl
-rw-r--r-- 1 root root   14632 Oct 11 20:21 libdl-2.26.so
lrwxrwxrwx 1 root root      13 Oct 11 20:21 libdl.so.2 -> libdl-2.26.so
root@cce186d9e685:/lib/x86_64-linux-gnu# cd /lib
root@cce186d9e685:/lib# cd x86_64-linux-gnu/
root@cce186d9e685:/lib/x86_64-linux-gnu# ls -al|grep libm.
-rw-r--r-- 1 root root 1404912 Oct 11 20:21 libm-2.26.so
lrwxrwxrwx 1 root root      12 Oct 11 20:21 libm.so.6 -> libm-2.26.so
-rw-r--r-- 1 root root   18784 Oct 11 20:21 libmemusage.so
lrwxrwxrwx 1 root root      17 Aug 14 10:15 libmount.so.1 -> libmount.so.1.1.0
-rw-r--r-- 1 root root  331976 Aug 14 10:15 libmount.so.1.1.0
-rw-r--r-- 1 root root  170432 Oct 11 20:21 libmvec-2.26.so
lrwxrwxrwx 1 root root      15 Oct 11 20:21 libmvec.so.1 -> libmvec-2.26.so

root@cce186d9e685:/lib/x86_64-linux-gnu# ls -al| grep libdl
-rw-r--r-- 1 root root   14632 Oct 11 20:21 libdl-2.26.so
lrwxrwxrwx 1 root root      13 Oct 11 20:21 libdl.so.2 -> libdl-2.26.so
root@cce186d9e685:/lib/x86_64-linux-gnu# 

when I look at the ld.so.conf it points me to the /etc/ld.so.conf.d:

root@cce186d9e685:/etc/ld.so.conf.d# ls -al
total 16
drwxr-xr-x 2 root root 4096 Jan 12 22:58 .
drwxr-xr-x 1 root root 4096 Jan 20 09:08 ..
-rw-r--r-- 1 root root   44 Jan 27  2016 libc.conf
-rw-r--r-- 1 root root   68 Oct 11 20:21 x86_64-linux-gnu.conf
root@cce186d9e685:/etc/ld.so.conf.d# cat *
# libc default configuration
/usr/local/lib
# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
root@cce186d9e685:/etc/ld.so.conf.d# 

and I see that /lib/x86_64-linux-gnu is listed in this container by default. So unless the cache needed refreshing by running sudo ldconfig, I can't fathom what went wrong on your build box.

Let's get the test.c building, then we'll be on solid ground.

@glycerine
Copy link
Contributor

Here's a link to installing gcc on Ubuntu.

https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91

If nothing else works, might try re-installing gcc per that gist.

@glycerine
Copy link
Contributor

hmm... okay, I can reproduce the issue in the docker container. Troubleshooting it now.

@glycerine
Copy link
Contributor

It is an order of flags issue. If I manually move the -lm and -ldl to the end of the link line, then it builds. Example:

me@dc7613b8de09:~/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua$ gcc -I .  -fPIC -m64 -pthread -fmessage-l\
ength=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/gijit/gi/vendor/github.com/glycer\
ine/golua/lua/_obj/_cgo_.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_main.o $WORK/github.com/\
gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_export.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua\
/lua/_obj/golua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lauxlib.cgo2.o $WORK/github.com/g\
ijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua\
/_obj/lua_defs.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/c-golua.o -g -O2  ./../../../LuaJI\
T/LuaJIT/src/libluajit.a ./../../../LuaJIT/LuaJIT/src/libluajit.a -lm -ldl

versus the orignal that CGO is generating fails:

me@dc7613b8de09:~/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua$ gcc -I .  -fPIC -m64 -pthread -fmessage-l\
ength=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/gijit/gi/vendor/github.com/glycer\
ine/golua/lua/_obj/_cgo_.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_main.o $WORK/github.com/\
gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_export.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua\
/lua/_obj/golua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lauxlib.cgo2.o $WORK/github.com/g\
ijit/gi/vendor/github.com/glycerine/golua/lua/_obj/lua.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua\
/_obj/lua_defs.cgo2.o $WORK/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/c-golua.o -g -O2 -lm -ldl  ./../..\
/../LuaJIT/LuaJIT/src/libluajit.a ./../../../LuaJIT/LuaJIT/src/libluajit.a
./../../../LuaJIT/LuaJIT/src/libluajit.a(lj_clib.o): In function `lj_clib_index':
lj_clib.c:(.text+0x172): undefined reference to `dlsym'

So now to figure out how to make CGO put the -l flags at the end...

@glycerine
Copy link
Contributor

I put in additional -lm -ldl flags in the CGO for golua, and that fixes the problem at tip.

PS I hate how Ubuntu changed the default linker options. It got super finicky and broke tons of stuff. Not such a great idea really. Background is here [1][2].

https://stackoverflow.com/questions/38352092/why-do-i-get-dso-missing-error-even-when-the-linker-can-locate-the-library/45218113#45218113

http://www.bnikolic.co.uk/blog/gnu-ld-as-needed.html

@glycerine
Copy link
Contributor

glycerine commented Jan 20, 2018

@vbmade2000 I'm glad you reported this, and I'm glad it was such an easy fix once the diagnosis was clear. Ubuntu users everywhere will be much happier.

@vbmade2000
Copy link
Author

@glycerine It worked :). Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants