www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Problems with static linking of c libraries

--bcaec548a0b9f130ac04a806d3fa
Content-Type: text/plain; charset=ISO-8859-1

Hey all,

I'm trying to build a D application which statically links in the the blas
and lapack libraries
(from http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html ). When
downloading the
pre-build libraries from the website I link them in using:

pragma(lib, "blas");
pragma(lib, "lapack");

Compiling isn't a problem but then optlink complains:

OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
blas.lib
 Error 43: Not a Valid Library File

First I thought this was due to the fact that I was running on windows 2008
(32 bit version) but
I also tried on windows XP professional, with the same result...

I decided to build the libraries myself using Cmake and VisualStudio 2010,
this however also
has the same result:

OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
blas.lib
 Error 43: Not a Valid Library File

I am able to build the packages using the MinGW toolchain (using GNU C/CPP)
however I then end up with
libblas.a and liblapack.a files, which causes the linker to not find the
libraries (under windows it searches for
the .lib extension). renaming them leads again to the msg seen above (Not a
Valid Library)

Any help on how to statically link these 2 packages in my executable using
windows ?

Kid regards,
Danny

Ps. I need to avoid the use of dynamic linking

--bcaec548a0b9f130ac04a806d3fa
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hey all,<div><br></div><div>I&#39;m trying to build a D application which s=
tatically links in the the blas and lapack libraries=A0</div><div>(from=A0<=
span class=3D"Apple-style-span" style=3D"border-collapse: collapse; color: =
rgb(68, 68, 68); font-family: arial, sans-serif; font-size: 13px; "><a href=
=3D"http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html" target=3D"=
_blank" style=3D"color: rgb(34, 34, 34); ">http://icl.cs.utk.edu/lapack-for=
-windows/clapack/index.html</a>=A0).=A0</span><span class=3D"Apple-style-sp=
an" style=3D"border-collapse: collapse; color: rgb(68, 68, 68); font-family=
: arial, sans-serif; ">When downloading the=A0</span></div>
<div><span class=3D"Apple-style-span" style=3D"border-collapse: collapse; c=
olor: rgb(68, 68, 68); font-family: arial, sans-serif; ">pre-build librarie=
s from the website I link them in using:</span></div><div><span class=3D"Ap=
ple-style-span" style=3D"border-collapse: collapse; color: rgb(68, 68, 68);=
 font-family: arial, sans-serif; "><br>
</span></div><div><span class=3D"Apple-style-span" style=3D"border-collapse=
: collapse; color: rgb(68, 68, 68); font-family: arial, sans-serif; ">pragm=
a(lib, &quot;blas&quot;);</span></div><div><font class=3D"Apple-style-span"=
 color=3D"#444444" face=3D"arial, sans-serif"><span class=3D"Apple-style-sp=
an" style=3D"border-collapse: collapse;">pragma(lib, &quot;lapack&quot;);</=
span></font></div>
<div><font class=3D"Apple-style-span" color=3D"#444444" face=3D"arial, sans=
-serif"><span class=3D"Apple-style-span" style=3D"border-collapse: collapse=
;"><br></span></font></div><div><font class=3D"Apple-style-span" color=3D"#=
444444" face=3D"arial, sans-serif"><span class=3D"Apple-style-span" style=
=3D"border-collapse: collapse;">Compiling isn&#39;t a problem but then optl=
ink complains:</span></font></div>
<div><font class=3D"Apple-style-span" color=3D"#444444" face=3D"arial, sans=
-serif" size=3D"1"><span class=3D"Apple-style-span" style=3D"border-collaps=
e: collapse;"><br></span></font></div><div><font class=3D"Apple-style-span"=
 color=3D"#444444" face=3D"arial, sans-serif"><div style=3D"border-collapse=
: collapse; font-size: x-small; ">
OPTLINK (R) for Win32 =A0Release 8.00.12</div><div style=3D"border-collapse=
: collapse; font-size: x-small; ">Copyright (C) Digital Mars 1989-2010 =A0A=
ll rights reserved.</div><div style=3D"border-collapse: collapse; font-size=
: x-small; ">
<a href=3D"http://www.digitalmars.com/ctg/optlink.html">http://www.digitalm=
ars.com/ctg/optlink.html</a></div><div style=3D"border-collapse: collapse; =
font-size: x-small; ">blas.lib</div><div style=3D"border-collapse: collapse=
; font-size: x-small; ">
=A0Error 43: Not a Valid Library File</div><div style=3D"border-collapse: c=
ollapse; font-size: x-small; "><br></div><div style=3D"border-collapse: col=
lapse; ">First I thought this was due to the fact that I was running on win=
dows 2008 (32 bit version) but=A0</div>
<div style=3D"border-collapse: collapse; ">I also tried on windows XP profe=
ssional, with the same result...</div><div style=3D"border-collapse: collap=
se; "><br></div><div><span class=3D"Apple-style-span" style=3D"border-colla=
pse: collapse;">I=A0decided=A0to build the libraries myself using Cmake and=
 VisualStudio 2010, this however also=A0</span></div>
