Hi Dave, I was able to build a pure C++ project using same libraries and it linked and executed fine, so I assumed boost was ok (yes, I built boost from src on my system). However, linking the same using cgo is giving these errors.
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.