digitalmars.D - Advice on linking D programs to fortran77 blas/lapack
- Michael Gratton (11/11) May 22 2008 Hello,
- Jonathan Crapuchettes (9/27) May 22 2008 Michael,
- Michael Gratton (4/34) May 22 2008 GDC did the trick quite nicely. Thanks for the help! I didn't get a ch...
- BCS (3/8) May 22 2008 take a look at mathextra, IIRC it has bindings:
- Don (2/15) May 22 2008 No, it's Bill Baxter's project that has the bindings.
- sclytrack (1/1) May 23 2008 http://dsource.org/projects/multiarray
- Bill Baxter (5/23) May 22 2008 I have the BLAS/LAPACK wrappers I use up as part of this:
- Walter Bright (2/7) May 23 2008 I'd run grep over your libraries and see who defines those symbols.
Hello, I'm trying to link a D program to the BLAS and LAPACK libraries (numerical linear algebra packages usually written in FORTRAN77). I've written an extern (C) {} block much like I would in C/C++ to provide "headers" for the functions I want to call, and then tried to build the program by dmd test.d /usr/lib/libblas.a /usr/lib/liblapack.a This nearly works, but LAPACK complains that several _gfortran symbols are undefined, such as: (.text+0x83): undefined reference to `_gfortran_compare_string' (.text+0x341): undefined reference to `_gfortran_copy_string' (.text+0x69): undefined reference to `_gfortran_st_write' ...and so on. Has anyone else had luck with this kind of linking? Am I missing a library that gcc magically includes when linking C and F77? Am I just flat trying to link wrong with the dmd command? Thanks! --mg
May 22 2008
Michael, Do you know if you can use the ATLAS package instead? I have it working currently with D. I found it a lot easer to work with since there is a C header file that can almost be directly ported to D. If you are not interested in ATLAS, you should try using gdc to compile your program. It might help with the problems that you are encountering. Hope that helps, JC Michael Gratton wrote:Hello, I'm trying to link a D program to the BLAS and LAPACK libraries (numerical linear algebra packages usually written in FORTRAN77). I've written an extern (C) {} block much like I would in C/C++ to provide "headers" for the functions I want to call, and then tried to build the program by dmd test.d /usr/lib/libblas.a /usr/lib/liblapack.a This nearly works, but LAPACK complains that several _gfortran symbols are undefined, such as: (.text+0x83): undefined reference to `_gfortran_compare_string' (.text+0x341): undefined reference to `_gfortran_copy_string' (.text+0x69): undefined reference to `_gfortran_st_write' ...and so on. Has anyone else had luck with this kind of linking? Am I missing a library that gcc magically includes when linking C and F77? Am I just flat trying to link wrong with the dmd command? Thanks! --mg
May 22 2008
GDC did the trick quite nicely. Thanks for the help! I didn't get a chance to try out ATLAS. We have fancy Intel BLAS/LAPACK that we paid money for, so it seems like a shame not to use them :) (But the single-thread performance difference is <5% for problems I run...) Yeah, and a D success story: the D templates allow me to write default BLAS-type routines for nice vector classes using long double ('real') precision. When the template is instantiated with double or float, I can just link to the standard BLAS/LAPACK. This really clears up a huge headache that was involved in testing things at different precisions. Jonathan Crapuchettes Wrote:Michael, Do you know if you can use the ATLAS package instead? I have it working currently with D. I found it a lot easer to work with since there is a C header file that can almost be directly ported to D. If you are not interested in ATLAS, you should try using gdc to compile your program. It might help with the problems that you are encountering. Hope that helps, JC Michael Gratton wrote:Hello, I'm trying to link a D program to the BLAS and LAPACK libraries (numerical linear algebra packages usually written in FORTRAN77). I've written an extern (C) {} block much like I would in C/C++ to provide "headers" for the functions I want to call, and then tried to build the program by dmd test.d /usr/lib/libblas.a /usr/lib/liblapack.a This nearly works, but LAPACK complains that several _gfortran symbols are undefined, such as: (.text+0x83): undefined reference to `_gfortran_compare_string' (.text+0x341): undefined reference to `_gfortran_copy_string' (.text+0x69): undefined reference to `_gfortran_st_write' ...and so on. Has anyone else had luck with this kind of linking? Am I missing a library that gcc magically includes when linking C and F77? Am I just flat trying to link wrong with the dmd command? Thanks! --mg
May 22 2008
Reply to Michael,Hello, I'm trying to link a D program to the BLAS and LAPACK libraries (numerical linear algebra packages usually written in FORTRAN77).take a look at mathextra, IIRC it has bindings: http://www.dsource.org/projects/mathextra
May 22 2008
BCS wrote:Reply to Michael,No, it's Bill Baxter's project that has the bindings.Hello, I'm trying to link a D program to the BLAS and LAPACK libraries (numerical linear algebra packages usually written in FORTRAN77).take a look at mathextra, IIRC it has bindings: http://www.dsource.org/projects/mathextra
May 22 2008
Michael Gratton wrote:Hello, I'm trying to link a D program to the BLAS and LAPACK libraries (numerical linear algebra packages usually written in FORTRAN77). I've written an extern (C) {} block much like I would in C/C++ to provide "headers" for the functions I want to call, and then tried to build the program by dmd test.d /usr/lib/libblas.a /usr/lib/liblapack.a This nearly works, but LAPACK complains that several _gfortran symbols are undefined, such as: (.text+0x83): undefined reference to `_gfortran_compare_string' (.text+0x341): undefined reference to `_gfortran_copy_string' (.text+0x69): undefined reference to `_gfortran_st_write' ...and so on. Has anyone else had luck with this kind of linking? Am I missing a library that gcc magically includes when linking C and F77? Am I just flat trying to link wrong with the dmd command? Thanks! --mgI have the BLAS/LAPACK wrappers I use up as part of this: http://www.dsource.org/projects/multiarray May require some tweaking to use with Intel's BLAS/LAPACK. I use ATLAS. --bb
May 22 2008
Michael Gratton wrote:This nearly works, but LAPACK complains that several _gfortran symbols are undefined, such as: (.text+0x83): undefined reference to `_gfortran_compare_string' (.text+0x341): undefined reference to `_gfortran_copy_string' (.text+0x69): undefined reference to `_gfortran_st_write'I'd run grep over your libraries and see who defines those symbols.
May 23 2008