2013-10-18 35 views
0

我正在編寫Linux上的C++應用程序。無法使用特徵庫編譯

對於特定的任務,我需要包含Eigen庫。

我安裝了libeigen3-dev包,包括我在我的代碼是這樣的:

#include <Eigen/Dense> 

我再嘗試編譯命令這個文件:

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

我使用gcc version 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 

誰能幫我修復它?

編輯: 這是回答問題偉業「你很可能已經有了錯誤在自己的代碼(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; 
}; 
+0

在包含之前,您可能已經在自己的代碼(TetrisAgent.cpp)中出現了錯誤。你可以添加所有的代碼,包括前24行嗎? – Albert

+0

您的tetris_utils.h中可能仍然存在一些錯誤。但是你有沒有試圖把Eigen/Dense包括在頂端?此外,另外,嘗試把你自己的包括在底部(這通常是一個很好的建議)。你有同樣的錯誤嗎? – Albert

+0

嘗試使用-E選項並查看違規行被預處理的內容。 –

回答

2
#define M 10 

^重新定義單個字母而不尊重範圍是個壞主意。

改爲嘗試static int const M = 10;