用icpc编译 - 使用库

时间:2016-08-15 07:37:59

标签: c++ icc

我正在尝试编译#include the library

的代码

在代码中我有以下几行:

int main()
{
    clock_t begin = clock();
    random_device rd;
    mt19937 gen(rd());
    uniform_real_distribution<> U(0,1);
    default_random_engine generator;
    rr1=U(gen); 
}

当我使用以下行编译时:

 icpc  -std=c++0x -std=c++11 -o main main.cpp -O3

我收到以下错误:

  

main.cpp(152):错误:标识符&#34; uniform_real_distribution&#34;未定义           uniform_real_distribution&LT;&GT; U(0,1);           ^

     

main.cpp(152):错误:预期表达式           uniform_real_distribution&LT;&GT; U(0,1);                                     ^

     

main.cpp(368):错误:标识符&#34; default_random_engine&#34;未定义           default_random_engine generator;           ^

     

main.cpp(441):错误:标识符&#34; U&#34;未定义                   RR1 = U(GEN); //时间间隔的第一个随机数

     

main.cpp(509):警告#1595:非POD(普通旧数据)类类型   通过省略号                           RR1 = U(GEN);

任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

此问题是由您的Intel编译器icpc版本不完全支持c ++ 11引起的,c ++ 11实际上是c ++ 0x。

这意味着:

  • 您需要更新英特尔的编译器以支持uniform_real_distribution
  • 或使用某些库,例如boostPCG
  • 或者仍然使用c ++ 11方式,但没有uniform_real_distribution。例如,直接使用mt19937mt19937_64或任何其他伪随机生成器。
  • 或使用非c ++ 11方式,即rand()或rand_r()用于非严重用途。

我想上面的部分回答了你的问题。

想知道更多?

对于英特尔用户,您可以先检查编译器的兼容性,并将icc的版本号翻译成相对相同的gcc版本号,然后从{{查看} 3}}

对于GNU的用户,您可以直接从c++0x/c++11 supported list检查编译器的兼容性

例如,你可以 $icpc -v 你可能会得到类似的东西 icpc version a.b.c (gcc version x.y.z compatibility) 这意味着你的Inter编译器的版本是a.b.c,它的兼容性是gcc版本x.y.z。

并且uniform_real_distribution支持{ //----| Build UI var stImporterWin = new Window("palette", "ST Import Panel", undefined, {resizeable:true}); stImporterWin.orientation = "column"; var imageSequenceGroup = stImporterWin.add("group"); imageSequenceGroup.alignment = ["fill", "fill"]; imageSequenceGroup.orientation = "column"; var imageSequenceTree = imageSequenceGroup.add("treeview"); imageSequenceTree.preferredSize = [600,650]; imageSequenceTree.alignment = ["fill", "fill"]; stImporterWin.onResize = function () { this.layout.resize(); } stImporterWin.show(); filesArray = ["//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/test image2_0001.txt", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/test image3.0001.txt", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/test image_001.txt", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/0040-Major Trans M13_Logo_v02.xml", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/0040-Major Trans M13_01_logo_.AO.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/0040-Major Trans M13_01_logo_.MultiMatteElement.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/0040-Major Trans M13_01_logo_.RGB_color.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/0040-Major Trans M13_01_logo_.VRaySelfIllumination.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/0040-Major Trans M13_01_logo_.VRaySpecular.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/0040-Major Trans M13_01_logo_.VRayZDepth.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/0040-Major Trans M13_01_logo_.origRGB.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T1/Thumbs.db", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T2/0040-Major Trans M13_logo_02.0080.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T2/Thumbs.db", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T2/AO/0040-Major Trans M13_logo_02._AO0080.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T2/VRaySelfIllumination/0040-Major Trans M13_logo_02._VRaySelfIllumination0080.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T2/VRaySpecular/0040-Major Trans M13_logo_02._VRaySpecular0080.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Logo/T2/VRayZDepth/0040-Major Trans M13_logo_02._VRayZDepth0080.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/T1/Thumbs.db", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/0040-Major Trans M13_01_text_.AO.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/0040-Major Trans M13_01_text_.MultiMatteElement.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/0040-Major Trans M13_01_text_.RGB_color.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/0040-Major Trans M13_01_text_.VRaySelfIllumination.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/0040-Major Trans M13_01_text_.VRaySpecular.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/0040-Major Trans M13_01_text_.VRayZDepth.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/0040-Major Trans M13_01_text_.origRGB.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T1/Thumbs.db", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T2 ext/NY18_MajorTrans Ext_01_M13_text..AO.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T2 ext/NY18_MajorTrans Ext_01_M13_text..MatteText.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T2 ext/NY18_MajorTrans Ext_01_M13_text..RGB_color.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T2 ext/NY18_MajorTrans Ext_01_M13_text..VRaySelfIllumination.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T2 ext/NY18_MajorTrans Ext_01_M13_text..VRaySpecular.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T2 ext/NY18_MajorTrans Ext_01_M13_text..VRayZDepth.0000.png", "//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders/Text/T2 ext/NY18_MajorTrans Ext_01_M13_text..origRGB.0000.png"]; rootFolder = File("//VFXJobs/NY-18/02_Sequences/IntroVideo/0040-Major Trans M13/Renders"); var node0 = imageSequenceTree.add("node", rootFolder.fsName.replace(/\\/g, "/")); node0.expanded = true; //build out arrays from the files for (var i = 0; i < filesArray.length; i++) { filesArray[i] = filesArray[i].split("/"); } //recursive tree building var rootAsArray = rootFolder.fsName.replace(/\\/g, "/").split("/"); BuildChildNodes(rootAsArray, filesArray, node0, 0); // for debug purposes I added "killme" so that we only recurse once for now function BuildChildNodes (root, files, parentNode, killme) { alert("Root: " + root.join("/")); previousDirName = ""; for (var i = 0; i < files.length; i++) { var currentPath = files[i]; if (currentPath.length > root.length+1) { // we got a sub-folder so add it to the tree if unique and recurse var dirName = currentPath[root.length]; if (dirName != previousDirName) { var newNode = parentNode.add("node", dirName); newNode.expanded = true; previousDirName = dirName; // recurse var newRoot = currentPath.slice(0, root.length+1); var newFilesList = files.slice(i); //make sure we only get this dir for (var j = 0; j < newFilesList.length; j++) { if (newFilesList[j].slice(0, root.length+1).join("/") != newRoot.join("/")) { newFilesList = newFilesList.slice(0,j); break; } }; if (killme == 0) { alert("recursing " + newRoot.join("/")); BuildChildNodes(newRoot, newFilesList, newNode, 1); } } } else { // we got a file in this dir, add it to the tree var fileName = currentPath[root.length]; var newNode = parentNode.add("item", fileName); } } } } 支持c++0x/c++11 supported list? (GCC 4.4.7经过验证的支持)

然后,如果您的x.y.z晚于4.4.5?(肯定是4.4.7),您可以使用&#39; uniform_xxx_distribution&#39;函数系列没有兼容性问题。