Something More for Research

Explorer of Research #HEMBAD

Build and Use OpenBLAS in Microsoft Visual Studio

Posted by Hemprasad Y. Badgujar on March 27, 2015


Build and Use OpenBLAS in Microsoft Visual Studio

As of OpenBLAS v0.2.10, it is currently only possible on Windows to build OpenBLAS with MinGW. The resulting library can be used in Visual Studio, but it can only be linked dynamically. This configuration has not been thoroughly tested and should be considered experimental.

Incompatible x86 calling conventions

Due to incompatibilities between the calling conventions of MinGW and Visual Studio you will need to make the following modifications ( 32-bit only ):

  1. Use the newer GCC 4.7.0. The older GCC (<4.7.0) has an ABI incompatibility for returning aggregate structures larger than 8 bytes with MSVC.

Build OpenBLAS on Windows OS

  1. Install the MinGW (GCC) compiler suite, either 32-bit (http://www.mingw.org/) or 64-bit (http://mingw-w64.sourceforge.net/). In addition, please install MSYS with MinGW.
  2. Build OpenBLAS in the MSYS shell. Usually, you can just type “make”. OpenBLAS will detect the compiler and CPU automatically.
  3. After the build is complete, OpenBLAS will generate the static library “libopenblas.a” and the shared dll library “libopenblas.dll” in the folder. You can type “make PREFIX=/your/installation/path install” to install the library to a certain location.

**Notice. We suggest using official MingWin or MingWin-w64 compilers. A user reported that s/he met Unhandled exception by other compiler suite.https://groups.google.com/forum/#!topic/openblas-users/me2S4LkE55w

Generate import library (before 0.2.10 version)

  1. First, you will need to have the lib.exe tool in the Visual Studio command prompt.
  2. Open the command prompt and type cd OPENBLAS_TOP_DIR/exports, where OPENBLAS_TOP_DIR is the main folder of your OpenBLAS installation.
  3. For a 32-bit library, type lib /machine:i386 /def:libopenblas.def. For 64-bit, typelib /machine:X64 /def:libopenblas.def.
  4. This will generate the import library “libopenblas.lib” and the export library “libopenblas.exp” in OPENBLAS_TOP_DIR/exports. Although these two files have the same name, they are totally different.

Generate import library (0.2.10 and after version)

  1. OpenBLAS already generated the import library “libopenblas.dll.a” for “libopenblas.dll”.

Use OpenBLAS .dll library in Visual Studio

  1. Copy the import library (before 0.2.10: “OPENBLAS_TOP_DIR/exports/libopenblas.lib”, 0.2.10 and after: “OPENBLAS_TOP_DIR/libopenblas.dll.a”) and .dll library “libopenblas.dll” into the same folder.
  2. Please follow the documentation about using third-party .dll libraries in MS Visual Studio 2008 or 2010. Make sure to link against a library for the correct architecture. For example, you may receive an error such as “The application was unable to start correctly (0xc00007b)” which typically indicates a mismatch between 32/64-bit libraries.

Notice. If you need CBLAS, you should include cblas.h in /your/installation/path/include in Visual Studio. Please read this page.

Limitations

  • Both static and dynamic linking are supported with MinGW. With Visual Studio, however, only dynamic linking is supported and so you should use the import library.
  • Debugging from Visual Studio does not work because MinGW and Visual Studio have incompatible formats for debug information (PDB vs. DWARF/STABS). You should either debug with GDB on the command-line or with a visual frontend, for instanceEclipse or Qt Creator.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Extracts from a Personal Diary

dedicated to the life of a silent girl who eventually learnt to open up

Num3ri v 2.0

I miei numeri - seconda versione

ThuyDX

Just another WordPress.com site

Algunos Intereses de Abraham Zamudio Chauca

Matematica, Linux , Programacion Serial , Programacion Paralela (CPU - GPU) , Cluster de Computadores , Software Cientifico

josephdung

thoughts...

Tech_Raj

A great WordPress.com site

Travel tips

Travel tips

Experience the real life.....!!!

Shurwaat achi honi chahiye ...

Ronzii's Blog

Just your average geek's blog

Karan Jitendra Thakkar

Everything I think. Everything I do. Right here.

VentureBeat

News About Tech, Money and Innovation

Chetan Solanki

Helpful to u, if u need it.....

ScreenCrush

Explorer of Research #HEMBAD

managedCUDA

Explorer of Research #HEMBAD

siddheshsathe

A great WordPress.com site

Ari's

This is My Space so Dont Mess With IT !!

%d bloggers like this: