Re: [CMake] underscore mangling with blas and cmake

2011-10-24 Thread Kelly Thompson
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/.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-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of
Jack Chessa
Sent: Sunday, October 23, 2011 9:25 PM
To: cmake@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:jfche...@utep.edu

Office:A309

Voice: (915) 747-6900

Fax:(915) 747-5019

Web:   http://utminers.utep.edu/jfchessa/index.html

 

 

 

 

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] underscore mangling with blas and cmake

2011-10-23 Thread Michael Wild
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:jfche...@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
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] underscore mangling with blas and cmake

2011-10-23 Thread Jack Chessa
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:jfche...@utep.edu
Office:A309
Voice: (915) 747-6900
Fax:(915) 747-5019
Web:   http://utminers.utep.edu/jfchessa/index.html




--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake