digitalmars.D.learn - Linker error from dub?
Possibly a dumb question, I'm not sure. I'm trying to use the cblas headers from DLangScience, and getting linker errors out of dub when trying to build my project. I'm only trying to call gemm(), so it should be pretty straightforward. Anyway, my dub.json: { "name" : "tcbuilder", "description" : "Thalamocortical network parameter parser", "dependencies" : { "cblas": "~>0.1.0", "scid": "~>0.3.0" } } and the output from `dub build`: Performing "debug" build using dmd for x86_64. cblas 0.1.0: target for configuration "library" is up to date. scid 0.3.0: target for configuration "library" is up to date. tcbuilder ~master: building configuration "application"... blasint = int Linking... .dub/build/application-debug-linux.posix-x86_64-dmd_2069-8ECAC666F541E423658AC8BE0 AB7073/tcbuilder.o: In function `_D3app18__T10matrixMultTdZ10matrixMultFNbxS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewxS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewZS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixView': /home/stiff/Projects/TCBuilder/source/app.d:248: 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!
Nov 11 2015
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.
Nov 11 2015
On Thursday, 12 November 2015 at 05:17:58 UTC, BBasile wrote:On Thursday, 12 November 2015 at 02:02:56 UTC, Stiff wrote:Does the libs element from cblas' dub.json not handle that library linkage? I suppose I should also mention that it was compiling fine before I actually used a function from the library in my code. 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...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.
Nov 11 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 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.On Thursday, 12 November 2015 at 02:02:56 UTC, Stiff wrote: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...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.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...
Nov 11 2015
On Thursday, 12 November 2015 at 06:03:49 UTC, BBasile wrote: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...I think that you would get an error with just the 'import blas.blas' and building the debug config. I've spotted a std.expirmental.allocators bug this summer that was revealed in by a similar scheme: extern declaration not used in release mode, but in debug mode the symbols, even if not used, were not eliminated and the compiler complained about undefined symbol this & that !
Nov 11 2015
On Thursday, 12 November 2015 at 06:11:37 UTC, BBasile wrote:On Thursday, 12 November 2015 at 06:03:49 UTC, BBasile wrote:It's been a few days, but I just wanted to say thanks for the help. I was able to fix the problem by linking to cblas in my dub.json.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...I think that you would get an error with just the 'import blas.blas' and building the debug config. I've spotted a std.expirmental.allocators bug this summer that was revealed in by a similar scheme: extern declaration not used in release mode, but in debug mode the symbols, even if not used, were not eliminated and the compiler complained about undefined symbol this & that !
Nov 16 2015