台北市 11076 信 義區松德路 12 號 10F
10F, #12, Song De Rd. , Taipei , 11076, Tai wan
T E L : 0 2 - 2 3 4 5 - 7 7 9 9 FA X : 0 2 - 2 3 4 5 - 0 8 6 7
w w w. i d m i n e r. c o m . t w 統 一 編 號 : 8 0 2 9 9 1 9 1
How to use IMSL CNL v8 試用版 in Visual Studio 2010 Express
前言: IMSL CNL v8 程式庫正式支援 Visual Studio 2010 專業開發, 企業, 及團隊開發
版(Professional/Premium/Ultimate)版本, 不過仍可支援 Microsoft 提供的免費版本
Visual Studio 2010 Express 簡易版, 但因為是簡易版, IMSL CNL v8 在 Express 版使用
會有一些限制, 此文件說明要如何在 2010 Express 版下使用 IMSL CNL v8 試用版.
使用限制:
IMSL CNL 8 如果是配合 MS Visual Studio 2010 express 版使用, 則有如下限制:
1. 2010 express 版只支援 IMSL CNL 8 32-bit 版, 不支援 64-bit 版
2. static link 方式不支援, 只支援 dll link 方式
3. 所有程式開發須在 Release mode 下, 不能在 Debug mode.
事前準備:
1. 下載 Visual Studio 2010 Express All-in-One ISO 中文版
- 網址 http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express-iso
或者
- 網址 http://msdn.microsoft.com/zh-tw/express/aa718373
2. 下載 Microsoft Visual C++ 2010 可轉散發套件(x86)中文版
- 可網路搜尋, 或到以下 Microsoft 網址
http://www.microsoft.com/downloads/zh-tw/details.aspx?familyid=a7b7a05e-6de6-4d3a-a42337bf0912db84
3. 下載 IMSL CNL v8 for Windows 32-bit 試用版
- 請至採智科技網站(www.idminer.com.tw)的產品頁 "IMSL C Lib 程式庫(CNL)" 下的 "檔案下載" 分
頁下載 32-bit 版 (CNL 64-bit 版不支援 2010 Express).
- 下載後請跟採智科技索取試用授權碼檔案(license.dat), 試用授權有使用期限限制
硬體環境:
筆電: Intel i5-2520M CPU(64-bit 雙核) with Win 7 專業版(64-bit 版)
安裝軟體:
1. 先安裝 Visual Studio 2010 All-in-One, 其中選擇安裝 VC++ 2010 Express 即可
- 如在 Win Vista / Win7 安裝, 安裝時可能需要關閉 UAC 使用者帳戶控制
- 安裝後是試用授權, 但可用 Windows Live Messenger, MSN or, Hotmail 等帳號來註冊為永久授權
1
台北市 11076 信 義區松德路 12 號 10F
10F, #12, Song De Rd. , Taipei , 11076, Tai wan
T E L : 0 2 - 2 3 4 5 - 7 7 9 9 FA X : 0 2 - 2 3 4 5 - 0 8 6 7
w w w. i d m i n e r. c o m . t w 統 一 編 號 : 8 0 2 9 9 1 9 1
2. 再安裝 Microsoft Visual C++ 2010 可轉散發套件(x86)中文版
3. 安裝 IMSL CNL v8 (不論電腦是 32 or 64 bit CPU)
- 配合 2010 Express 版使用, 請選擇 IA32 架構安裝(不要選 x64 架構)
- 配合 2010 Express 版使用, 請選擇 only IMSL 安裝(不要選 MKL&CUDA 版)
- 安裝時如要求輸入 license #, 可輸入 999999
要自動設定環境變數, 請選 Yes
4. 請將採智科技提供的試用授權碼檔案(license.lic or license.dat), 儲存在 IMSL 安裝
路徑下的 license 目錄內, 以 Win 7 而言, 是 C:\Program Files (x86)\VNI\license\下.
安裝軟體及儲存 license.lic 檔完成後, 請重新開機
2
台北市 11076 信 義區松德路 12 號 10F
10F, #12, Song De Rd. , Taipei , 11076, Tai wan
T E L : 0 2 - 2 3 4 5 - 7 7 9 9 FA X : 0 2 - 2 3 4 5 - 0 8 6 7
w w w. i d m i n e r. c o m . t w 統 一 編 號 : 8 0 2 9 9 1 9 1
5. 檢查環境變數設定
- 在 IMSL 安裝時會自動設定系統環境變數, 建議在個人使用者變數, 也新增相同設定
- 在 Win 7 下: 控制台->系統及安全性->系統->進階系統設定->環境變數
- 新增變數: 變數名稱- LM_LICENSE_FILE 值- C:\Program Files (x86)\VNI\license
使用 IMSL C Library 函式庫 for Visual Studio 2010 Express 範例
步驟如下:
1. 啟動 Visual C++ 2010 Express
2. 新增專案: 選單列, 檔案->新增->專案, 選 Win32 主控台應用程式, 下方名稱輸入
cnl (或你自定的名稱), 確定
3
台北市 11076 信 義區松德路 12 號 10F
10F, #12, Song De Rd. , Taipei , 11076, Tai wan
T E L : 0 2 - 2 3 4 5 - 7 7 9 9 FA X : 0 2 - 2 3 4 5 - 0 8 6 7
w w w. i d m i n e r. c o m . t w 統 一 編 號 : 8 0 2 9 9 1 9 1
3. 調整 mode: 產生 cnl.cpp 專案後, 上方的工具列中, 將下拉選單的 Debug 改成
Release mode (2010 Express 版才需調整)
4. 新增程式碼
- 這是一個簡單的程式, 計算下方的線性方程式:
33x + 16y + 72z = 129
-24x - 10y - 57z = -96
18x - 11y + 7z = 8.5
- 請 Copy 下列程式碼到 cnl.cpp 並存檔
/* Program start */
/* The header file for Mathematics of the IMSL C Library. */
/* For Statistics, use <imsl.h>. */
#include "stdafx.h"
#include <imsl.h>
int _tmain(int argc, _TCHAR* argv[])
{
/* variable declaration */
int n = 3;
float *x;
static float a[] = {33.0, 16.0, 72.0,
-24.0, -10.0, -57.0,
18.0, -11.0, 7.0};
static float b[] = {129.0, -96.0, 8.5};
float *p_inva;
4
台北市 11076 信 義區松德路 12 號 10F
10F, #12, Song De Rd. , Taipei , 11076, Tai wan
T E L : 0 2 - 2 3 4 5 - 7 7 9 9 FA X : 0 2 - 2 3 4 5 - 0 8 6 7
w w w. i d m i n e r. c o m . t w 統 一 編 號 : 8 0 2 9 9 1 9 1
/* The main IMSL function call to solve for x in Ax=B.
* This is the floating point version, to use
* double-precision arguments, call
* imsl_d_lin_sol_gen */
x = imsl_f_lin_sol_gen(n, a, b, 0);
/* Optional arguments are included after required
* arguments. These are usually preceded by a constant
* named IMSL_* indicating which optional argument is
* being passed.In this example, we request the inverse
* of the a matrix */
x = imsl_f_lin_sol_gen (n, a, b,
IMSL_INVERSE, &p_inva,
0);
/* Print the solution x and the inverse of a using
* write_matrix, a printing utility */
imsl_f_write_matrix ("Solution x", 1, n, x, 0);
imsl_f_write_matrix ("Inverse of A", n, n, p_inva, 0);
return 0;
}
/* Program end */
5
台北市 11076 信 義區松德路 12 號 10F
10F, #12, Song De Rd. , Taipei , 11076, Tai wan
T E L : 0 2 - 2 3 4 5 - 7 7 9 9 FA X : 0 2 - 2 3 4 5 - 0 8 6 7
w w w. i d m i n e r. c o m . t w 統 一 編 號 : 8 0 2 9 9 1 9 1
5. 將 IMSL 目錄 include 到專案內: 選單列, 專案->cnl 屬性->點開"組態屬性"->點開
"C/C++"->一般->其他 Include 目錄, 編輯將其指到 IMSL CNL 安裝路徑下的 include
目錄
- 在 Win 7 下, 如 C:\Program Files (x86)\VNI\imsl\cnl800\winms100i32\include
6. 將所需 link 的物件加入: 選單列, 專案->加入現有項目, 到 IMSL CNL 安裝路徑下的
lib 目錄 (在 Win 7 是 C:\Program Files (x86)\VNI\imsl\cnl800\winms100i32\lib\)
- 以此範例, 只需加入 imslcmath_imsl_dll.lib 物件即可, 但建議可將 lib 目錄下所有
imslc*開頭的物件都選擇加入
6
台北市 11076 信 義區松德路 12 號 10F
10F, #12, Song De Rd. , Taipei , 11076, Tai wan
T E L : 0 2 - 2 3 4 5 - 7 7 9 9 FA X : 0 2 - 2 3 4 5 - 0 8 6 7
w w w. i d m i n e r. c o m . t w 統 一 編 號 : 8 0 2 9 9 1 9 1
7. 編譯 Compile 專案: 選單列, 建置->建置方案
執行程式:
8.a. 由 2010 Express 執行: 選單列, 偵錯->啟動但不偵錯, 就會出現結果畫面
8.b. 用指令列來執行程式
- 開始->所有程式->Microsoft Visual Studio 2010 Express->Visual Studio 命令提示
字元(2010), 就會開啟指令列視窗
- 將指令列的目錄, 更改到 cnl.cpp 所在的目錄
- 在指令列輸入> cl cnl.cpp %LINK_CNL_SHARED% 即會出現結果視窗. (2010
Express 版不支援 static link 方式)
7
© Copyright 2026