$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\SDeor7119713\gocode
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users
\SDEOR7~1\AppData\Local\Temp\go-build176493662=/tmp/go-build -gno-record-gcc
-switches
set CXX=g++
set CGO_ENABLED=1

cgo is setup to use boost, pthread etc. along with archive built from my 
own code (-ls88). libs88.a uses another .a, which is where boost is being 
called.

// #cgo CFLAGS: -I${SRCDIR}/includes
// #cgo LDFLAGS: -Wl,-rpath,'$ORIGIN/lib/' -L${SRCDIR}/windows/amd64 -ls88 
-lLogDump -lboost_system -lboost_date_time -lboost_thread -lboost_filesystem 
-lstdc++ -lm -lpthread
// #include <stdlib.h>
// #include <stdio.h>
// #include "s88.h"
import "C"


On Wednesday, April 20, 2016 at 7:06:28 PM UTC-7, Dorival Pedroso wrote:
>
> Hi,
>
> I'm just wondering what is the cause of the following error (multiple 
> definition of __something)?
> C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
> C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libntdll.a(dyyls01966.o):(.idata$5+0x0):
>  
> multiple definition of `__imp_pow'
>
> This only happens on Windows10 but on Ubuntu/Linux.
>
> The Go code makes a call to LAPACK via a C interface as follows:
> package main
>
> /*
> #cgo CFLAGS: -O3
> #cgo linux   LDFLAGS: -lm -llapack -lgfortran -lblas
> #cgo windows LDFLAGS: -lm -llapack -lgfortran -lblas -LC:/GoslDeps/lib
>
> #include <stdlib.h>
>
> void dgesvd_(const char* jobu, const char* jobvt, const int* M, const int* 
> N, double* A, const int* lda, double* S, double* U, const int* ldu, double* 
> VT, const int* ldvt, double* work,const int* lwork, const int* info);
>
> int lapack_svd(double *U, double *S, double *Vt, long m_long, double *A) {
>     int     m     = (int)(m_long);
>     int     info  = 0;
>     char    job   = 'A';
>     int     lwork = 10*m;
>     double* work  = (double*)malloc(lwork*sizeof(double));
>     dgesvd_(&job,   // JOBU
>             &job,   // JOBVT
>             &m,     // M
>             &m,     // N
>             A,      // A
>             &m,     // LDA
>             S,      // S
>             U,      // U
>             &m,     // LDU
>             Vt,     // VT
>             &m,     // LDVT
>             work,   // WORK
>             &lwork, // LWORK
>             &info); // INFO
>     free(work);
>     return info;
> }
> */
> import "C"
>
> import (
> "fmt"
> "math"
> "unsafe"
> )
>
> func main() {
> A := []float64{1, 2, 3, 2, -4, -9, 3, 6, -3} // col-major format
> m := int(math.Sqrt(float64(len(A))))
> I := func(i, j int) int { return j*m + i }
> printmat(m, A, "A")
> U := make([]float64, len(A))
> S := make([]float64, len(A))
> Vt := make([]float64, len(A))
> info := C.lapack_svd(
> (*C.double)(unsafe.Pointer(&U[0])),
> (*C.double)(unsafe.Pointer(&S[0])),
> (*C.double)(unsafe.Pointer(&Vt[0])),
> (C.long)(m),
> (*C.double)(unsafe.Pointer(&A[0])),
> )
> fmt.Printf("SVD: info = %d\n", info)
> USVt := make([]float64, len(A))
> for i := 0; i < m; i++ {
> for j := 0; j < m; j++ {
> for k := 0; k < m; k++ {
> USVt[I(i, j)] += U[I(i, k)] * S[k] * Vt[I(k, j)]
> }
> }
> }
> printmat(m, USVt, "U*S*Vt")
> }
>
> func printmat(m int, M []float64, msg string) {
> fmt.Printf("%s =\n", msg)
> for i := 0; i < m; i++ {
> for j := 0; j < m; j++ {
> fmt.Printf("%13.8f", M[j*m+i])
> }
> fmt.Println()
> }
> }
>
> Any help is much appreciated.
>
> Cheers.
> Dorival
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to