User forums > Using Code::Blocks

Linking libraries (.lib fortran)

<< < (2/4) > >>

Librarylinker:

--- Quote from: stahta01 on February 13, 2020, 03:52:49 am ---Post a build log and maybe some could help you!
In case it is a simple mistake; without a build log you are wasting band width and everyone's time

Edit: BLAS and LAPACK are libraries that building them yourself is likely possible.
But,  MATGEN is not a library that Google has very much about.
Edit2: Most of the Google results is about the matgen command/program. I have not found a matgen library!

Tim S.

--- End quote ---
Build log would just say that undefined reference error and I added a short program example too. It is all there, thanks
And just ignore the part I say it is simple, I am more time then you wouldn't believe, trying to fix this. That's why I ened up asking here

 
--- Quote from: cacb on February 13, 2020, 08:44:51 am ---
--- Quote from: Librarylinker on February 13, 2020, 12:57:32 am ---I think everything should work fine, but I end up getting an error message:
undefined reference to `dgemm_'

--- End quote ---

That looks like a linker error.

I don't know the compiler(s) you are using or whether your project is all Fortran or mixed C++/Fortran, or whether the libraries were compiled by you. A *.lib library is the typical result of Visual Studio-compatible compiler (I guess it is Intel Fortran nowadays, in ancient times it was Fortran Powerstation and before history began it was VAX Fortran). GCC or variants typically create *.a static libraries if I am not mistaken.

So the question is whether your wingw64 compiler produces compatible object code with those intel libraries, probably compiled with an Intel compiler.  From the '_' suffix I am guessing it does not, it is what your wingw64 compiler expects it to be, but the intel compiler probably 'decorates' the subroutine names in a different way, causing the linker error.

Your best bet is to recompile those libraries using the compiler you are using, or alternatively use an intel compiler for your own code.

I used to deal with such issues a long time ago when calling Fortran from C++ http://arnholm.org/software/cppf77/cppf77.htm



--- End quote ---
Thank you for the answer.
It is all fortran (like the program example).
The libraires were probably downloaded from intel.
Do you have the source code so I can recompile?

stahta01:
http://netlib.org/lapack/lapack.tgz
Link from https://icl.cs.utk.edu/lapack-for-windows/lapack/#build

Tim S.

stahta01:
Sample FORTRAN file builds OK for me; with minor code edit.

The library blas has the dgemm function.
Note: It still built after removing the lapack from linker library list.

Using MSys2 MinGW64 lapack library (which installs blas library)

--- Code: ---$ pacman -Qs lapack
local/mingw-w64-x86_64-lapack 3.8.0-5
    Linear Algebra PACKage (mingw-w64)

--- End code ---

Tim S.


--- Code: ----------------- Build: Debug in dgemm (compiler: GNU Fortran Compiler)---------------

gfortran.exe -Jobj\Debug\ -Wall  -g     -c C:\Users\stahta01\devel\test\dgemm\main.f95 -o obj\Debug\main.o
gfortran.exe  -o bin\Debug\dgemm.exe obj\Debug\main.o   -llapack -lblas
Output file is bin\Debug\dgemm.exe with size 319.11 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

--- End code ---

cacb:

--- Quote from: Librarylinker on February 13, 2020, 11:26:19 am ---Do you have the source code so I can recompile?

--- End quote ---

No.

Librarylinker:

--- Quote from: stahta01 on February 13, 2020, 12:39:14 pm ---Sample FORTRAN file builds OK for me; with minor code edit.

--- End quote ---

What did you do?

You just installed the file from http://netlib.org/lapack/lapack.tgz by using MSys2 MinGW64, is that it? (I'm not experienced in dealing with those things, I'm not sure if I understood what you did. I guess you didn't create a .a library and simply linked it. And also you are not working with the .lib I provided, right?)

Would you be able to compile it with Codeblocks IDE?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version