以 amd64 模式编译(Visual Studio 2010)
伙计们,我想编译一个本机 64 位应用程序。我确实以正确的方式配置了 VS 并且它可以工作,但显然它是交叉编译而不是在本机 amd64 模式下编译,因为如果我尝试分配超过 1 000 000 000 的向量,我的程序仍然会冻结。
现在,我的问题是我在哪里确实必须添加额外的“amd64”(如此处所述http://msdn.microsoft.com/en-us/library /x4d2c09s%28VS.80%29.aspx)。 我在属性页>下尝试过调试>命令参数但这没有帮助。
哦,不要对我太严厉,我对这个话题还很陌生。
提前致谢。
(Windows 7 Professional 上的 Visual Studio 2010 终极版。)
编辑:对于 Bo,
我不知道,因为我在发布模式下运行它,但我确实收到“...exe 已停止工作”消息。另外,我添加了具有推回功能的元素,它适用于 1 000 000 000 个元素,但不适用于 1 100 000 000 个元素。
EDIT2:
感谢您的提示。我实际上使用的是 2010 版本的页面,我只是发布了错误的链接。 我也确实按照这些网站上的说明进行操作,正如我所写,它可以正常工作,直到我使用超过 4 GB 的 RAM。 我尝试运行一个使用超过 2 GB 内存的 32 位应用程序,当然没有成功。 然后我按照页面上的说明进行操作->我能够以 4 GB 的使用量运行该应用程序。 现在,我想分配超过 4GB ->它不起作用。 为什么我认为它必须与编译有关,因为你可以设置一个特定的标志,使 32 位应用程序能够使用 4GB,我认为这就是交叉编译选项的作用。 ->使其“以某种方式”兼容 32 和 64 位。
EDIT3:我确实在 win7 64x 上安装了 8GB
EDIT4:抱歉,没有评论单个帖子,但如果我点击“评论”,什么也不会发生。 但我刚刚发现了一些东西。编译器的问题可能不是问题,因为我可以成功分配 2 个 vec,其中一个大小为 500 000 000,另一个大小为 700 000 000。 有人知道为什么我不能分配大于 4GB 的向量吗?
guys I want to compile a native 64 bit application. I did configure VS the right way and it works but obvisouly it is cross compiling and not compiling in native amd64 mode as my program still freezes if I try to allocate a vector with more than 1 000 000 000.
Now, my question is where I do have to put that extra "amd64" (as described here http://msdn.microsoft.com/en-us/library/x4d2c09s%28VS.80%29.aspx).
I tried it under property pages > debugging > command arguments but that didn't help.
Oh, and dont be to harsh to me, I am kinda new to this topic.
Thanks in advance.
(Visual studio 2010 ultimate edition on windows 7 professional.)
EDIT: to Bo
I don't know as I am running it in release mode and I do actually get "...exe has stopped working" message. In addition I am adding elements with push back and it works for 1 000 000 000 elements but not for 1 100 000 000.
EDIT2:
Thanks for the hints. I am actually using the 2010 versions of the pages, I just posted the wrong link.
I did also follow the instructions on these sites and as I wrote, it works till I use more than 4 GB of RAM.
I tried to run a 32 Bit app which uses more than 2 GB ram, didnt work of course.
Then I did the instructions on the page -> I was able to run that app with a usage of 4 GB.
Now, I wanted to allocate more than 4gb -> It didnt work.
Why I think it has to do something with the compiling thing is that you can set a certain flag which makes 32bit apps able to use 4gb, I thought that that is what the cross compiling option does. -> making it "somehow" compatible to 32 and 64 bit.
EDIT3: I do have 8gb installed on win7 64x
EDIT4: Sorry, for not commenting the single posts but if I click on "comment" nothing happens.
But I just dicoverd something. the thing with the compiler is probably not the problem, as I can successfully allocated 2 vecs with one being of the size 500 000 000 and the other of 700 000 000.
Has somebody else a clue why I can't allocated a vector bigger than 4gb?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它可能没有冻结,而是填满了您的交换文件。
如果在调试模式下运行,运行时将用特殊值填充数组(标记未初始化的变量)。这可能需要一段时间!
我在发布模式下运行该程序没有任何问题
运行几秒钟(交换文件活动较多)并打印预期大小。
It is probably not freezing but filling up your swap file.
If you run in debug mode, the runtime will fill the array with a special value (marking uninitialized variables). This might take a while!
I have no problems running this program in release mode
Runs in a couple of seconds (with heavy swap file activity) and prints the expected size.
现在,我的问题是我必须在哪里放置额外的“amd64”
首先,您链接到了 VS 2005 的说明,而不是 2010。虽然在这种情况下可能并不重要,但有VS 2005 和 2010 之间有很多差异,因此请小心并使用正确的文档。这是正确的链接。
“amd64”是传递给 vcvarsall.bat 的参数,用于初始化在命令行会话中构建 x64 应用程序的环境。它不会传递到您的应用程序,也不是 IDE 中的项目设置。 链接解释了这一点。 Lirik 在评论中发布的链接解释了如何在 IDE 中正确配置项目,但这又是 VS 2005 的链接。您想要使用此 link
现在,至于你的错误,无论你是否使用交叉编译器或本机几乎肯定与此无关。这是一个完全独立的问题。
Now, my question is where I do have to put that extra "amd64"
First off, you linked to the instructions for VS 2005, not 2010. Although it probably doesn't matter in this case, there are a lot of differences between VS 2005 and 2010, so be careful and use the right documentation. This is the correct link.
"amd64" is an argument you pass to vcvarsall.bat to initialize the environment for building x64 apps in a command line session. It's not passed to your app, nor is it a project setting in the IDE. The paragraph and table under "Vcvarsall.bat" in the link explains this. The link Lirik posted in the comments explains how to configure your project correctly in the IDE, but again that's a link to VS 2005. You want to use this link
Now, as for your bug, whether you're using the cross-compiler or native almost certainly has nothing to do with it. That's a whole separate question.
您可以使用以下命令检查您的应用程序是 32 位还是 64 位:
$ dumpbin /headers myprogram.exe
它应该在开始处告诉您目标体系结构。
You can check is your application is 32 or 64 bits with the following command:
$ dumpbin /headers myprogram.exe
It should tell you the target architecture near the beginning.