NX12.0 二次开发使用VS2012 报错解决方案
NX12.0 二次开发使用VS2012 报错解决方案严格的讲NX12.0需要使用VS2015进行开发,这里说下如果你是低版本的解决方案,但是不推荐!
(1)安装完后,点击Open Wizard 告诉你创建项目错误
这种问题就是编译器版本不符合官方的匹配导致的,更改方法很简单
打开 C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcprojects下的NX12_NXOpenCPP.vsz 将
Wizard=VsWizard.VsWizardEngine.14.0 中的14 改成11 也就是对应的VS2012
这样创建的对话框就可以出来了!
(2)你可能还会遇到路径错误,path not found, 建议对这个文件进行修改,尤其是你有多个版本存在的话,一劳永逸
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\VCWizards\NX11_NXOpenCPP\scripts\1033 下的default.js 文件
修改里面的环境变量路径,注意路径是双反斜线 \\,参考如下!
//@<DEL>@ TEXT ENCLOSED within delete markers will be REMOVED
// 09-Jun-2012 Frank Berger Initial Release for VS2010 based on "NX8 Open Wizard"
// 31-Okt-2013 Frank Berger modified for VS2012
// 13-Feb-2015 Sudhir Pawar ARCH:11320: Added libufun_die.lib,libufun_vdac.lib & libufun_weld.lib
// 21-Dec-2015 Purushottam Thakre Fixed PR#7567548: Call DeletePlatform function to delete 'Win32' platform.
// 08-Jan-2016 Prabhakar Mandlik Fixed PR#7588129: Added /d1scalableinclude- switch.
// 10-Feb-2016 Purushottam Thakre Fixed PR#7630769: Reverted changes done to fix PR#7567548 which is causing regression
//TEXT ENCLOSED within delete markers will be REMOVED @<DEL>@
function OnFinish(selProj, selObj)
{
try
{
var bodyTemplateFile = wizard.FindSymbol("TEMPLATES_PATH") + "\\" + "body_template.txt";
var bodyTemplateText = wizard.RenderTemplateToString(bodyTemplateFile);
wizard.AddSymbol("BODY_TEMPLATE", bodyTemplateText);
var entryPointsTemplateFile = wizard.FindSymbol("TEMPLATES_PATH") + "\\" + "entry_points_template.txt";
var entryPointsTemplateText = wizard.RenderTemplateToString(entryPointsTemplateFile);
wizard.AddSymbol("ENTRY_POINTS_TEMPLATE", entryPointsTemplateText);
var unloadOption = "UNLOAD_IMMEDIATELY";
if ( wizard.FindSymbol( "UF_UNLOAD_UG_TERMINATE" ) )
{
unloadOption = "UF_UNLOAD_UG_TERMINATE";
}
else if ( wizard.FindSymbol( "UNLOAD_SEL_DIALOG" ) )
{
unloadOption = "UF_UNLOAD_SEL_DIALOG";
}
wizard.AddSymbol("UF_UNLOAD_OPTION", unloadOption);
// Assign the project path and project name
var strProjectPath = wizard.FindSymbol("PROJECT_PATH");
var strProjectName = wizard.FindSymbol("PROJECT_NAME");
var strClassName = wizard.FindSymbol("MAIN_CLASS_NAME");
if ( strClassName.length < 1 )
{
wizard.AddSymbol("MAIN_CLASS_NAME", "NONAME");
}
// Create the Visual C++ project and call it "NXOpenProj"
selProj = CreateProject(strProjectName, strProjectPath);
// selProj.Object.Keyword = "NXOpenProj"
// Add common and specific configurations to the project
AddCommonConfig(selProj, strProjectName);
AddSpecificConfig(selProj, strProjectName);
// selProj.Object.keyword = "MFCDLLProj";
//Set the project filters
SetupFilters(selProj);
// Add files to the project from the project's Templates.inf file
AddFilesToProjectWithInfFile(selProj, strProjectName);
selProj.Object.Save();
}
catch(e)
{
if (e.description.length != 0)
SetErrorInfo(e);
return e.number
}
}
function SetFileProperties(projfile, strName)
{
return false;
}
function DoOpenFile(strTarget)
{
return false;
}
function GetTargetName(strName, strProjectName, strResPath, strHelpPath)
{
try
{
var strTarget = strName;
if (strName.substr(0, 4) == "root")
{
var strlen = strName.length;
if (strName == "root.ico" || strName == "root.rc2")
{
var strSafeProjectName = wizard.FindSymbol("SAFE_PROJECT_NAME");
strSafeTarget = strSafeProjectName + strName.substr(4, strlen - 4);
strTarget = strResPath + "\\" + strSafeTarget;
}
else if (strName == "root.txt" )
{
strTarget = strProjectName + ".cpp";
}
else
{
strTarget = strProjectName + strName.substr(4, strlen - 4);
}
return strTarget;
}
switch (strName)
{
case "readme.txt":
strTarget = "ReadMe.txt";
break;
case "all.rc":
case "dlgall.rc":
strTarget = strProjectName + ".rc";
break;
case "dlgres.h":
case "resource.h":
strTarget = "Resource.h";
break;
default:
break;
}
return strTarget;
}
catch(e)
{
throw e;
}
}
function AddSpecificConfig(proj, strProjectName)
{
try
{
var isDllApp = wizard.FindSymbol("DLL_APPLICATION");
var isCxx = true;
var appType;
var appExtension;
proj.ConfigurationManager.AddPlatform("x64", "Win32", true);
if ( isDllApp )
{
appType = typeDynamicLibrary;
appExtension = ".dll";
}
else
{
appType = typeApplication;
appExtension = ".exe";
}
var linkLibs = "libufun.lib";
linkLibs += " libufun_cae.lib";
linkLibs += " libufun_cam.lib";
linkLibs += " libufun_die.lib";
linkLibs += " libufun_vdac.lib";
linkLibs += " libufun_weld.lib";
if ( isCxx)
{
var wshell = new ActiveXObject("WScript.Shell")
var libpath ="D:\\dsplm\\Siemens\\NX12\\ugopen";
var Fo =new ActiveXObject("Scripting.FileSystemObject");
var FSo = new Enumerator(Fo.GetFolder(libpath).Files);
var nxopencppName = "libnxopencpp";
for(; !FSo.atEnd(); FSo.moveNext())
{
if(FSo.item().name.match("^"+nxopencppName)==nxopencppName) //check if file name start with libnxopencpp
if(FSo.item().name.slice(FSo.item().name.lastIndexOf(".")+1).toLowerCase() == "lib") //check if file has '.lib' as an extension
{
linkLibs =linkLibs + " " + FSo.item().name;
}
}
}
if ( isDllApp )
{
linkLibs += " libugopenint.lib";
linkLibs += " libugopenint_cae.lib";
linkLibs += " libugopenint_cam.lib";
if ( isCxx)
linkLibs += " libnxopenuicpp.lib";
}
//=================================================================
//Debug Configuration
//=================================================================
//LRJ - add x64
var config = proj.Object.Configurations("Debug|x64");
config.ConfigurationType = appType;
config.CharacterSet = charSetUnicode;
config.useOfMfc = useMfcStdWin;
var CLTool = config.Tools("VCCLCompilerTool");
var strDefines = GetPlatformDefine(config);
strDefines += "_CRT_SECURE_NO_WARNINGS;_SECURE_SCL=0";
if ( isDllApp )
{
strDefines += ";_USRDLL";
}
else
{
strDefines += ";_CONSOLE";
}
CLTool.PreprocessorDefinitions = strDefines;
config.UseOfMFC = useMfcDynamic;
CLTool.RuntimeLibrary = rtMultiThreadedDLL;
CLTool.TreatWChar_tAsBuiltInType = true;
CLTool.DebugInformationFormat = debugEnabled;
CLTool.AdditionalIncludeDirectories = "D:\\dsplm\\Siemens\\NX12\\ugopen";
CLTool.RuntimeTypeInfo = 1;
CLTool.UsePrecompiledHeader = pchNone;
CLTool.AdditionalOptions = "/d1scalableinclude-";
//LRJ - change for X64 - add TargetMachine
var LinkTool = config.Tools("VCLinkerTool");
LinkTool.TargetMachine = machineAMD64;
LinkTool.LinkIncremental = linkIncrementalYes;
LinkTool.GenerateDebugInformation = true;
LinkTool.OutputFile = "$(OutDir)/" + strProjectName + appExtension;
if ( isDllApp )
LinkTool.ImportLibrary = "$(OutDir)/" + strProjectName + ".lib";
LinkTool.AdditionalLibraryDirectories = "D:\\dsplm\\Siemens\\NX12\\ugopen";
LinkTool.AdditionalDependencies = linkLibs;
LinkTool.SubSystem = subSystemConsole;
//LRJ - add following line for X64 definition
dte.ExecuteCommand("Build.SolutionPlatforms", "x64");
//=================================================================
//Release Configuration
//=================================================================
//LRJ - add X64 definition to configuration line
config = proj.Object.Configurations("Release|x64");
config.ConfigurationType = appType;
config.CharacterSet = charSetUnicode;
config.useOfMfc = useMfcStdWin;
CLTool = config.Tools("VCCLCompilerTool");
strDefines = GetPlatformDefine(config);
strDefines += "_CRT_SECURE_NO_WARNINGS;_SECURE_SCL=0";
if ( isDllApp )
{
strDefines += ";_USRDLL";
}
else
{
strDefines += ";_CONSOLE";
}
CLTool.PreprocessorDefinitions = strDefines;
config.UseOfMFC = useMfcDynamic;
CLTool.RuntimeLibrary = rtMultiThreadedDLL;
CLTool.InlineFunctionExpansion = expandOnlyInline;
CLTool.TreatWChar_tAsBuiltInType = true;
CLTool.DebugInformationFormat = debugEnabled;
CLTool.AdditionalIncludeDirectories += ";D:\\dsplm\\Siemens\\NX12\\ugopen";
CLTool.RuntimeTypeInfo = 1;
CLTool.UsePrecompiledHeader = pchNone;
//CLTool.AdditionalOptions = "/d1scalableinclude-";
LinkTool = config.Tools("VCLinkerTool");
//LRJ - add following line for X64 definition
LinkTool.TargetMachine = machineAMD64;
LinkTool.OutputFile = "$(OutDir)/" + strProjectName + appExtension;
if ( isDllApp )
LinkTool.ImportLibrary = "$(OutDir)/" + strProjectName + ".lib";
LinkTool.GenerateDebugInformation = true;
LinkTool.LinkIncremental = linkIncrementalNo;
LinkTool.AdditionalLibraryDirectories += ";D:\\dsplm\\Siemens\\NX12\\ugopen";
LinkTool.AdditionalDependencies = linkLibs;
LinkTool.SubSystem = subSystemConsole;
//LRJ - add following line for X64 definition
dte.ExecuteCommand("Build.SolutionPlatforms", "x64");
}
catch(e)
{
throw e;
}
}
结果如下:
页:
[1]