내가 정의한 클래스에서 MTRand (http://www.bedaux.net/mtrand/의 Mersenne Twister 난수 생성기)를 사용하고 있습니다. 컴파일을 시도 할 때 예기치 않은 오류가 발생하여 디코딩 할 수 없습니다. 여기 MTRand가 컴파일시 오류가 발생합니다.
내 코드의 관련 부분이다 ... 나는 ++ 프로그래머 C 초보자, 그래서 어떤 도움이 먼 길을 갈 것입니다 :#include<iostream>
#include<vector>
#include<deque>
#include<cmath>
#include "./mtrand/mtrand.h"
using namespace std;
class mp{
long double store;
deque< vector<long double> > stack;
long double boundary;
long double dt;
long double time;
MTRand_open random;
long int random_seed;
public:
void initialize(long int, long double, long double);
long double get_state(); // return the state at position int
void update();
friend long double A(mp*);
friend long double D(mp*);
long double normal();
vector <long double> viewCurrent();
};
함수가 다음있다가 호출하는 경우, 난수 생성기의 씨앗을 설정
void mp::initialize(long int rand_seed_input, long double bdry_in, long double dt_in){
time = 0;
dt = dt_in;
random_seed = rand_seed_input;
random.seed(random_seed);
boundary = bdry_in;
}
난 그냥이 컴파일하면 테스트 할, 그래서 정확하게 아무것도하지 않습니다 주요 기능을 만들 :
int main(){
return 0;
}
0 컴파일시에
, 나는이 오류가 무엇을 의미하는지 오류
Undefined symbols:
"MTRand_int32::seed(unsigned long)", referenced from:
mp::initialize(int, long, long double, long double)in ccJylsHh.o
"MTRand_int32::p", referenced from:
MTRand_int32::rand_int32() in ccJylsHh.o
MTRand_int32::rand_int32() in ccJylsHh.o
MTRand_int32::rand_int32() in ccJylsHh.o
"MTRand_int32::state", referenced from:
MTRand_int32::rand_int32() in ccJylsHh.o
"MTRand_int32::gen_state()", referenced from:
MTRand_int32::rand_int32() in ccJylsHh.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
나는 확실하지 않다 얻을, 그것은 어떻게 제거해야합니다.
내가 이해하는 바로는 MTR은 시드를 초기화하는 방법을 알 수 없다는 것입니다. 그러나 클래스 MTR에 기본 시드가 있으므로 문제가 무엇인지 알 수 없습니다.
라이브러리를 연결 했습니까? – Mysticial
라이브러리를 연결하는 것이 무엇을 의미하는지 잘 모르겠습니다. 컴파일시'g ++ nameOfFile.cpp' 만 입력하면 게시 된 오류가 발생합니다. mtrand의 상대 경로 이름을'/ Users/path/to/mtrand/mtrand.h'의 절대 경로로 바꾸고'g ++ nameOfFile.cpp'를 사용하여 다시 컴파일하려고 시도했지만 여전히 동일한 오류가 발생합니다 . mtrand와 함께 제공되는 테스트 코드를 컴파일하고 똑같은 오류가 발생하지만 내 디렉토리의 폴더에서 .o 파일을 찾을 수 없습니다. 나는 몹시 혼란스러워! –