<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.apple-tab-span
        {mso-style-name:apple-tab-span;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Arial","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:974800655;
        mso-list-type:hybrid;
        mso-list-template-ids:-1197067026 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='word-wrap: break-word;-webkit-nbsp-mode: space;-webkit-line-break: after-white-space'><div class=WordSection1><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>Jack,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>As Michael mentioned &#8211; ensure that you are linking to the BLAS library:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='margin-left:.25in'><span style='font-size:10.0pt;font-family:"Courier New";color:#1D1B11'>find_package(BLAS REQUIRED)<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.25in'><span style='font-size:10.0pt;font-family:"Courier New";color:#1D1B11'>add_executable( foo ${sources} )<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.25in'><span style='font-size:10.0pt;font-family:"Courier New";color:#1D1B11'>target_link_library( foo ${BLAS_LIBRARIES} )<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>FYI &#8211; For the Makefile Generator, the object files are usually stored in a subdirectory named &#8216;CMakeFiles/&lt;target_name&gt;.dir&#8217; &nbsp;&nbsp;You can run nm on these *.o files to examine the name mangling.&nbsp; When calling BLAS routines, I normally need to append an underscore to the call from C++.<o:p></o:p></span></p><p class=MsoListParagraph><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>Eventually, you may want to consider using the FortranCInterface.cmake module to determine the current name mangling system.&nbsp; You can use this information along with CPP macros to ensure that your code ports to other compilers/platforms.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'>-kt<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> cmake-bounces@cmake.org [mailto:cmake-bounces@cmake.org] <b>On Behalf Of </b>Jack Chessa<br><b>Sent:</b> Sunday, October 23, 2011 9:25 PM<br><b>To:</b> cmake@cmake.org<br><b>Subject:</b> [CMake] underscore mangling with blas and cmake<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I am new to cmake and have a question that I hope has a simple answer. &nbsp;I am building a simple C++ program that uses blas scopy. &nbsp;I am using<o:p></o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>find_package(BLAS REQUIRED)<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>to find blas on the system (OSX in this case), and the cmake step seems to find it, but when I go to the make step I get the&nbsp;<o:p></o:p></p></div><div><div><p class=MsoNormal>Undefined symbols:<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; &quot;_scopy_&quot;, referenced from:<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; &nbsp; &nbsp; _main in blas_ex.cpp.o<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>I usually can fix this with the&nbsp;-fleading-underscore or&nbsp;-fnoleading-underscore or -Dadd_... but I am not really sure what is going on in the cmake build or the Makefile that cmake creates. &nbsp;I don't see any .o files to nm on either. &nbsp;So my question is what is the best way to deal with underscore issues in cmake? &nbsp;Does anyone have a simple example for using cmake to build a c++ program with blas or lapack.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Thanks<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><div><div><div><p class=MsoNormal><span class=apple-style-span><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif"'>Jack Chessa</span></span><o:p></o:p></p></div><div><div><div><div><div><div><div><div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>Associate&nbsp;Professor</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>Department of Mechanical Engineering</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>University of Texas at El Paso</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>Email:<span class=apple-tab-span>&nbsp;&nbsp;&nbsp;&nbsp;</span><a href="mailto:jfchessa@utep.edu">jfchessa@utep.edu</a></span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>Office:<span class=apple-tab-span>&nbsp;&nbsp;&nbsp;&nbsp;</span>A309</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>Voice:<span class=apple-tab-span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>(915) 747-6900</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>Fax:<span class=apple-tab-span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>(915) 747-5019</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:black'>Web:<span class=apple-tab-span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><a href="http://utminers.utep.edu/jfchessa/index.html">http://utminers.utep.edu/jfchessa/index.html</a></span><o:p></o:p></p></div></div></div></div></div></div></div></div></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div></div></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div></div></body></html>