C++&引用;系统(命令)“;不在NetBeans/Windows上工作 我正在使用Windows上的CODBROCK进行C++项目,但随后决定切换到NETBeIDEIDE 8.2。
在我的项目中,我使用一些传递的参数调用另一个可执行文件(我使用合适的参数运行另一个.exe,然后将它的输出用于我的主项目),它用于代码块,但不用于NetBeans 代码如下:C++&引用;系统(命令)“;不在NetBeans/Windows上工作 我正在使用Windows上的CODBROCK进行C++项目,但随后决定切换到NETBeIDEIDE 8.2。,c++,netbeans,system,codeblocks,C++,Netbeans,System,Codeblocks,在我的项目中,我使用一些传递的参数调用另一个可执行文件(我使用合适的参数运行另一个.exe,然后将它的输出用于我的主项目),它用于代码块,但不用于NetBeans 代码如下: #include <iostream> #include <fstream> #include <stdlib.h> #include <cstdlib> #include <string.h> #include <sstream> #include
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cstdlib>
#include <string.h>
#include <sstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "My_Constants.h"
#include "Data.h"
#include "Parameters.h"
#include "Pattern.h"
#include "Squish.h"
#include "Deserializer.h"
#include "Automatic_Run.h"
using namespace std;
int main()
{
Parameters parameters;
parameters.mode = SQUISH;
Automatic_Run runner;
string inputname;
//--------------------------------User Input-------------------------------------
cout << "enter input file name \n";
getline(cin, inputname);
parameters.inputFileName.assign(inputname);
cout<<"=============================================================================\n";
//--------------------------------Running SQUISH/first call--------------------------
cout<<"Running SQUISH - first call\n";
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command,"C:\\Users\\Administrator\\Documents\\CodeBlocksProjects\\TestSQUISH\\bin\\Debug\\TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
// the rest of the code(not relevant to the problem)
return 0;
}
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command, "/cygdrive/c/Users/Administrator/Documents/CodeBlocksProjects/TestSQUISH/bin/Debug/TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括“My_Constants.h”
#包括“Data.h”
#包括“Parameters.h”
#包括“Pattern.h”
#包括“Squish.h”
#包括“反序列化程序.h”
#包括“Automatic_Run.h”
使用名称空间std;
int main()
{
参数;
parameters.mode=挤压;
自动跑步器;
字符串输入名;
//--------------------------------用户输入-------------------------------------
cout转到项目设置,并将项目执行路径设置为其他应用程序所在的文件夹
或
将系统路径设置为包含该文件夹。转到“项目设置”并将要执行的项目路径设置为其他应用程序所在的文件夹
或
将系统路径设置为包含该文件夹。多亏@Yksisarvinen的评论,我才能够解决这个问题
注意到NetBeans使用的是shell而不是Windows风格的命令,在使用NetBeans自己的终端真正清楚地了解它如何转换路径之后,我能够使用以下命令成功地运行代码:
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cstdlib>
#include <string.h>
#include <sstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "My_Constants.h"
#include "Data.h"
#include "Parameters.h"
#include "Pattern.h"
#include "Squish.h"
#include "Deserializer.h"
#include "Automatic_Run.h"
using namespace std;
int main()
{
Parameters parameters;
parameters.mode = SQUISH;
Automatic_Run runner;
string inputname;
//--------------------------------User Input-------------------------------------
cout << "enter input file name \n";
getline(cin, inputname);
parameters.inputFileName.assign(inputname);
cout<<"=============================================================================\n";
//--------------------------------Running SQUISH/first call--------------------------
cout<<"Running SQUISH - first call\n";
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command,"C:\\Users\\Administrator\\Documents\\CodeBlocksProjects\\TestSQUISH\\bin\\Debug\\TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
// the rest of the code(not relevant to the problem)
return 0;
}
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command, "/cygdrive/c/Users/Administrator/Documents/CodeBlocksProjects/TestSQUISH/bin/Debug/TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
Netbeans终端将cygdrive
添加到路径的开头,并使用c
而不是c:
如果可执行文件与您自己的项目位于同一目录中,那么这就足够了:
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command ,"./TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
感谢@Yksisarvinen的评论,我能够解决这个问题
注意到NetBeans使用的是shell而不是Windows风格的命令,在使用NetBeans自己的终端真正清楚地了解它如何转换路径之后,我能够使用以下命令成功地运行代码:
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cstdlib>
#include <string.h>
#include <sstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "My_Constants.h"
#include "Data.h"
#include "Parameters.h"
#include "Pattern.h"
#include "Squish.h"
#include "Deserializer.h"
#include "Automatic_Run.h"
using namespace std;
int main()
{
Parameters parameters;
parameters.mode = SQUISH;
Automatic_Run runner;
string inputname;
//--------------------------------User Input-------------------------------------
cout << "enter input file name \n";
getline(cin, inputname);
parameters.inputFileName.assign(inputname);
cout<<"=============================================================================\n";
//--------------------------------Running SQUISH/first call--------------------------
cout<<"Running SQUISH - first call\n";
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command,"C:\\Users\\Administrator\\Documents\\CodeBlocksProjects\\TestSQUISH\\bin\\Debug\\TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
// the rest of the code(not relevant to the problem)
return 0;
}
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command, "/cygdrive/c/Users/Administrator/Documents/CodeBlocksProjects/TestSQUISH/bin/Debug/TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
Netbeans终端将cygdrive
添加到路径的开头,并使用c
而不是c:
如果可执行文件与您自己的项目位于同一目录中,那么这就足够了:
char command[1000]="";
string passedParameters = " -i "+parameters.inputFileName +" -f "+ "t";
strcat(command ,"./TestSQUISH.exe ");
strcat(command,passedParameters.c_str());
int result = system(command);
这不是合法的C++。请提供你正在编译和执行的确切代码。我猜你需要4x而不是2X。谢谢,我尝试过,它解决了“/”。问题,但找不到该命令的主要问题仍然存在:sh:C:\Users\Administrator\Documents\CodeBlocksProjects\TestSQUISH\bin\Debug\TestSQUISH.exe:command not found@jvapend目录的完整路径是否存在?可执行文件是否存在?从错误消息来看,NetBeans似乎使用了sh
shell(不知何故)你确信它理解Windows风格的路径从<代码> C:< /C> >吗?这不是合法的C++。请提供你正在编译和执行的确切代码。我猜你需要4X而不是2X。谢谢,我试过了,它解决了“/”。问题,但找不到该命令的主要问题仍然存在:sh:C:\Users\Administrator\Documents\CodeBlocksProjects\TestSQUISH\bin\Debug\TestSQUISH.exe:command not found@jvapend目录的完整路径是否存在?可执行文件是否存在?从错误消息来看,NetBeans似乎使用了sh
shell(不知何故)。您确定它理解以C:
开头的Windows样式路径吗?