[CMake] underscore mangling with blas and cmake
Kelly Thompson
kgt at lanl.gov
Mon Oct 24 10:34:38 EDT 2011
Jack,
1. As Michael mentioned - ensure that you are linking to the BLAS
library:
find_package(BLAS REQUIRED)
add_executable( foo ${sources} )
target_link_library( foo ${BLAS_LIBRARIES} )
2. FYI - For the Makefile Generator, the object files are usually stored
in a subdirectory named 'CMakeFiles/<target_name>.dir' You can run nm on
these *.o files to examine the name mangling. When calling BLAS routines, I
normally need to append an underscore to the call from C++.
3. Eventually, you may want to consider using the
FortranCInterface.cmake module to determine the current name mangling
system. You can use this information along with CPP macros to ensure that
your code ports to other compilers/platforms.
-kt
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of
Jack Chessa
Sent: Sunday, October 23, 2011 9:25 PM
To: cmake at cmake.org
Subject: [CMake] underscore mangling with blas and cmake
I am new to cmake and have a question that I hope has a simple answer. I am
building a simple C++ program that uses blas scopy. I am using
find_package(BLAS REQUIRED)
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
Undefined symbols:
"_scopy_", referenced from:
_main in blas_ex.cpp.o
I usually can fix this with the -fleading-underscore or
-fnoleading-underscore or -Dadd_... but I am not really sure what is going
on in the cmake build or the Makefile that cmake creates. I don't see any
.o files to nm on either. So my question is what is the best way to deal
with underscore issues in cmake? Does anyone have a simple example for
using cmake to build a c++ program with blas or lapack.
Thanks
Jack Chessa
Associate Professor
Department of Mechanical Engineering
University of Texas at El Paso
Email: jfchessa at utep.edu
Office: A309
Voice: (915) 747-6900
Fax: (915) 747-5019
Web: http://utminers.utep.edu/jfchessa/index.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111024/c29da613/attachment.htm>
More information about the CMake
mailing list