我试图在makefile中包含额外库的路径,但我无法弄清楚如何让编译器使用该路径.到目前为止我有:
g++ -g -Wall testing.cpp fileparameters.cpp main.cpp -o test
Run Code Online (Sandbox Code Playgroud)
我想要包括路径
/data[...]/lib
Run Code Online (Sandbox Code Playgroud)
因为testing.cpp包含来自该库的文件.另外,我在linux机器上.
编辑:不是图书馆的路径.只是包含的文件.我的错.
这可能有一个非常明显的答案,但我似乎无法找到它.我想使用的Xcode 4的C++编程,我想创建一个项目,建立并通过的Xcode 4运行它就像我对其他语言做.我的问题是我找不到合适的项目类型.
当我去编译这段代码时,它说它期望在我的构造函数中的 ) 之前有一个不合格的 id
分析2.h:
#ifndef _ANALYSIS2_H
#define _ANALYSIS2_H
class Analysis2{
public:
Analysis2();
...
Run Code Online (Sandbox Code Playgroud)
分析2.cpp:
#include "analysis2.h"
using namespace std;
Analysis2()
{
Seconds_v = 0;
Seconds_t = 0;
}
...
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
我正在尝试编译此代码,并且g ++一直告诉我"TimeFinder"尚未声明
头文件
#ifndef _TIMEFINDER_H
#define _TIMEFINDER_H
#include <vector>
#include "timefinder.cpp"
using namespace std;
class TimeFinder
{
public:
static vector<int> time_from_name(string filename);
static int calc_seconds (vector <int> time);
};
#endif
Run Code Online (Sandbox Code Playgroud)
CPP文件
#include "timefinder.h"
using namespace std;
vector<int> TimeFinder::time_from_name(string filename)//Line 14
{
//Method Body
}
int TimeFinder::calc_seconds (vector <int> time1)//Line 37
{
//Method Body
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样?我在网上查看了其他示例,我的代码似乎与其他人的代码相匹配......
编辑:确切的错误消息是
timefinder.cpp:14:错误:'TimeFinder'尚未声明
timefinder.cpp:37:错误:'TimeFinder'尚未声明
编辑2:对不起,我对此并不擅长,但我要感谢大家的建议.希望我的代码质量会因为它们而开始提高.
这是我在实现它们之前用来测试方法的主文件.我试图获取目录中所有文件的列表,将它们写入txt文件(它在这里工作正常),然后从该文本文件中读取文件名.
using namespace std;
string sysCall = "", location = "~/Documents/filenames.txt";
string temp = "";
sysCall = "ls / > "+location;
system(sysCall.c_str());
ifstream allfiles(location.c_str());
allfiles.good();
getline(allfiles, temp);
cout<<temp<<endl; //At this point, the value of temp is equal to ""
return -1;
Run Code Online (Sandbox Code Playgroud)
程序运行后,没有输出任何文本.从我在其他人的问题中读到的,这应该有效(但显然不是).我在这做错了什么?
编辑:allfiles.good()返回false,但我不明白为什么它会返回...
我正在使用CERN的ROOT框架(必需),我想从TNtuple中获取数据并绘制图形.我可以在创建TNtuple时或在将其写入.root文件之后绘制数据图形.一些支持文档建议我创建一个TTree,但这似乎可能是过度/迂回,因为我不会将它用于其他任何事情(并且TNtuple满足我的所有其他要求).有没有人有更好的建议如何从TNtuple中提取数据并绘制图表?