2016-08-16 2 views
-1

최근에 프로그램을 다운로드했습니다. 환자 특정 생존 예측 CLI, http://pssp.srv.ualberta.ca/.cpp 파일과 메이크 파일에서 프로그램을 컴파일하는 방법

Readme 파일에 포함 상태 :. 코드는 수정없이 리눅스에서 컴파일해야 "1 컴파일, 그냥 'make'를 입력하라 컴파일하려면 컴파일 후 2 실행 파일이 있어야합니다. mtlr 열차 및 mtlr 테스트. " 나는 보았다

[email protected]:/pssp_source$ ls 
common.cpp data_type_api.h DenseVector.h Main.cpp Makefile Sparm.cpp Sparm.o   SparseVector.h test_model.mltr Util.h 
common.h DenseVector.cpp example_data Main.o readme.pdf Sparm.h SparseVector.cpp Test.cpp  test_model.mlty 

: 같은 폴더의

[email protected]:/pssp_source$ make 
g++ -c -O3 DenseVector.cpp -o DenseVector.o 
In file included from DenseVector.cpp:1:0: 
DenseVector.h:9:2: error: ‘size_t’ does not name a type 
    size_t m_dim; 
^
DenseVector.h:18:21: error: expected ‘)’ before ‘n’ 
    DenseVector(size_t n); 
        ^
DenseVector.h:26:33: error: ‘size_t’ does not name a type 
    double const& operator[](const size_t i) const 
           ^
DenseVector.h:26:40: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive] 
    double const& operator[](const size_t i) const 
             ^
DenseVector.h:31:27: error: ‘size_t’ does not name a type 
    double& operator[](const size_t i) 
         ^
DenseVector.h:31:34: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive] 
    double& operator[](const size_t i) 
           ^
DenseVector.h:38:2: error: ‘size_t’ does not name a type 
    size_t dim() const 
^
DenseVector.h: In member function ‘void DenseVector::push_back(double)’: 
DenseVector.h:23:3: error: ‘m_dim’ was not declared in this scope 
    m_dim++; 
^
DenseVector.cpp: At global scope: 
DenseVector.cpp:6:1: error: prototype for ‘DenseVector::DenseVector(size_t)’ does not match any in class ‘DenseVector’ 
DenseVector::DenseVector(size_t n): m_dim(n) 
^ 
In file included from DenseVector.cpp:1:0: 
DenseVector.h:5:7: error: candidates are: DenseVector::DenseVector(const DenseVector&) 
class DenseVector 
    ^
DenseVector.h:12:2: error:     DenseVector::DenseVector() 
    DenseVector(void); 
^
DenseVector.cpp: In constructor ‘DenseVector::DenseVector()’: 
DenseVector.cpp:16:2: error: class ‘DenseVector’ does not have any field named ‘m_dim’ 
:m_dim(0) 
^
DenseVector.cpp: In member function ‘void DenseVector::clear()’: 
DenseVector.cpp:27:22: error: ‘m_dim’ was not declared in this scope 
    for (size_t i=0; i<m_dim; i++) 
        ^
In file included from /usr/include/c++/4.8/cassert:43:0, 
       from DenseVector.cpp:3: 
DenseVector.cpp: In function ‘double sprod_nn(const DenseVector&, const DenseVector&)’: 
DenseVector.cpp:37:11: error: ‘const class DenseVector’ has no member named ‘dim’ 
    assert(a.dim() == b.dim()); 
     ^
DenseVector.cpp:37:22: error: ‘const class DenseVector’ has no member named ‘dim’ 
    assert(a.dim() == b.dim()); 
        ^
DenseVector.cpp:38:15: error: ‘const class DenseVector’ has no member named ‘dim’ 
    size_t n = a.dim(); 
      ^
In file included from /usr/include/c++/4.8/cassert:43:0, 
       from DenseVector.cpp:3: 
DenseVector.cpp: In function ‘void multadd_nn(DenseVector&, const DenseVector&, double)’: 
DenseVector.cpp:49:11: error: ‘class DenseVector’ has no member named ‘dim’ 
    assert(w.dim()==a.dim()); 
     ^
DenseVector.cpp:49:20: error: ‘const class DenseVector’ has no member named ‘dim’ 
    assert(w.dim()==a.dim()); 
        ^
DenseVector.cpp:50:15: error: ‘class DenseVector’ has no member named ‘dim’ 
    size_t n = w.dim(); 
      ^
DenseVector.cpp: In function ‘void smult_n(DenseVector&, double)’: 
DenseVector.cpp:62:15: error: ‘class DenseVector’ has no member named ‘dim’ 
    size_t n = w.dim(); 
      ^
make: *** [DenseVector.o] Error 1 

내용은 볼 : 내가 얻을 디렉토리와 유형 메이크업에 갈 때

나는 나의 위치에 압축을 푼 폴더를 다운로드 C++ 코드를 컴파일하는 데 필요한 기본 패키지와이를 실행하는 방법에 대한 기본 지식을 제공합니다. 아무도이 문제를 해결하지 못했습니다. 형식이없는 size_t에 문제가있는 것처럼 보입니다.

DenseVector.cpp의 시작입니다 : 내가 전에 같은 코드를 컴파일 된 적이없는, 그래서 아마 뭔가를 분명 실종

#include "DenseVector.h" 

#include <cassert> 
#include <iostream> 

DenseVector::DenseVector(size_t n): m_dim(n) 
{ 
    m_dvector.reserve(n); 
    for (size_t i=0; i<n; i++) 
    { 
      m_dvector.push_back(0); 
    } 
} 

. 우분투 14.04가 필요하다면, g ++ 버전은 4.8.4입니다.

감사합니다.

+0

'size_t'는'std'의 멤버입니다. 'std :: size_t'가 필요합니다. – NathanOliver

+0

['size_t'] (http://en.cppreference.com/w/cpp/types/size_t)는 ''에서 나오고'std ::'네임 스페이스가 필요합니다 – CoryKramer

+1

[size_t는 g ++에서 찾을 수 없습니다 - 4.1 또는 다른 우분투 8.1] (http://stackoverflow.com/questions/1107940/size-t-can-not-be-found-by-g-4-1-or-others-on-ubuntu-8- 1) –

답변

0

README 거짓말처럼 들립니다. 아마 그것은 표준 라이브러리의 다른 버전으로 작업 한 것 같습니다.

시도 DenseVector.h의 상단에

#include <stddef.h> 

를 추가.

+0

완벽하게 작동했습니다. 감사합니다, – slips

+0

@slips [답변 수락 방법은 무엇입니까?] (http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) –

0

파일을 엽니 프로그램의 루트 디렉토리에 DenseVector.h 및 수정,

#pragma once 

#include <vector> 
#include <cstddef> // <--- Add this line to the file 

class DenseVector 
{ 
    protected: 
// ... 
그것을 저장

하고 다시 시도 삽입!

+0

그러면 'size_t'를 'std ::'- 그래서 그것은 발견되지 않을 것이다. –

0

C의 올바른 버전을 사용하고 있다고 생각하지 않습니다. C11이 필요하다고 생각합니다. -03 플래그를 사용하는 대신 -11 또는 -std=c11을 사용하십시오. 그런 다음 다시 컴파일하십시오.

관련 문제