2017-03-17 90 views
0

我在我的電腦上運行MinGW GCC 5.1.0的代碼。問題與std :: stoi,沒有在MinGW GCC 5.1.0上聲明

當我輸入:

g++ hope.cpp -o hope -I D:\armadillo-7.600.2\include 

在CMD告訴我:

hope.cpp:183:26: error: 'stoi' was not declared in this scope 
Point_Num = stoi(temp[1]);//number of point 
        ^
hope.cpp:190:34: error: 'stof' was not declared in this scope 
Point(i, 0) = stof(temp[travel]); 

但是,當我進入:

g++ hope.cpp -o hope -I D:\armadillo-7.600.2\include -std=c++11 

在CMD告訴我:

C:\Users\von77\AppData\Local\Temp\ccXdhQzS.o:hope.cpp:(.text$_ZN4arma7op_norm21vec_norm_1_direct_stdIdEET_RKNS_3MatIS2_EE[_ZN4arma7op_norm21vec_norm_1_direct_stdIdEET_RKNS_3MatIS2_EE]+0x7b): undefined reference to `dasum_' 
C:\Users\von77\AppData\Local\Temp\ccXdhQzS.o:hope.cpp:(.text$_ZN4arma7op_norm21vec_norm_2_direct_stdIdEET_RKNS_3MatIS2_EE[_ZN4arma7op_norm21vec_norm_2_direct_stdIdEET_RKNS_3MatIS2_EE]+0x7f): undefined reference to `dnrm2_' 
C:\Users\von77\AppData\Local\Temp\ccXdhQzS.o:hope.cpp:(.text$_ZN4arma4blas3dotIdEET_yPKS2_S4_[_ZN4arma4blas3dotIdEET_yPKS2_S4_]+0x3f): undefined reference to `ddot_' 
C:\Users\von77\AppData\Local\Temp\ccXdhQzS.o:hope.cpp:(.text$_ZN4arma6lapack5gesddIdEEvPcPiS3_PT_S3_S5_S5_S3_S5_S3_S5_S3_S3_S3_[_ZN4arma6lapack5gesddIdEEvPcPiS3_PT_S3_S5_S5_S3_S5_S3_S5_S3_S3_S3_]+0x8c): undefined reference to `dgesdd_' 
collect2.exe: error: ld returned 1 exit status 

我用atoi代替stoi後: 我得到了與「g ++ hope.cpp -o hope -I D:\ armadillo-7.600.2 \ include -std = C++ 11」相同的結果。

回答

0

你需要包含字符串頭

#include <string> 

,你需要指定命名空間

std::stoi(temp[1]); 
+0

我已經這樣做了,但結果是一樣的 – Francis

+0

的_Undefined reference_錯誤是前由於缺少庫,您需要指定哪一個帶-l選項,我猜你需要-larmadillo或-llapack或-lblas – Alkano

+0

你有沒有使用過犰狳? – Francis