<div><span class=3D"Apple-style-span" style=3D"border-collapse: collapse;">=
has the same result:</span></div><div><span class=3D"Apple-style-span" styl=
e=3D"border-collapse: collapse;"><br></span></div></font><div style=3D"colo=
r: rgb(68, 68, 68); font-family: arial, sans-serif; border-collapse: collap=
se; font-size: x-small; ">
OPTLINK (R) for Win32 =A0Release 8.00.12</div><div style=3D"color: rgb(68, =
68, 68); font-family: arial, sans-serif; border-collapse: collapse; font-si=
ze: x-small; ">Copyright (C) Digital Mars 1989-2010 =A0All rights reserved.=
</div>
<div style=3D"color: rgb(68, 68, 68); font-family: arial, sans-serif; borde=
r-collapse: collapse; font-size: x-small; "><a href=3D"http://www.digitalma=
rs.com/ctg/optlink.html">http://www.digitalmars.com/ctg/optlink.html</a></d=
iv>
<div style=3D"color: rgb(68, 68, 68); font-family: arial, sans-serif; borde=
r-collapse: collapse; font-size: x-small; ">blas.lib</div><div style=3D"col=
or: rgb(68, 68, 68); font-family: arial, sans-serif; border-collapse: colla=
pse; font-size: x-small; ">
=A0Error 43: Not a Valid Library File</div><div style=3D"color: rgb(68, 68,=
 68); font-family: arial, sans-serif; border-collapse: collapse; font-size:=
 x-small; "><br></div><div style=3D"color: rgb(68, 68, 68); font-family: ar=
ial, sans-serif; border-collapse: collapse; ">
I am able to build the packages using the MinGW toolchain (using GNU C/CPP)=
 however I then end up with=A0</div><div><font class=3D"Apple-style-span" c=
olor=3D"#444444" face=3D"arial, sans-serif"><span class=3D"Apple-style-span=
" style=3D"border-collapse: collapse;">libblas.a and liblapack.a files, whi=
ch causes the linker to not find the libraries (under windows it=A0searches=
=A0for=A0</span></font></div>
<div><font class=3D"Apple-style-span" color=3D"#444444" face=3D"arial, sans=
-serif"><span class=3D"Apple-style-span" style=3D"border-collapse: collapse=
;">the .lib extension). renaming them leads again to the msg seen above (No=
t a Valid Library)</span></font></div>
</div><div><font class=3D"Apple-style-span" color=3D"#444444" face=3D"arial=
, sans-serif"><span class=3D"Apple-style-span" style=3D"border-collapse: co=
llapse;"><br></span></font></div><div><font class=3D"Apple-style-span" colo=
r=3D"#444444" face=3D"arial, sans-serif"><span class=3D"Apple-style-span" s=
tyle=3D"border-collapse: collapse;">Any help on how to statically link thes=
e 2 packages in my executable using windows ?</span></font></div>
<div><font class=3D"Apple-style-span" color=3D"#444444" face=3D"arial, sans=
-serif"><span class=3D"Apple-style-span" style=3D"border-collapse: collapse=
;"><br></span></font></div><div><font class=3D"Apple-style-span" color=3D"#=
444444" face=3D"arial, sans-serif"><span class=3D"Apple-style-span" style=
=3D"border-collapse: collapse;">Kid regards,</span></font></div>
<div><font class=3D"Apple-style-span" color=3D"#444444" face=3D"arial, sans=
-serif"><span class=3D"Apple-style-span" style=3D"border-collapse: collapse=
;">Danny</span></font></div><div><font class=3D"Apple-style-span" color=3D"=
#444444" face=3D"arial, sans-serif"><span class=3D"Apple-style-span" style=
=3D"border-collapse: collapse;"><br>
</span></font></div><div><span class=3D"Apple-style-span" style=3D"border-c=
ollapse: collapse; color: rgb(68, 68, 68); font-family: arial, sans-serif; =
">Ps. I need to avoid the use of=A0dynamic linking</span></div>

--bcaec548a0b9f130ac04a806d3fa--
Jul 14 2011