gpt4 book ai didi

c++ - 无法使用 Eigen 库进行编译

转载 作者:太空宇宙 更新时间:2023-11-04 09:42:59 28 4
gpt4 key购买 nike

我正在 Linux 上编写一个 C++ 应用程序。

对于特定任务,我需要包含 Eigen 库。

我安装了 libeigen3-dev 包,并以这种方式将其包含在我的代码中:

#include <Eigen/Dense>

然后我尝试使用以下命令编译此文件:

g++    -I/usr/include/eigen3 -c TetrisAgent.cpp -o TetrisAgent.o

我正在使用 gcc 4.7.2 版

不幸的是,由于这个错误,我无法编译它:

In file included from /usr/include/eigen3/Eigen/Core:329:0,
from /usr/include/eigen3/Eigen/Dense:1,
from TetrisAgent.cpp:24:
/usr/include/eigen3/Eigen/src/Core/GeneralProduct.h:121:14: error: expected ‘>’ before numeric constant
/usr/include/eigen3/Eigen/src/Core/GeneralProduct.h:121:56: error: ‘N’ was not declared in this scope
/usr/include/eigen3/Eigen/src/Core/GeneralProduct.h:121:59: error: template argument 2 is invalid
make: *** [TetrisAgent.o] Error 1

谁能帮我解决这个问题?

编辑:这是为了回答 Albert 的问题“在包含之前,您自己的代码 (TetrisAgent.cpp) 中很可能已经存在错误。您可以将所有代码添加到包含之前,即前 24 行吗?"

/* 
* Copyright (C) 2008, Brian Tanner

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <stdio.h> /* for printf */
#include <string.h> /* for strcmp */
#include <time.h> /*for time()*/
#include <rlglue/Agent_common.h> /* agent_ function prototypes and RL-Glue types */
#include <rlglue/utils/C/RLStruct_util.h> /* helpful functions for allocating structs and cleaning them up */
#include "tetris_utils.h"
#include <vector>
#include <Eigen/Dense>

编辑 2:这是 tetris_utils.h 文件的代码:

#define GRID_WIDTH 10
#define GRID_HEIGHT 20
#define BATCH_SIZE 100

//number of games before updating the weights
#define M 10

static int available_rotations[] = {1,3,3,0,1,1,3};

static int max_position[7][4] = {{10,7,0,0},
{9,8,9,8},
{9,8,9,8},
{9,0,0,0},
{8,9,0,0},
{8,9,0,0},
{8,9,8,9} };


struct state_dump{
int features[21];
float V;
float reward;
};

最佳答案

#define M 10

^ 在不考虑范围的情况下重新定义单个字母是个坏主意。

请尝试使用 static int const M = 10;

关于c++ - 无法使用 Eigen 库进行编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19446248/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com