User forums > Using Code::Blocks

Linking libraries (.lib fortran)

(1/4) > >>

Librarylinker:
Hi,

I am trying to link 3 libraries (.lib) to a project. The libraries are BLASd, LAPACKd, MATGENd (which might be intel libraries as they are in upper case - which I think wouldn't be the source of error)

I am using wingw64 to as fortran compiler.

I didn't install nothing but the IDE and the compiler, i.e., I just have the .lib files and I am trying to link them to the projects...

I did what I think was needed to link the libraries which is:
- settings > compiler > search directories > linker > add: (added the path to the 3 .lib files)
I did the same to compiler (although I think it isn't necessary for fortran) i.e.
- settings > compiler > search directories > compiler> add: (added the path to the 3 .lib files)
Added the libraries to the projects build options:
- project > build options > linker settings > linker libraries > add> (added BLASd, LAPACKd and MATGENd)
(I've  read here and there that the order of this list is important, so I tried all the combinations: BLM, BML, LBM, LMB, MBL, MLB...)

I think everything should work fine, but I end up getting an error message:
undefined reference to `dgemm_'

For simplicity, uploaded a small program example which I have this error (cant attach to the post because to lib files exceed the limit): https://drive.google.com/open?id=1dj9s_KOmC3hVjqBkAO_GArwyqGb6eK-w

This sounds like a horrendously simple question and it might be. But to me, it might end up consuming literally the rest of my life if I can't get any help of someone more experienced to tell me what might be going on here.

If anybody could help with this, you don't know how much you would be changing a man's life

Thanks in advance

oBFusCATed:
I don't know anything about fortran, but I'll start from here:
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Also I'll try to add one library at a time if this is possible. Start from the lower levels and keep adding the upper levels.
And consider asking the help from the place where you've downloaded the libraries. They might know if they are compatible with your compiler and version.

Librarylinker:
Thank you for the answer.

[And consider asking the help from the place where you've downloaded the libraries.]
Those are old files, I won't be able to track the origin... but I know in 2012 it was used for windows, MVS IDE, intel compiler and recently it was used for linux, gfortran (which I whink is the same compiler I am using, but mine is windows). So it seems that they should be compatible with mine...

Anyone else that might have a solution for this problem (which doesn't seem to be complex in actaulity), I tried all logical solution I could imagine

stahta01:
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.

cacb:

--- 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

Navigation

[0] Message Index

[#] Next page

Go to full version