は私がTMBチュートリアルのこのコンパイルエラーは何ですか?
#include <TMB.hpp> // Links in the TMB libraries
template<class Type>
Type objective_function<Type>::operator()()
{
DATA_VECTOR(x); // Data vector transmitted from R
PARAMETER(mu); // Parameter value transmitted from R
PARAMETER(sigma); //
Type f; // Declare the "objective function" (neg. log. likelihood)
f = -sum(dnorm(x,mu,sigma,true)); // Use R-style call to normal density
return f;
}
TMB tutorial pageからC++のコードをコピーしてtutorial.cpp
としてそれを救いました。私はその後、指示に従ってそれをコンパイルしようとしました:
> compile("tutorial.cpp")
Error in compile("tutorial.cpp") : Compilation failed
In addition: Warning messages:
1: In readLines(file) : incomplete final line found on 'tutorial.cpp'
2: running command 'make -f ".../R/R-33~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.2/share/make/winshlib.mk" -f "...\AppData\Local\Temp\RtmpqgV7xA\file2d987ade32f3" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="tutorial.dll" WIN=64 TCLBIN=64 OBJECTS="tutorial.o"' had status 127
また、RStudioエディタウィンドウに、私はエラーの上にホバーして、ラインType objective_function<...
の隣に十字を見ることができます:
Variable templates are a C++1y extension
expected ';' at end of declaration
expected unqualified-id
チュートリアル関数をコンパイルするように修正するにはどうすればよいですか?
セッション情報:私は今、私の問題を解決した
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] TMB_1.7.8
loaded via a namespace (and not attached):
[1] Matrix_1.2-8 tools_3.3.2 grid_3.3.2 lattice_0.20-34
AMBではなくTMBを意味しますか? 'sessionInfo()'の結果が役に立ちます。 x86_64-apple-darwin13.4.0(64-bit)で動作します。 'devtools :: dr_devtools()'も試してみてください。 –
私はTMBに感謝しました。私はTMB faqで解決策を見つけたかもしれませんが、もし私がここに投稿するなら、RToolsインストールの私の欠点と関係していると思います。 (100 MBのインストールをダウンロードするのに時間がかかります) – Alex
'c:/ Rtools/mingw_64/bin/g ++:not found 'というエラーが表示されます。しかし、Rtoolsは 'c:/ RBuildTools'に、'> system( 'g ++ -v')には が組み込まれています。 COLLECT_GCC = C:\ RBUILD〜1 \ 3.4 \ mingw_32 \ bin \ G__〜1.EXE'が動作します。 – Alex