开发者

compiling in amd64 mode (visual studio 2010)

开发者 https://www.devze.com 2023-03-27 13:49 出处:网络
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

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. The开发者_运维问答n 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?


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

#include <vector>
#include <iostream>

int main()
{
    std::vector<int>   v(2000000000);

    std::cout << v.size();

    return 0;
}

Runs in a couple of seconds (with heavy swap file activity) and prints the expected size.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号