mrirecon / bart

BART: Toolbox for Computational Magnetic Resonance Imaging
https://mrirecon.github.io/bart/
BSD 3-Clause "New" or "Revised" License
294 stars 163 forks source link

Cygwin compile fails #102

Closed johannestoger closed 7 years ago

johannestoger commented 7 years ago

Hi, just tried to compile BART v0.4.01 on Cygwin to integrate with Matlab on a colleagues computer (Windows 7). I installed cygwin 64-bit and the packages that are mentioned in the README file.

First, I got an error that lapacke.h is missing, but I got past that error by downloading the LAPACKE (C integration) header files from the LAPACK website: http://www.netlib.org/lapack/

After this the file execinfo.h is missing. However, this is not provided at all in Cygwin due to this function being basically incompatible with Windows.

Is there a better way of compiling on Windows?

Error log from compilation below:

gcc -Wall -Wextra -MMD -MF /cygdrive/c/Users/johannes/code/csf-resp-recon/bart/src/misc/.debug.d -I/cygdrive/c/Users/johannes/code/csf-resp-recon/bart/src/ -I/usr//include/ -I/usr//include -DFFTWTHREADS -DMAIN_LIST="avg, bench, bitmask, bpsense, cabs, caldir, calmat, carg, casorati, cc, ccapply, cdf97, circshift, conj, conv, copy, cpyphs, creal, crop, delta, ecalib, ecaltwo, estdelay, estdims, estshift, estvar, extract, fakeksp, fft, fftmod, fftshift, filter, flatten, flip, fmac, homodyne, invert, itsense, join, lrmatrix, mandelbrot, mip, nlinv, noise, normalize, nrmse, nufft, ones, pattern, phantom, pics, pocsense, poisson, repmat, reshape, resize, rof, rss, sake, saxpy, scale, sdot, show, slice, spow, sqpics, squeeze, svd, threshold, toimg, traj, transpose, twixread, version, walsh, wave, wavelet, zeros, zexpj, ()" -include src/main.h -O3 -ffast-math -Wmissing-prototypes -std=gnu11 -I/cygdrive/c/Users/johannes/code/csf-resp-recon/bart/src/ -I../lapacke-include/ -fopenmp -c -o /cygdrive/c/Users/johannes/code/csf-resp-recon/bart/src/misc/debug.o /cygdrive/c/Users/johannes/code/csf-resp-recon/bart/src/misc/debug.c /cygdrive/c/Users/johannes/code/csf-resp-recon/bart/src/misc/debug.c:22:22: fatal error: execinfo.h: No such file or directory

include

                  ^

compilation terminated. make[1]: [Makefile:373: /cygdrive/c/Users/johannes/code/csf-resp-recon/bart/src/misc/debug.o] Error 1 make[1]: Leaving directory '/cygdrive/c/Users/johannes/code/csf-resp-recon/bart' make: [Makefile:194: default] Error 2

uecker commented 7 years ago

You can try BART from the cygwin branch which includes the relevant code from LAPACKE directly. But I haven't heard any success stories so far. Otherwise, the last version which should work with cygwin is 0.3.01. But there were people reporting problems on Windows for 0.3.01 too, so your mileage may vary... The recommended way to run BART on Windows is using WSL, but this only available on Windows 10 as far as I know.

johannestoger commented 7 years ago

Thanks, the cygwin branch fixes the lapacke error. However, the execinfo.h bug is still there.

Compilation of v0.3.01 on Cygwin seems to be working fine, some linking errors though for the main bart executable but I might be able to fix that.

Is there any other way of generating a Windows executable? MingW maybe?

WSL is what I'm using myself and it's working very well.

Thanks for your quick answer!

uecker commented 7 years ago

I see. Somehow I missed the fact that the execinfo problem does not come from lapacke at all. I pushed a change to the cygwin branch which hopefully fixes this. Can you try again and report back, please?

Not sure why there a linking errors for 0.3.01. This is supposed to work. If you have a fix, let me know...

MingW might also work, but I have no experience with it. You can try...

johannestoger commented 7 years ago

Thanks, managed to compile it on Cygwin 64-bit now, and all tests are passing! =)

I only had to fix one small thing in the Makefile: for OS detection, running 'uname -s' on Cygwin on Windows 10 gives the result 'CYGWIN_NT-10.0', not 'Cygwin' as the Makefile expects.

uecker commented 7 years ago

Thanks, I have merged the changes into the master branch. It would be great if you could test this as well. Thank you!

johannestoger commented 7 years ago

Almost there!

gcc -rdynamic -O3 -ffast-math -Wmissing-prototypes -std=gnu11 -I/cygdrive/c/Users/johannes/code/bart/src/ -fopenmp -Dmain_real=main_bart -o bart src/main.c /cygdrive/c/Users/johannes/code/bart/src/bart.o lib/libbox.a lib/libgrecon.a lib/libsense.a lib/libnoir.a lib/libiter.a lib/liblinops.a lib/libwavelet.a lib/liblowrank.a lib/libnoncart.a lib/libcalib.a lib/libsimu.a lib/libsake.a lib/libdfwavelet.a lib/libnum.a lib/libmisc.a lib/libnum.a lib/libmisc.a lib/liblapacke.a -L/usr//lib -lfftw3f -lfftw3f_threads -L/usr//lib -llapack -lblas -lpng -lm lib/libnum.a(lapack.o):lapack.c:(.text+0x2e1): undefined reference to LAPACKE_ctrtri' lib/libnum.a(lapack.o):lapack.c:(.text+0x2e1): relocation truncated to fit: R_X86_64_PC32 against undefined symbolLAPACKE_ctrtri' lib/libnum.a(lapack.o):lapack.c:(.text+0x321): undefined reference to LAPACKE_ctrtri' lib/libnum.a(lapack.o):lapack.c:(.text+0x321): relocation truncated to fit: R_X86_64_PC32 against undefined symbolLAPACKE_ctrtri' collect2: error: ld returned 1 exit status make[1]: [Makefile:428: bart] Error 1 make[1]: Leaving directory '/cygdrive/c/Users/johannes/code/bart' make: [Makefile:219: default] Error 2

uecker commented 7 years ago

Ok, I see. We use more lapack functions now. I will fix this later today or tomorrow.

uecker commented 7 years ago

should be fixed.

johannestoger commented 7 years ago

Thanks, compilation succeeds and all tests are passing now!