Linker error from dub?
BBasile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Nov 11 22:03:47 PST 2015
On Thursday, 12 November 2015 at 05:44:37 UTC, Stiff wrote:
> On Thursday, 12 November 2015 at 05:17:58 UTC, BBasile wrote:
>> On Thursday, 12 November 2015 at 02:02:56 UTC, Stiff wrote:
>>> Possibly a dumb question, I'm not sure.
>>> [...]
>>> undefined reference to `cblas_dgemm'
>>> collect2: error: ld returned 1 exit status
>>> --- errorlevel 1
>>> dmd failed with exit code 1.
>>>
>>>
>>> Any suggestions? I do have a blas library installed, but the
>>> cblas D project isn't docced very well, so I don't know if
>>> there's a compatibility issue.
>>>
>>> Thanks!
>>
>> You should add something to tell DUB to link your program with
>> the openblas static library since cblas is just a binding. For
>> example this should work:
>>
>> {
>> "name" : "tcbuilder",
>> "description" : "Thalamocortical network parameter
>> parser",
>> "dependencies" : {
>> "cblas": "~>0.1.0",
>> "scid": "~>0.3.0"
>> },
>> "libs" : [
>> "openblas"
>> ],
>> }
>>
>> And install the 'openblas-devel' package of course. Btw I've
>> verified with a simple program and it works, although it just
>> included cblas, not scid.
>
> Does the libs element from cblas' dub.json not handle that
> library linkage?
>
> If it does work with OpenBLAS, that would seem to suggest that
> "Works with OpenBLAS and others" is a bit more restrictive than
> it sounds...
On my system it only worked with OpenBlas...so now I don't know
(its quite probable that the other blas libs work..) but what's
sure is that you have to fill the libs[] to compile the
application because the blas C library won't be pre-linked when
compiling cblas. I mean that even if it's done in cblas D binding
you'll have to add it anyway in the final project.
> I suppose I should also mention that it was compiling fine
> before I actually used a function from the library in my code.
It worked fine because it was not used, not parsed, not linked.
Maybe just the functions declarations was parsed to solve the
symbols in the program, but since none was used the 'import
blas.blas' was eliminated or something like that. This could be
explained better by someone who knows well DMD architecture...
More information about the Digitalmars-d-learn
mailing list