Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-18 Thread Ian Lance Taylor
On Wed, Mar 18, 2020 at 9:59 AM Mohamed Mahmoud  wrote:
>
> On Wednesday, March 18, 2020 at 11:59:38 AM UTC-4, Ian Lance Taylor wrote:
>>
>> On Wed, Mar 18, 2020 at 5:18 AM Mohamed Mahmoud  wrote:
>> >
>> > On Wednesday, March 18, 2020 at 8:01:27 AM UTC-4, Mohamed Mahmoud wrote:
>> >>
>> >>
>> >>> It doesn't look like the -ldflags option is getting through to the 
>> >>> linker.  Try
>> >>> go build "-ldflags=all=-w -extldflags=-lmabain -v"
>> >>>
>> >>> Ian
>> >>
>> >>
>> >> I tried the new format however it still can't link mabain lib and I get 
>> >> the same errors
>> >>
>> >> Step 25/26 : RUN cd ${MABAIN_SRC}/; go build -x -i "-ldflags=all=-w 
>> >> -extldflags=-lmabain -v"
>> >>
>> >>  ---> Running in 90e992e27f6b
>> >>
>> >> WORK=/tmp/go-build678792509
>> >>
>> >> mkdir -p $WORK/b001/
>> >>
>> >> swig -version
>> >>
>> >> cd $WORK
>> >>
>> >> /usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
>> >> "$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
>> >> ./swig_intsize.go
>> >>
>> >> cd /mabain_src
>> >>
>> >> swig -go -cgo -intgosize 64 -module mabain -o $WORK/b001/mabain_wrap.cxx 
>> >> -outdir $WORK/b001/ -c++ mabain.swigcxx
>> >>
>> >> CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
>> >> $WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
>> >> $WORK/b001/_mabain_swig.go
>> >>
>> >> cd $WORK
>> >>
>> >> gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true
>> >>
>> >> gcc -Qunused-arguments -c -x c - -o /dev/null || true
>> >>
>> >> gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>> >>
>> >> gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true
>> >>
>> >> cd $WORK/b001
>> >>
>> >> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> >> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
>> >> ./ -g -O2 -o ./_x001.o -c _cgo_export.c
>> >>
>> >> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> >> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
>> >> ./ -g -O2 -o ./_x002.o -c _mabain_swig.cgo2.c
>> >>
>> >> cd $WORK
>> >>
>> >> g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true
>> >>
>> >> g++ -Qunused-arguments -c -x c - -o /dev/null || true
>> >>
>> >> g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>> >>
>> >> g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true
>> >>
>> >> cd /mabain_src
>> >>
>> >> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
>> >> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
>> >> $WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp
>> >>
>> >> cd $WORK/b001
>> >>
>> >> TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> >> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
>> >> ./ -g -O2 -o ./_x004.o -c mabain_wrap.cxx
>> >>
>> >> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> >> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
>> >> ./ -g -O2 -o ./_cgo_main.o -c _cgo_main.c
>> >>
>> >> cd /mabain_src
>> >>
>> >> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
>> >> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
>> >> $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
>> >> $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2
>> >>
>> >> # _/mabain_src
>> >>
>> >> /tmp/go-build678792509/b001/_x003.o: In function `mbOpen':
>> >>
>> >> ./mabain_c_interface.cpp:10: undefined reference to 
>> >> `mabain::CONSTS::ReaderOptions()'
>> >
>> >
>> > root@70c73d4a4f01:/# go version
>> >
>> > go version go1.13 linux/amd64
>> >
>> > root@70c73d4a4f01:/# swig -version
>> >
>> >
>> > SWIG Version 3.0.12
>> >
>> >
>> > Compiled with g++ [x86_64-pc-linux-gnu]
>> >
>> >
>> > Configured options: +pcre
>> >
>> >
>> > Please see http://www.swig.org for reporting bugs and further information
>>
>>
>> Oh, sorry, I see now that this is failing in the cgo step, not the link step.
>>
>> Try adding this to your Go file:
>>
>> // #cgo LDFLAGS: -lmabain
>> import "C"
>>
>> Ian
>
>
> Step 25/26 : RUN cd ${MABAIN_SRC}/; go build -x "-ldflags=all=-w 
> -extldflags=-lmabain -v"
>
>  ---> Running in e570e7fe65fa
>
> WORK=/tmp/go-build247647361
>
> can't load package: package .: use of cgo in test /mabain_src/mabain_test.go 
> not supported
>
> The command '/bin/sh -c cd ${MABAIN_SRC}/; go build -x "-ldflags=all=-w 
> -extldflags=-lmabain -v"' returned a non-zero code: 1
>
> MMAHMOUD-M-45WX:golang mohamedmahmoud$ git diff mabain_test.go
>
> diff --git a/swig/golang/mabain_test.go b/swig/golang/mabain_test.go
>
> index 3b5be36..d2bc605 100644
>
> --- a/swig/golang/mabain_test.go
>
> +++ b/swig/golang/mabain_test.go
>
> @@ -1,14 +1,16 @@
>
>  package mabain
>
>
>
> +// #cgo LDFLAGS: -lmabain
>
>  import (
>
> +   "C"
>
> "fmt"
>
> -   "testing"
>
> "os"
>
> +   "

Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-18 Thread Mohamed Mahmoud


On Wednesday, March 18, 2020 at 11:59:38 AM UTC-4, Ian Lance Taylor wrote:
>
> On Wed, Mar 18, 2020 at 5:18 AM Mohamed Mahmoud  > wrote: 
> > 
> > On Wednesday, March 18, 2020 at 8:01:27 AM UTC-4, Mohamed Mahmoud wrote: 
> >> 
> >> 
> >>> It doesn't look like the -ldflags option is getting through to the 
> linker.  Try 
> >>> go build "-ldflags=all=-w -extldflags=-lmabain -v" 
> >>> 
> >>> Ian 
> >> 
> >> 
> >> I tried the new format however it still can't link mabain lib and I get 
> the same errors 
> >> 
> >> Step 25/26 : RUN cd ${MABAIN_SRC}/; go build -x -i "-ldflags=all=-w 
> -extldflags=-lmabain -v" 
> >> 
> >>  ---> Running in 90e992e27f6b 
> >> 
> >> WORK=/tmp/go-build678792509 
> >> 
> >> mkdir -p $WORK/b001/ 
> >> 
> >> swig -version 
> >> 
> >> cd $WORK 
> >> 
> >> /usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
> "$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
> ./swig_intsize.go 
> >> 
> >> cd /mabain_src 
> >> 
> >> swig -go -cgo -intgosize 64 -module mabain -o 
> $WORK/b001/mabain_wrap.cxx -outdir $WORK/b001/ -c++ mabain.swigcxx 
> >> 
> >> CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
> $WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
> $WORK/b001/_mabain_swig.go 
> >> 
> >> cd $WORK 
> >> 
> >> gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true 
> >> 
> >> gcc -Qunused-arguments -c -x c - -o /dev/null || true 
> >> 
> >> gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true 
> >> 
> >> gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true 
> >> 
> >> cd $WORK/b001 
> >> 
> >> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_x001.o -c _cgo_export.c 
> >> 
> >> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_x002.o -c _mabain_swig.cgo2.c 
> >> 
> >> cd $WORK 
> >> 
> >> g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true 
> >> 
> >> g++ -Qunused-arguments -c -x c - -o /dev/null || true 
> >> 
> >> g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true 
> >> 
> >> g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true 
> >> 
> >> cd /mabain_src 
> >> 
> >> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
> $WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp 
> >> 
> >> cd $WORK/b001 
> >> 
> >> TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_x004.o -c mabain_wrap.cxx 
> >> 
> >> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_cgo_main.o -c _cgo_main.c 
> >> 
> >> cd /mabain_src 
> >> 
> >> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
> $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
> $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2 
> >> 
> >> # _/mabain_src 
> >> 
> >> /tmp/go-build678792509/b001/_x003.o: In function `mbOpen': 
> >> 
> >> ./mabain_c_interface.cpp:10: undefined reference to 
> `mabain::CONSTS::ReaderOptions()' 
> > 
> > 
> > root@70c73d4a4f01:/# go version 
> > 
> > go version go1.13 linux/amd64 
> > 
> > root@70c73d4a4f01:/# swig -version 
> > 
> > 
> > SWIG Version 3.0.12 
> > 
> > 
> > Compiled with g++ [x86_64-pc-linux-gnu] 
> > 
> > 
> > Configured options: +pcre 
> > 
> > 
> > Please see http://www.swig.org for reporting bugs and further 
> information 
>
>
> Oh, sorry, I see now that this is failing in the cgo step, not the link 
> step. 
>
> Try adding this to your Go file: 
>
> // #cgo LDFLAGS: -lmabain 
> import "C" 
>
> Ian 
>

Step 25/26 : RUN cd ${MABAIN_SRC}/; go build -x "-ldflags=all=-w 
-extldflags=-lmabain -v"

 ---> Running in e570e7fe65fa

WORK=/tmp/go-build247647361

*can't load package: package .: use of cgo in test 
/mabain_src/mabain_test.go not supported*

The command '/bin/sh -c cd ${MABAIN_SRC}/; go build -x "-ldflags=all=-w 
-extldflags=-lmabain -v"' returned a non-zero code: 1

MMAHMOUD-M-45WX:golang mohamedmahmoud$ git diff mabain_test.go 

*diff --git a/swig/golang/mabain_test.go b/swig/golang/mabain_test.go*

*index 3b5be36..d2bc605 100644*

*--- a/swig/golang/mabain_test.go*

*+++ b/swig/golang/mabain_test.go*

@@ -1,14 +1,16 @@

 package mabain

 

+// #cgo LDFLAGS: -lmabain

 import (

+   "C"

"fmt"

-   "testing"

"os"

+   "testing"

 )

 

 const (

MABAIN_PATH = "/var/tmp/mabain_test"

-   COUNT = 100

+   COUNT   = 100

 )
 I thought we can use either SWIG or CGO but not both ?

-- 
You received 

Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-18 Thread Ian Lance Taylor
On Wed, Mar 18, 2020 at 5:18 AM Mohamed Mahmoud  wrote:
>
> On Wednesday, March 18, 2020 at 8:01:27 AM UTC-4, Mohamed Mahmoud wrote:
>>
>>
>>> It doesn't look like the -ldflags option is getting through to the linker.  
>>> Try
>>> go build "-ldflags=all=-w -extldflags=-lmabain -v"
>>>
>>> Ian
>>
>>
>> I tried the new format however it still can't link mabain lib and I get the 
>> same errors
>>
>> Step 25/26 : RUN cd ${MABAIN_SRC}/; go build -x -i "-ldflags=all=-w 
>> -extldflags=-lmabain -v"
>>
>>  ---> Running in 90e992e27f6b
>>
>> WORK=/tmp/go-build678792509
>>
>> mkdir -p $WORK/b001/
>>
>> swig -version
>>
>> cd $WORK
>>
>> /usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
>> "$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
>> ./swig_intsize.go
>>
>> cd /mabain_src
>>
>> swig -go -cgo -intgosize 64 -module mabain -o $WORK/b001/mabain_wrap.cxx 
>> -outdir $WORK/b001/ -c++ mabain.swigcxx
>>
>> CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
>> $WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
>> $WORK/b001/_mabain_swig.go
>>
>> cd $WORK
>>
>> gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true
>>
>> gcc -Qunused-arguments -c -x c - -o /dev/null || true
>>
>> gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>>
>> gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true
>>
>> cd $WORK/b001
>>
>> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
>> -g -O2 -o ./_x001.o -c _cgo_export.c
>>
>> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
>> -g -O2 -o ./_x002.o -c _mabain_swig.cgo2.c
>>
>> cd $WORK
>>
>> g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true
>>
>> g++ -Qunused-arguments -c -x c - -o /dev/null || true
>>
>> g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>>
>> g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true
>>
>> cd /mabain_src
>>
>> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
>> $WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp
>>
>> cd $WORK/b001
>>
>> TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
>> -g -O2 -o ./_x004.o -c mabain_wrap.cxx
>>
>> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
>> -g -O2 -o ./_cgo_main.o -c _cgo_main.c
>>
>> cd /mabain_src
>>
>> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
>> $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
>> $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2
>>
>> # _/mabain_src
>>
>> /tmp/go-build678792509/b001/_x003.o: In function `mbOpen':
>>
>> ./mabain_c_interface.cpp:10: undefined reference to 
>> `mabain::CONSTS::ReaderOptions()'
>
>
> root@70c73d4a4f01:/# go version
>
> go version go1.13 linux/amd64
>
> root@70c73d4a4f01:/# swig -version
>
>
> SWIG Version 3.0.12
>
>
> Compiled with g++ [x86_64-pc-linux-gnu]
>
>
> Configured options: +pcre
>
>
> Please see http://www.swig.org for reporting bugs and further information


Oh, sorry, I see now that this is failing in the cgo step, not the link step.

Try adding this to your Go file:

// #cgo LDFLAGS: -lmabain
import "C"

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcU1Pz%2B2cWtiv6da-OHYY3%2BBetC7GEU1nmW5t3LwTKw2uQ%40mail.gmail.com.


Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-18 Thread Mohamed Mahmoud



On Wednesday, March 18, 2020 at 8:01:27 AM UTC-4, Mohamed Mahmoud wrote:
>
>
> It doesn't look like the -ldflags option is getting through to the linker. 
>>  Try 
>> go build "-ldflags=all=-w -extldflags=-lmabain -v" 
>>
>> Ian 
>>
>
> I tried the new format however it still can't link mabain lib and I get 
> the same errors
>
> Step 25/26 : RUN cd ${MABAIN_SRC}/; go build -x -i "-ldflags=all=-w 
> -extldflags=-lmabain -v"
>
>  ---> Running in 90e992e27f6b
>
> WORK=/tmp/go-build678792509
>
> mkdir -p $WORK/b001/
>
> swig -version
>
> cd $WORK
>
> /usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
> "$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
> ./swig_intsize.go
>
> cd /mabain_src
>
> swig -go -cgo -intgosize 64 -module mabain -o $WORK/b001/mabain_wrap.cxx 
> -outdir $WORK/b001/ -c++ mabain.swigcxx
>
> CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
> $WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
> $WORK/b001/_mabain_swig.go
>
> cd $WORK
>
> gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true
>
> gcc -Qunused-arguments -c -x c - -o /dev/null || true
>
> gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>
> gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true
>
> cd $WORK/b001
>
> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_x001.o -c _cgo_export.c
>
> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_x002.o -c _mabain_swig.cgo2.c
>
> cd $WORK
>
> g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true
>
> g++ -Qunused-arguments -c -x c - -o /dev/null || true
>
> g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>
> g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true
>
> cd /mabain_src
>
> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
> $WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp
>
> cd $WORK/b001
>
> TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_x004.o -c mabain_wrap.cxx
>
> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
> -g -O2 -o ./_cgo_main.o -c _cgo_main.c
>
> cd /mabain_src
>
> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
> $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
> $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2
>
> # _/mabain_src
>
> /tmp/go-build678792509/b001/_x003.o: In function `mbOpen':
> ./mabain_c_interface.cpp:10: undefined reference to 
> `mabain::CONSTS::ReaderOptions()' 
>

root@70c73d4a4f01:/# go version

go version go1.13 linux/amd64

root@70c73d4a4f01:/# swig -version


SWIG Version 3.0.12


Compiled with g++ [x86_64-pc-linux-gnu]


Configured options: +pcre


Please see http://www.swig.org for reporting bugs and further information 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b9f5048e-755c-43d5-b7fc-58d9d3d4eb27%40googlegroups.com.


Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-18 Thread Mohamed Mahmoud


> It doesn't look like the -ldflags option is getting through to the linker. 
>  Try 
> go build "-ldflags=all=-w -extldflags=-lmabain -v" 
>
> Ian 
>

I tried the new format however it still can't link mabain lib and I get the 
same errors

Step 25/26 : RUN cd ${MABAIN_SRC}/; go build -x -i "-ldflags=all=-w 
-extldflags=-lmabain -v"

 ---> Running in 90e992e27f6b

WORK=/tmp/go-build678792509

mkdir -p $WORK/b001/

swig -version

cd $WORK

/usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
"$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
./swig_intsize.go

cd /mabain_src

swig -go -cgo -intgosize 64 -module mabain -o $WORK/b001/mabain_wrap.cxx 
-outdir $WORK/b001/ -c++ mabain.swigcxx

CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
$WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
$WORK/b001/_mabain_swig.go

cd $WORK

gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true

gcc -Qunused-arguments -c -x c - -o /dev/null || true

gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true

gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true

cd $WORK/b001

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x001.o -c _cgo_export.c

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x002.o -c _mabain_swig.cgo2.c

cd $WORK

g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true

g++ -Qunused-arguments -c -x c - -o /dev/null || true

g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true

g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true

cd /mabain_src

TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
$WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp

cd $WORK/b001

TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x004.o -c mabain_wrap.cxx

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_cgo_main.o -c _cgo_main.c

cd /mabain_src

TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
$WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
$WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2

# _/mabain_src

/tmp/go-build678792509/b001/_x003.o: In function `mbOpen':
./mabain_c_interface.cpp:10: undefined reference to 
`mabain::CONSTS::ReaderOptions()' 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4284daf5-63d4-4742-9664-8f184a5a695e%40googlegroups.com.


Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-17 Thread Ian Lance Taylor
On Tue, Mar 17, 2020 at 2:05 PM Mohamed Mahmoud  wrote:
>
> On Tuesday, March 17, 2020 at 5:01:43 PM UTC-4, Mohamed Mahmoud wrote:
>>
>> I don't see anything obviously wrong.  Add -v to -ldflags to see
>>>
>>> exactly how the external linker is being invoked.  Make sure that
>>> -lmabain appears at the right point in the link line.
>>>
>>> Ian
>>
>>
>> I added -v its not showing libmabain , I am not sure what exactly you mean 
>> by having -lmabain at the right point , below is my command line let me know 
>> what it should be ?
>
>  Step 25/26 : RUN cd ${MABAIN_SRC}/; go install -x -i -ldflags '-w 
> -extldflags "-lmabain" -v'
>
>  ---> Running in fd8ed360602a
>
> WORK=/tmp/go-build682038651
>
> mkdir -p $WORK/b001/
>
> swig -version
>
> cd $WORK
>
> /usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
> "$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
> ./swig_intsize.go
>
> cd /mabain_src
>
> swig -go -cgo -intgosize 64 -module mabain -o $WORK/b001/mabain_wrap.cxx 
> -outdir $WORK/b001/ -c++ mabain.swigcxx
>
> CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
> $WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
> $WORK/b001/_mabain_swig.go
>
> cd $WORK
>
> gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true
>
> gcc -Qunused-arguments -c -x c - -o /dev/null || true
>
> gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>
> gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true
>
> cd $WORK/b001
>
> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g 
> -O2 -o ./_x001.o -c _cgo_export.c
>
> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g 
> -O2 -o ./_x002.o -c _mabain_swig.cgo2.c
>
> cd $WORK
>
> g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true
>
> g++ -Qunused-arguments -c -x c - -o /dev/null || true
>
> g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
>
> g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true
>
> cd /mabain_src
>
> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
> $WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp
>
> cd $WORK/b001
>
> TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g 
> -O2 -o ./_x004.o -c mabain_wrap.cxx
>
> TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ -g 
> -O2 -o ./_cgo_main.o -c _cgo_main.c
>
> cd /mabain_src
>
> TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
> $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
> $WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2
>
> # _/mabain_src
>
> /tmp/go-build682038651/b001/_x003.o: In function `mbOpen':
>
> ./mabain_c_interface.cpp:10: undefined reference to 
> `mabain::CONSTS::ReaderOptions()'
>
> ./mabain_c_interface.cpp:12: undefined reference to `mabain::DB::DB(char 
> const*, int, unsigned long, unsigned long, unsigned int)'
>
> ./mabain_c_interface.cpp:13: undefined reference to `mabain::DB::is_open() 
> const'
>
> ./mabain_c_interface.cpp:14: undefined reference to `mabain::DB::StatusStr() 
> const'
>
> ./mabain_c_interface.cpp:11: undefined reference to 
> `mabain::CONSTS::WriterOptions()'
>
> /tmp/go-build682038651/b001/_x003.o: In function `mbFind':
>
> ./mabain_c_interface.cpp:44: undefined reference to `mabain::MBData::MBData()'
>
> ./mabain_c_interface.cpp:45: undefined reference to `mabain::DB::Find(char 
> const*, int, mabain::MBData&) const'
>
> ./mabain_c_interface.cpp:44: undefined reference to 
> `mabain::MBData::~MBData()'
>
> ./mabain_c_interface.cpp:44: undefined reference to 
> `mabain::MBData::~MBData()'
>
> /tmp/go-build682038651/b001/_x003.o: In function `mbClose':
>
> ./mabain_c_interface.cpp:23: undefined reference to `mabain::DB::Close()'
>
> /tmp/go-build682038651/b001/_x003.o: In function `mbAdd':
>
> ./mabain_c_interface.cpp:30: undefined reference to `mabain::DB::Add(char 
> const*, int, char const*, int, bool)'
>
> /tmp/go-build682038651/b001/_x003.o: In function `mbRemove':
>
> ./mabain_c_interface.cpp:37: undefined reference to `mabain::DB::Remove(char 
> const*, int)'
>
> collect2: error: ld returned 1 exit status
>
> The command '/bin/sh -c cd ${MABAIN_SRC}/; go install -x -i -ldflags '-w 
> -extldflags "-lmabain" -v'' returned a non-zero code: 2

It doesn't look like the -ldflags option is getting through to the linker.  Try
go build "-ldflags=all=-w -extldflags=-lmabain -v"

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"go

Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-17 Thread Mohamed Mahmoud


On Tuesday, March 17, 2020 at 5:01:43 PM UTC-4, Mohamed Mahmoud wrote:
>
> I don't see anything obviously wrong.  Add -v to -ldflags to see 
>
>> exactly how the external linker is being invoked.  Make sure that 
>> -lmabain appears at the right point in the link line. 
>>
>> Ian 
>>
>
> I added -v its not showing libmabain , I am not sure what exactly you mean 
> by having -lmabain at the right point , below is my command line let me 
> know what it should be ?
>
 Step 25/26 : RUN cd ${MABAIN_SRC}/; go install -x -i -ldflags '-w 
-extldflags "-lmabain" -v'

 ---> Running in fd8ed360602a

WORK=/tmp/go-build682038651

mkdir -p $WORK/b001/

swig -version

cd $WORK

/usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
"$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
./swig_intsize.go

cd /mabain_src

swig -go -cgo -intgosize 64 -module mabain -o $WORK/b001/mabain_wrap.cxx 
-outdir $WORK/b001/ -c++ mabain.swigcxx

CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
$WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
$WORK/b001/_mabain_swig.go

cd $WORK

gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true

gcc -Qunused-arguments -c -x c - -o /dev/null || true

gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true

gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true

cd $WORK/b001

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x001.o -c _cgo_export.c

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x002.o -c _mabain_swig.cgo2.c

cd $WORK

g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true

g++ -Qunused-arguments -c -x c - -o /dev/null || true

g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true

g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true

cd /mabain_src

TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
$WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp

cd $WORK/b001

TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x004.o -c mabain_wrap.cxx

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_cgo_main.o -c _cgo_main.c

cd /mabain_src

TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
$WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
$WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2

# _/mabain_src

/tmp/go-build682038651/b001/_x003.o: In function `mbOpen':

./mabain_c_interface.cpp:10: undefined reference to 
`mabain::CONSTS::ReaderOptions()'

./mabain_c_interface.cpp:12: undefined reference to `mabain::DB::DB(char 
const*, int, unsigned long, unsigned long, unsigned int)'

./mabain_c_interface.cpp:13: undefined reference to `mabain::DB::is_open() 
const'

./mabain_c_interface.cpp:14: undefined reference to 
`mabain::DB::StatusStr() const'

./mabain_c_interface.cpp:11: undefined reference to 
`mabain::CONSTS::WriterOptions()'

/tmp/go-build682038651/b001/_x003.o: In function `mbFind':

./mabain_c_interface.cpp:44: undefined reference to 
`mabain::MBData::MBData()'

./mabain_c_interface.cpp:45: undefined reference to `mabain::DB::Find(char 
const*, int, mabain::MBData&) const'

./mabain_c_interface.cpp:44: undefined reference to 
`mabain::MBData::~MBData()'

./mabain_c_interface.cpp:44: undefined reference to 
`mabain::MBData::~MBData()'

/tmp/go-build682038651/b001/_x003.o: In function `mbClose':

./mabain_c_interface.cpp:23: undefined reference to `mabain::DB::Close()'

/tmp/go-build682038651/b001/_x003.o: In function `mbAdd':

./mabain_c_interface.cpp:30: undefined reference to `mabain::DB::Add(char 
const*, int, char const*, int, bool)'

/tmp/go-build682038651/b001/_x003.o: In function `mbRemove':

./mabain_c_interface.cpp:37: undefined reference to 
`mabain::DB::Remove(char const*, int)'

collect2: error: ld returned 1 exit status

The command '/bin/sh -c cd ${MABAIN_SRC}/; go install -x -i -ldflags '-w 
-extldflags "-lmabain" -v'' returned a non-zero code: 2

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f6f24f25-a43b-4834-8dd2-45eec94bc902%40googlegroups.com.


Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-17 Thread Mohamed Mahmoud
I don't see anything obviously wrong.  Add -v to -ldflags to see 

> exactly how the external linker is being invoked.  Make sure that 
> -lmabain appears at the right point in the link line. 
>
> Ian 
>

I added -v its not showing libmabain , I am not sure what exactly you mean 
by having -lmabain at the right point , below is my command line let me 
know what it should be ?

Step 25/26 : RUN cd ${MABAIN_SRC}/; go install -x -i -ldflags '-w 
-extldflags "-lmabain" -v'

 ---> Running in fd8ed360602a

WORK=/tmp/go-build682038651

mkdir -p $WORK/b001/

swig -version

cd $WORK

/usr/local/go/pkg/tool/linux_amd64/compile -o ./b001/_go_.o -trimpath 
"$WORK/b001=>" -p main -complete -goversion go1.13 -D _$WORK -c=4 
./swig_intsize.go

cd /mabain_src

swig -go -cgo -intgosize 64 -module mabain -o $WORK/b001/mabain_wrap.cxx 
-outdir $WORK/b001/ -c++ mabain.swigcxx

CGO_LDFLAGS='"-g" "-O2"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir 
$WORK/b001/ -importpath _/mabain_src -- -I $WORK/b001/ -g -O2 
$WORK/b001/_mabain_swig.go

cd $WORK

gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true

gcc -Qunused-arguments -c -x c - -o /dev/null || true

gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true

gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true

cd $WORK/b001

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x001.o -c _cgo_export.c

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x002.o -c _mabain_swig.cgo2.c

cd $WORK

g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true

g++ -Qunused-arguments -c -x c - -o /dev/null || true

g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true

g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true

cd /mabain_src

TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I 
$WORK/b001/ -g -O2 -o $WORK/b001/_x003.o -c mabain_c_interface.cpp

cd $WORK/b001

TERM='dumb' g++ -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_x004.o -c mabain_wrap.cxx

TERM='dumb' gcc -I /mabain_src -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -I ./ 
-g -O2 -o ./_cgo_main.o -c _cgo_main.c

cd /mabain_src

TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -o 
$WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o 
$WORK/b001/_x002.o $WORK/b001/_x003.o $WORK/b001/_x004.o -g -O2

# _/mabain_src

/tmp/go-build682038651/b001/_x003.o: In function `mbOpen':

./mabain_c_interface.cpp:10: undefined reference to 
`mabain::CONSTS::ReaderOptions()'

./mabain_c_interface.cpp:12: undefined reference to `mabain::DB::DB(char 
const*, int, unsigned long, unsigned long, unsigned int)'

./mabain_c_interface.cpp:13: undefined reference to `mabain::DB::is_open() 
const'

./mabain_c_interface.cpp:14: undefined reference to 
`mabain::DB::StatusStr() const'

./mabain_c_interface.cpp:11: undefined reference to 
`mabain::CONSTS::WriterOptions()'

/tmp/go-build682038651/b001/_x003.o: In function `mbFind':

./mabain_c_interface.cpp:44: undefined reference to 
`mabain::MBData::MBData()'

./mabain_c_interface.cpp:45: undefined reference to `mabain::DB::Find(char 
const*, int, mabain::MBData&) const'

./mabain_c_interface.cpp:44: undefined reference to 
`mabain::MBData::~MBData()'

./mabain_c_interface.cpp:44: undefined reference to 
`mabain::MBData::~MBData()'

/tmp/go-build682038651/b001/_x003.o: In function `mbClose':

./mabain_c_interface.cpp:23: undefined reference to `mabain::DB::Close()'

/tmp/go-build682038651/b001/_x003.o: In function `mbAdd':

./mabain_c_interface.cpp:30: undefined reference to `mabain::DB::Add(char 
const*, int, char const*, int, bool)'

/tmp/go-build682038651/b001/_x003.o: In function `mbRemove':

./mabain_c_interface.cpp:37: undefined reference to 
`mabain::DB::Remove(char const*, int)'

collect2: error: ld returned 1 exit status

The command '/bin/sh -c cd ${MABAIN_SRC}/; go install -x -i -ldflags '-w 
-extldflags "-lmabain" -v'' returned a non-zero code: 2

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/911b9b18-9f2c-4615-85e6-a89d04430a10%40googlegroups.com.


Re: [go-nuts] building C++ wrapper for mabain lib with go1.13

2020-03-17 Thread Ian Lance Taylor
On Tue, Mar 17, 2020 at 9:04 AM  wrote:
>
> I have created swigcxx file , since swig now is natively integrated in go 
> tools
> I ran the following to build a test program that interact with the mabain 
> wrapper go package to test the APIs
>
> go install -x -i -ldflags '-w -extldflags "-lmabain"'
>
>
> However I ran into linker errors that I am not able to resolve
>
>
> # mabain
>
> /tmp/go-build378478658/b001/_x003.o: In function `mbOpen':
>
> ./mabain_c_interface.cpp:10: undefined reference to 
> `mabain::CONSTS::ReaderOptions()'
>
> ./mabain_c_interface.cpp:12: undefined reference to `mabain::DB::DB(char 
> const*, int, unsigned long, unsigned long, unsigned int)'
>
> ./mabain_c_interface.cpp:13: undefined reference to `mabain::DB::is_open() 
> const'
>
> ./mabain_c_interface.cpp:14: undefined reference to `mabain::DB::StatusStr() 
> const'
>
> ./mabain_c_interface.cpp:11: undefined reference to 
> `mabain::CONSTS::WriterOptions()'
>
> /tmp/go-build378478658/b001/_x003.o: In function `mbFind':
>
> ./mabain_c_interface.cpp:44: undefined reference to `mabain::MBData::MBData()'
>
> ./mabain_c_interface.cpp:45: undefined reference to `mabain::DB::Find(char 
> const*, int, mabain::MBData&) const'
>
> ./mabain_c_interface.cpp:44: undefined reference to 
> `mabain::MBData::~MBData()'
>
> ./mabain_c_interface.cpp:44: undefined reference to 
> `mabain::MBData::~MBData()'
>
> /tmp/go-build378478658/b001/_x003.o: In function `mbClose':
>
> ./mabain_c_interface.cpp:23: undefined reference to `mabain::DB::Close()'
>
> /tmp/go-build378478658/b001/_x003.o: In function `mbAdd':
>
> ./mabain_c_interface.cpp:30: undefined reference to `mabain::DB::Add(char 
> const*, int, char const*, int, bool)'
>
> /tmp/go-build378478658/b001/_x003.o: In function `mbRemove':
>
> ./mabain_c_interface.cpp:37: undefined reference to `mabain::DB::Remove(char 
> const*, int)'
>
> collect2: error: ld returned 1 exit status
>
>
>
> root@e75d907ebd87:/usr/local/lib# ls -ltr
>
> total 1844
>
> -rwxr-xr-x 1 root root 1887608 Mar 17 11:42 libmabain.so
>
> root@e75d907ebd87:/usr/local/lib#
>
>
>
> root@e75d907ebd87:/usr/local/lib# objdump -t libmabain.so | grep ReaderOption
>
> 00022b60 g F .text 0003  
> _ZN6mabain6CONSTS13ReaderOptionsEv
>
>
> Any suggestions on how to fix this linker error ?

I don't see anything obviously wrong.  Add -v to -ldflags to see
exactly how the external linker is being invoked.  Make sure that
-lmabain appears at the right point in the link line.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWhbQJZ8tqT4LrOe2sR%3DUdfJXDos15r27R-VgpB3%2BfB8w%40mail.gmail.com.