21

So today I decided I would update to Visual Studio 2015 (previously running the RC version with no difficulties) but now my project does not like the /LARGEADDRESSAWARE command line event.

I have a post-build event of:

call "$(DevEnvDir)..\tools\vsvars32.bat"
editbin /largeaddressaware "$(TargetPath)"

However I get the following error:

The command "call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE..\tools\vsvars32.bat" editbin /largeaddressaware "C:\...\bin\Debug\Application.exe"" exited with code 9009

Any thoughts?

phuclv
  • 37,963
  • 15
  • 156
  • 475
Rolodium
  • 343
  • 1
  • 2
  • 12
  • Separate each command with `;` and try again. – Daniel A. White Jul 22 '15 at 14:09
  • Unfortunately that was the first thing I tried, it doesn't make much sense that this has had to change when it work in the 2015 RC version perfectly fine... And the two location directories are correctly, I manually checked both and both files exist where they are supposed to be :( – Rolodium Jul 22 '15 at 14:11
  • to me it looks like its running the whole post build event as one command – Daniel A. White Jul 22 '15 at 14:59
  • Works fine on my machine. Look in the Output window for a more specific error message. – Hans Passant Jul 22 '15 at 15:07
  • Tested this on Visual Studio 2013 and builds fine with the above post-build events but still doesn't work in 2015. I have changed the events to have separate calls to 2 different batch scripts and they are called in the correct sequence. The issue only occurs when I add the second line. – Rolodium Jul 22 '15 at 15:16
  • 1
    Output windows gives the following error "'editbin' is not recognized as an internal or external command, operable program or batch file." – Rolodium Jul 22 '15 at 15:17
  • 5
    It is located in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\editbin.exe Use Explorer to see if it is there. That directory has 45 files, if it is substantially empty then the VS2015 install did not go well. Usually caused by not properly uninstalling a CTP or RC version. – Hans Passant Jul 22 '15 at 16:14
  • That is exactly what has happened... editbin.exe is in the VC directory and not the bin directory... Thanks – Rolodium Jul 23 '15 at 07:27

4 Answers4

50

I call a cmd script as a PostBuildEvent:

IF  EXIST  "%VS140COMNTOOLS%"  CALL  "%VS140COMNTOOLS%vsvars32.bat"
IF  EXIST  "%VS120COMNTOOLS%"  CALL  "%VS120COMNTOOLS%vsvars32.bat"
IF  EXIST  "%VS110COMNTOOLS%"  CALL  "%VS110COMNTOOLS%vsvars32.bat"
IF  EXIST  "%VS100COMNTOOLS%"  CALL  "%VS100COMNTOOLS%vsvars32.bat"

editbin.exe /LARGEADDRESSAWARE MyApp.exe

It checks for the environment variable according to the installed VS (first 2015, next 2013, next 2012 and finally 2010) and now all paths are fine.

If it still can't find the .exe, make sure the C++ Tools option in the installer is selected. By default VS2015 only installs C# and VB.net, but not C++ with its tools. Here you have to activate it under custom in the setup:

enter image description here

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
magicandre1981
  • 27,895
  • 5
  • 86
  • 127
  • 6
    Thanks a ton, that was exactly the issue I had ! Had not installed the C++ Tools ... – SvenG Sep 09 '15 at 11:51
  • This is what worked for me, however I also noticed an existing postbuild command I had from a migrated VS2013 project had special quote characters which had apparently worked before. Changing these to neutral quotes worked. – Parrish Husband Sep 13 '16 at 14:27
  • If I'd already have c++ and f# installed, how could I uninstall them? Is that even possible? – eddy Sep 18 '16 at 17:50
  • @eddy in this dialog, uncheck the entries ;) – magicandre1981 Sep 18 '16 at 17:53
  • 2
    This is a correct solution. You actually only need to install the "Common Tools...", saves a few GB of install. – Hersker Jan 03 '17 at 08:51
8

If you set your platform to "Any CPU" this flag is set for you by default now in Visual Studio 2015.

See Compiling C# with Any CPU sets Application can handle large (>2GB) addresses.

Community
  • 1
  • 1
Chris Weber
  • 5,555
  • 8
  • 44
  • 52
3

The issue was caused when uninstalling the Visual Studio 2015 RC version. It does not remove all the directories and therefore the install of the full release version is not successful. The simple solution is to uninstall the RC version and restart. Then manually delete the C:\Program Files (x86)\Microsoft Visual Studio 14.0 directory. Then you can install the the new version without any issues.

Credit Hans Passant for identifying this issue.

Rolodium
  • 343
  • 1
  • 2
  • 12
2

My problem with this, that I was calling vcvarsall.bat from the wrong location first. I'd upgraded to Visual Studio 2017, and vcvarsall.bat had moved. (So had EditBin.exe. There are 4 locations for it now, though I changed to using whatever was in the path.) Fixing that, fixed the problem. Here's my post-build file for your purview.

:: Install C++ tools to have these installed

:: build for 32 bit     
:: VS 2012 call "$(DevEnvDir)..\..\vc\vcvarsall.bat" x86 

:: build for 64
:: VS 2012 call "$(DevEnvDir)..\..\vc\vcvarsall.bat" amd64
:: VS 2017
call "$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvarsall.bat" amd64

:: "$(DevEnvDir)..\..\vc\bin\EditBin.exe" "$(TargetPath)"  /LARGEADDRESSAWARE
EditBin "$(TargetPath)"  /LARGEADDRESSAWARE
Chuck Savage
  • 11,775
  • 6
  • 49
  • 69