[CMake] underscore mangling with blas and cmake

Michael Wild themiwi at gmail.com
Mon Oct 24 02:43:20 EDT 2011


On 10/24/2011 05:25 AM, Jack Chessa wrote:
> 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 <mailto:jfchessa at utep.edu>
> Office:    A309
> Voice:     (915) 747-6900
> Fax:                        (915) 747-5019
> Web:       http://utminers.utep.edu/jfchessa/index.html

Do you invoke target_link_libraries? Something like this:

target_link_libraries(foo ${BLAS_LIBRARIES})



Michael


More information about the CMake mailing list