gem5 scons构建失败,并显示“ TypeError:参数应为整数或类似字节的对象,而不是'str'”

时间:2020-05-18 21:54:41

标签: scons gem5

我正在尝试在Ubuntu 20.04的全新安装上安装gem5,并使用commit 9fc9c67b4242c03f165951775be5cd0812f2a705。我用过了 http://learning.gem5.org/book/part1/building.htmlhttps://www.gem5.org/documentation/general_docs/building 作为我的指导。据我所知,我已经使用安装了所有必需的依赖项(在这两行中重复了一些依赖项)

#include <database.h>
using namespace std;

int main() {

    SQLRETURN ret = 0; /* ODBC API return status */

    SQLHENV env;
    SQLHDBC dbc;
    SQLHSTMT stmt;

    SQLSMALLINT msg_len = 0;
    SQLCHAR sql_state[6], message[256];
    SQLINTEGER native_error = 0;

    try{
        ret = SQLAllocEnv(&env);
        ret = SQLAllocConnect(env, &dbc);
        ret = SQLConnect(dbc, (SQLCHAR*)"KarTarDB", strlen("KarTarDB"), (SQLCHAR*)"sa",2,(SQLCHAR*)"KarTarPwd",9);

        if(ret == SQL_INVALID_HANDLE || ret < 0) {
            cout << "Connection open failure." << endl;
            ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sql_state, &native_error, message, sizeof(message), &msg_len);
            cout << ret << endl;
        } else{
            char sql[100]="INSERT INTO emp(name, age, dob) VALUES ('john', 23, '010101')";

            ret = SQLPrepare(stmt,(unsigned char*)sql, SQL_NTS);//strlen(sql));
            ret = SQLExecute(stmt);//,(SQLCHAR*)sql,strlen(sql));

            if(ret == SQL_ERROR || ret < 0) {
                cout << "ResultSet Error: " << ret << endl;
                //ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sql_state, &native_error, message, sizeof(message), &msg_len);
            }else{
                cout << "Done" << endl;
            }
        }
    }catch(...) {
        cout << "Database error.." << endl;
        }
    return 0;
}

然后,当我尝试使用构建gem5时

sudo apt install build-essential git m4 scons zlib1g zlib1g-dev libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev python-dev python

sudo apt install build-essential git m4 scons zlib1g zlib1g-dev \
    libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
    python-dev python libboost-all-dev

执行'scons'行后,得到以下输出:

git clone https://gem5.googlesource.com/public/gem5
cd gem5    
scons build/X86/gem5.opt -j8

我不确定如何解决此错误,甚至不确定为什么会发生此错误;我什至不知道这个错误在说什么。任何帮助,将不胜感激。

1 个答案:

答案 0 :(得分:3)

是的。这是运行以scons形式实现的构建系统的结果,该构建系统仅期望python2。

如果您遇到了这种情况,可以执行以下操作,直到gem项目推送其Python 3 + SCons更改为止。

sudo apt-get install virtualenv
# create a virtualenv which uses python 2.7
virtualenv -p python2.7 venv27
# activate the virtualenv
. venv27/bin/activate
# Install SCons in the python 2.7 virtualenv
pip install scons
# This will now use the scons installed in a python 2.7 virtualenv.
scons build/X86/gem5.opt -j8

这在Ubuntu 20.04系统上对我有用。