首页 > 解决方案 > C ++ ROOT:IncrementalExecutor::executeFunction:链接时符号'_ZStorSt13_Ios_OpenmodeS_'未解析[cling接口函数]

问题描述

我是 C++ 新手,在 Ubuntu 18.04 中使用 CERN ROOT 解释器 6.22/00(课程需要)。我正在尝试编写一个简单地从文件中读取数据列并将数据写入输出文件的代码。这是我的代码的最低可重现版本,我从数组而不是文件中读取:

# include <iostream>
# include <fstream>
//# include <math.h>
# include <iomanip>
//# include <cmath>
//# include <stdlib.h>
# include <cstdlib>
//# include <fstream.h>
//# include <string.h>
# include <string>
//# include <direct.h> 
//# include <dos.h> //For Sleep() 

using namespace std;
int main()
{
    char outputFileName[30] = "output.dat";
    int NumOfRows = 5;
    int nCount[5] = {0, 1, 2, 3, 4};
    int nCount2[5] = {1, 2, 3, 4, 5};
    
    cout<<"Creating output file"<<endl;
    ofstream outFile(outputFileName);
    outFile<<"1st Param"<<setw(15)<<"2nd Param"<<endl; //Header
        for (int a = 1; a < NumOfRows; a++){
            
            // Reading rest of file
            outFile << nCount[a] << nCount2[a];

                
        }
    outFile<<""<<endl;
    
            // Warning if file cant be opened
    if(!outFile.is_open()){ 
        cout << "Error opening file. \n";
        //cout << "Giving Retry... \n";
    }
    if(outFile.is_open()){
        cout<<"Output File was opened successfully"<<endl;
    }
    if(outFile.good()){
        cout<<"Output File is ready for reading"<<endl;
    }
    outFile.close();
    
    if(!outFile.is_open()){
        cout<<"Output File closed successfully"<<endl;
    }
    
    return 0;
}

但是,当我运行此代码时,出现错误:

IncrementalExecutor::executeFunction: symbol '_ZStorSt13_Ios_OpenmodeS_' unresolved while linking [cling interface function]!
You are probably missing the definition of std::operator|(std::_Ios_Openmode, std::_Ios_Openmode)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZSt4setwi' unresolved while linking [cling interface function]!
You are probably missing the definition of std::setw(int)
Maybe you need to load the corresponding shared library?

我尝试了错误建议并在库中查找std::setw(int),但我看到它是在 中定义的<iomanip>,我已经将其包含在代码中。我在这里想念什么?

标签: c++root-framework

解决方案


推荐阅读