⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imslvs2005 .txt

📁 IMSL 库是一个很不错的数值库 有fortran版本和C版本 以下是C版本在VS2005.net下的环境设置.
💻 TXT
字号:

在VS2005 C++程序中调用IMSL程序的问题.

安装应该没有任何问题. 一路next就可.

1.关于VS2005编译环境设置:
这很关键.如果设置不好会出现各种问题.
以下是我的设置,在win2003下,完全行的通

a)首先可能经常要调用imsl,直接设置全局的环境就得了,要不得每个调用imsl的环境都要单独设置.

Tools-opinion-projects and solution-VC++ solutions
Inclue 加入 C:\Program Files\VNI\imsl\cnl600\vs05pc\include
lib 加入C:\Program Files\VNI\imsl\cnl600\vs05pc\lib
注:我的VNL和VS2005均装在C:\Program Files


b)
以下指采用静态编译模式下(以将编译好的移动到另外机子上运行,后面会说明)    

release模式下:
打开Project- *** properties-configuration  properties-

在linker-input-addtional dependences 中加入
imslcmath.lib imslcmath_scalar.lib imslcmath_iblas.lib imslcstat.lib imslcstat_iblas.lib lmgr.lib libcrvs.lib libsb.lib libcmt.lib oldnames.lib kernel32.lib user32.lib netapi32.lib advapi32.lib gdi32.lib comdlg32.lib comctl32.lib wsock32.lib

在linker-ignore all defaut libraries:no
在C/C+-code generation-runtime   /MT


Debug模式:
打开Project- *** properties-configuration  properties-

在linker-input-addtional dependences 中加入
imslcmath.lib imslcmath_scalar.lib imslcmath_iblas.lib imslcstat.lib imslcstat_iblas.lib lmgr.lib libcrvs.lib libsb.lib oldnames.lib kernel32.lib user32.lib netapi32.lib advapi32.lib gdi32.lib comdlg32.lib comctl32.lib wsock32.lib
(比release删掉一个libcmt)
在linker-ignore all defaut libraries:no
ignore specific library:  libc.lib;libcd.lib;libcmt.lib
在C/C+-code generation-runtime   /MTD


c)静态编译连接成功后,可以拷到其它机子上运行exe文件
但是需要把IMSL的 license 文件也拷过去.
并且在 我的电脑-属性-高级-环境变量 添加
变量名为 LM_LICENSE_FILE
值就是那个license.dat的位置.




另外附上 
安装的release的提供的设置,按此设置动态可以通过没有问题;
静态有问题,imsl 与 iostream 冲突

================<  Part 6: Accessing the Library from the  >================
===================<   Microsoft Visual Studio 2005   >===================

You can easily access the IMSL C Numerical Library from the Microsoft Visual 
Studio 2005 Developer Environment.  During the installation, the paths to the 
location of the object library and include files are automatically defined and 
are available to the system through environment variables, if that option is 
selected by the user.  However, the CNL include directory and the names of the 
object libraries must be specified in the Solution or Project Explorer.  
To setup a sample project, follow the steps outlined below:

NOTE: The steps below are intended for a standard Release version of the 
application.  You should make certain that the correct versions of the Microsoft 
Visual C++ runtime libraries (Multi-threaded / Single threaded, DLL / Static, 
Release / Debug) are specified in the Project properties settings for the type 
of project you are building.  See the Visual Studio online help system for more 
information.

   1) Start the Microsoft Visual Studio 2005 Developer Environment

   2) To create a new project
      a) On the File menu, point to New, and then click Project.
      b) In the Project Types area, click Visual C++ and select Win32, 
         then in the Visual Studio installed templates pane, click 
         Win32 Console Application.
      c) Fill in the name of the project.
         When you create a new project, Visual Studio places the project 
         in a solution. Accept the default name for the solution, which 
         by default is the same name as the project.
         You can accept the default location, type in a different location, 
         or browse to a directory where you want to save the project.
      d) From the Overview page of the Win32 Application Wizard dialog, 
         press Next.
      e) Select the Empty Project setting and click Finish.
         You now have a project with no source code files.

      
   3) In the main menu, select Project ==> Add Existing Item... and 
      browse to the file:
      <VNI_DIR>\imsl\cnl600\<ENV>\examples\validate\cmath.c and add it 
      to the project.

   4) Click on Project ==> <project name> Properties ==> Configuration 
      Properties ===> C/C++ ===> General and add the directory: 
      <VNI_DIR>\imsl\cnl600\<ENV>\include to the "Additional Include 
      Directories" list and then click OK.

   5) Follow step 5a if you wish to link to the CNL DLL library or step 
      5b if you wish to link to the CNL static library.  If you are 
      using CNL in a Visual Studio 2005 project for the first time, it 
      is advisable that you link to the DLL version of CNL (step 5a).  
      Unlike the Static version of CNL, the DLL version does not require 
      the additional CNL and FlexLM license manager library files, as 
      they are already linked into the DLL library.  You should only use 
      the static version when you are comfortable with the various 
      project settings and libraries that are necessary to successfully 
      compile a static project.

      a) Using CNL Dynamic Link Library (DLL)

      Choose Project ==> Add Existing Item and choose Files of Type as
      All Files (*.*) and browse to the <VNI_DIR>\imsl\cnl600\<ENV>\lib 
      directory and add the file imslcmath_dll.lib (and/or 
      imslcstat_dll.lib) to the project.  These are the import libraries 
      for the DLL versions of the CNL library, imslcmath_dll.dll and 
      imslcstat_dll.dll, which are located in the CNL bin directory. 
      
      NOTE: If you do not allow the CNL Setup program to update the 
            System Environment Variables, this directory must be added 
            to the environment variable PATH.

      b) Using CNL static library 
      
      NOTE:  Due to requirements in the linker, you must add these 
      libraries to your project in the specified order.

      Choose Project ==> Add Existing Item and choose Files of Type as 
      All Files (*.*) and locate the <VNI_DIR>\imsl\cnl600\<ENV>\lib 
      directory and add these Lib files to the project: imslcmath.lib 
      (and/or imslcstat.lib if necessary), imslcmath_iblas.lib, 
      imslcmath_scalar.lib, lmgr.lib, libcrvs.lib, libsb.lib

      Choose Project ==> Add Existing Item and choose Files of Type as 
      All Files (*.*) and add this file to the project: 
      
      C:\Program Files\Microsoft Visual Studio 8\Vc\lib\libcmt.lib
      
      
      Click on Project ==> <project_name> Properties ==> Configuration 
      Properties ===> Linker ===> Input and add these names under 
      Additional dependencies, with each entry separated by a space:

           netapi32.lib advapi32.lib gdi32.lib 
           comdlg32.lib comctl32.lib wsock32.lib
           
      Click on Project ==> <project_name> Properties ==> Configuration 
      Properties ===> Linker ===> Input and under Ignore Specific 
      Libraries, add this line:

           LIBCD.lib;LIBC.lib

   6) You should be able to build the Solution and run the program, 
      assuming that you have setup the CNL license manager with your 
      licensing information.

Microsoft Visual Studio 2005 is now set up to use the IMSL C Numerical Library. 
Please refer to the Microsoft Visual Studio 2005 documentation for further 
information on the Microsoft Visual Studio 2005 Developer environment.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
还有VNI提供的说明:
使用IMSL C 数值函式库
1. 建立范例程序
此范例程序将解决以下的线性方程式问题:
33x + 16y + 72z = 129
-24x - 10y - 57z = -96
18x - 11y + 7z = 8.5
2. 建立新项目
启动 Visual Studio 并新增 Visual C++ 主控台应用程序项目,命名为 cnl。
 
之后请直接点选完成
 
3. 加入程序代码
复制以下程序至 cnl.cpp 原始码档案并储存。
 
/* Program start */
#include "stdafx.h"
#include <stdio.h>
#include <imsl.h> 
void main()
{
    /* 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;

    /* 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);
} 
/* Program end */
 
编译与执行 IMSL C数值函式库
1. 设定环境变量
如果您之前未设定自动设定环境变量,您必需于IMSL C Library安装位置执行cnlsetup.bat批次檔。
2a. 自【命令提示字符】中编译
为使用【命令提示字符】编译,请开启「开始」 -> 「所有程序」 -> 「Microsoft Visual Studio 2005」 -> 「Visual Studio Tools」 -> 「Visual Studio 2005 命令提示字符」。
Shared Library
> cl cnl.cpp %LINK_CNL_DLL%
Dynamic Library
> cl cnl.cpp %LINK_CNL_STATIC%
2b. 使用 Visual Studio .NET 环境编译
当程序代码输入后需对项目属性设定IMSL C Library。首先在项目-> cnl 属性,开启C/C++ -> 一般。增加路径C:\Program Files\VNI\imsl\cnl600\vs05pc\include至 “其它Include目录”。

Dynamic Link
在项目 -> 加入现有项目,浏览C:\Program Files\VNI\imsl\cnl600\vs05pc\lib\imslcmath_dll.lib加入 到项目,在项目-> cnl 属性,开启C/C++ ->程序代码产生,将”执行阶段链接库”改为
”多执行绪 DLL (/MD)”,最后在窗体列选择建置 -> 建置方案,编译项目。

 
Static Link
1	在项目 -> cnl属性 -> 组态属性 -> 连结器 -> 输入 -> 其它相依性 ->加入netapi32.lib advapi32.lib gdi32.lib comdlg32.lib comctl32.lib wsock32.lib
2	在项目 -> cnl属性 -> 组态属性 -> 连结器 -> 输入 -> 忽略特定链接库加入 LIBCD.lib; LIBC.lib
3	在项目 -> cnl属性 -> 组态属性 -> C/C++ -> 程序代码产生 -> 执行阶段链接库 ->设定为 “多执行绪  (/MT)”
4	在项目 -> 加入现有项目 -> 浏览C:\Program Files\VNI\imsl\cnl600\vs05pc\lib 加入imslcmath.lib (and/or imslcstat.lib), imslcmath_iblas.lib, imslcmath_scalar.lib, lmgr.lib, libcrvs.lib. Libsb.lib
5	在项目 -> 加入现有项目 > 浏览C:\Program Files\Microsoft Visual Studio 8\VC\lib\ 加入libcmt.lib
最后在项目 -> cnl属性 -> 组态属性 -> C/C++ -> 前置处理器产生 -> 前置处理器定义 -> 在”WIN32;_DEBUG;_CONSOLE”后面加上 ”;ANSI” ,(All examples are conform to ANSI C)
6	最后在窗体列选择 建置 -> 建置方案,编译项目






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -