OpenSees开发(一)windows 上编译opensees (使用vs2005)

先贴一段opensees的介绍


“OpenSees的全称是Open System for Earthquake Engineering Simulation (地震工程模拟的开放体系)。它是由美国国家自然科学基金(NSF)资助、西部大学联盟“太平洋地震工程研究中心”(Pacific Earthquake Engineering Research Center,简称PEER)主导、加州大学伯克利分校为主研发而成的、用于结构和岩土方面地震反应模拟的一个较为全面且不断发展的开放的程序软件体系。”


简单的说,它是一套开源的土木工程计算实现的C++类库和框架


下面介绍如何在windows平台利用vs2005编译opensees


1.下载源码:stable.ziparchive


2.下载tcl85

注意:1.请将安装目录从 c:/tcl 改为 c:\program files\tcl

2.如果你安装的是更高版本的activetcl,则可能需要更改头文件:

打开tcl.h,更改结构体的定义:

typedef struct Tcl_Interp {
    char *result;		/* If the last command returned a string
				 * result, this points to it. */
    void (*freeProc) _ANSI_ARGS_((char *blockPtr));
				/* Zero means the string result is statically
				 * allocated. TCL_DYNAMIC means it was
				 * allocated with ckalloc and should be freed
				 * with ckfree. Other values give the address
				 * of function to invoke to free the result.
				 * Tcl_Eval must free it before executing next
				 * command. */
    int errorLine;		/* When TCL_ERROR is returned, this gives the
				 * line number within the command where the
				 * error occurred (1 if first line). */
} Tcl_Interp;
安装完之后需要重新启动计算机

3.解压源码包,打开OpenSees2.3.0\Win32\opensees.sln,让vs自动转换就行

解决方案中有3个exe项目,openSees,openSeesTk,quickmain,其中quickmain为一个简单的实例,代码与OpenSees2.3.0\EXAMPLES\Example1一样,顺便说一下该代码有误,将在之后的分析中解决

将quickmain设为启动项目,编译,出现链接错误

正在链接...
1>LINK : warning LNK4075: 忽略“/INCREMENTAL”(由于“/FORCE”规范)
1>libm.lib(libm_error.obj) : error LNK2019: 无法解析的外部符号 _errno,该符号在函数 ___libm_error_support 中被引用
1>libifcore.lib(for_nt_open_proc.obj) : error LNK2001: 无法解析的外部符号 _errno
1>libifcore.lib(for_portlib.obj) : error LNK2001: 无法解析的外部符号 _errno
1>libifcore.lib(for_init.obj) : error LNK2019: 无法解析的外部符号 __pxcptinfoptrs,该符号在函数 _GETEXCEPTIONPTRSQQ 中被引用
1>.\..\..\bin/OpenSees.exe : fatal error LNK1120: 2 个无法解析的外部命令
1>生成日志保存在“file://d:\Open Source\OpenSees2.3.0\Win32\obj\openSees\debug\BuildLog.htm”
1>openSees - 5 个错误,1 个警告
========== 生成: 0 已成功, 1 已失败, 23 最新, 0 已跳过 ==========

这需要将OpenSees2.3.0\Win32\VC2005errno.cpp加入工程中,不知道为什么原始的版本没有加,现在加入(注意按工程属性决定在*.cpp中是否添加预编译头文件),

再出现错误:

1>LINK : warning LNK4075: 忽略“/INCREMENTAL”(由于“/FORCE”规范)
1>libifcore.lib(for_init.obj) : error LNK2019: 无法解析的外部符号 __pxcptinfoptrs,该符号在函数 _GETEXCEPTIONPTRSQQ 中被引用
1>.\..\..\bin/OpenSees.exe : fatal error LNK1120: 1 个无法解析的外部命令

参考:

http://opensees.berkeley.edu/community/viewtopic.php?t=4624

http://opensees.berkeley.edu/community/viewtopic.php?t=5462

将链接输入库中的libifcore.lib改为libifcoremt.lib,ok,链接成功。


接下去,对于主工程quickmain,有众多项目依赖性,导致每次重新生成该项目会将其它lib项目重新编译,徒增编译时间(假定lib项目源码永远不改动的情况下),于是将项目依赖性全部清除,出现链接错误,根据排除法确定问题所在,在quickmain项目的链接依赖项中加入handler.lib 链接成功。



posted on 2014-06-15 01:04  silyvin  阅读(738)  评论(0编辑  收藏  举报