Dec 5, 2011

1.1 第一個程式

這篇要說明怎樣跑第一個LAPACK程式,內容是參考這邊。此篇是接續上一篇的結果
繼續下去做的。


原文
  1. Download the LAPACK precompiled binaries for MinGW. You should have a two files: liblapack.lib andliblapack.dll (libblas.lib libblas.dll if you also want the Reference BLAS) .
  2. OPTIONAL: Obtain a tuned version of BLAS for your machine (refer to "Compiling GotoBLAS").
  3. Create a Visual Studio project with the following sample C program:
  4. For C++ program, rename the prototypes in the above program to
    void dgesv_( )
    void dgels_( )
    
    to 
    extern "C" void dgesv_( )
    extern "C" void dgels_( )
    
  5. Add the the BLAS and LAPACK libraries to the Visual Studio project settings,
    under Linker -> General -> Additional Library Directories: the directory where your liblapack.lib is.
    under Linker -> Input -> Additional Dependencies: libblas.lib;liblapack.lib (For example, on my machine, I am using the Reference BLAS)
    Note: because BLAS libraries commonly provide faster versions of some LAPACK subroutines, the BLAS library must be listed before before LAPACK library.
    Note: make sure that all the dll (BLAS, LAPACK, MinGW dlls) are on your system path or copy them in the WINDOWS\system32 folder, else binary won't run.
  6. Compile the project and run the resulting executable. You should get the output: The solution is
    -0.661082 9.456125 -16.014625

1. 上一篇做完後,其實第一步已經完成了。

 2.  接下來就開VC2010,開個新專案。然後把  範例的程式貼上去。

 3. 把使用到的 void dgesv_( )與 void dgels_( ) 改成
     extern "C" void dgels_ 與 extern "C" void dgels_

 4. 把要連結的lib 與dll 設定好。

 5. 就可編譯,執行後就可以看到結果了。ya~
 


No comments: