Using Visual Studio 2010 IDE

This has been replaced by the following:

Setting up the build is somewhat straight forward on windows however I could not find any instructions on setting up a Visual Studio project for editing and debugging. I’m writing down the instructions I was given on IRC for my future benefits and for others. I hope at some point someone will take the initiative to put this information on MDN.

These instructions start from the point where you have a simple build of Firefox completed with the latest windows SDK and VS 10.

  • Create a new project using ‘Project from Existing Code’ (See Joe Walker’s comment if you don’t have this).
  • Select ‘Visual C++’, enter a project name (ex: mozilla-central), source directory as project file location, select ‘Show all files in Solution Explorer’.
  • Make sure you un-select ‘Add Files to the project from these folders’, hit Next.
  • Select ‘Use external build system’, hit Finish.
  • Project will be empty until you select ‘Show all Files’ from top middle icon in the solution explorer when the project is selected, File -> close the solution, re-open it. Source files should appear (I had to do this step 3 times)
  • For autocomplete select Project ->Properties -> NMake.
  • Under ‘Preprocessor Definitions’ add XP_WIN (return here later to add any definition your may be compiling with/find missing)
  • Under ‘Include Search Path’ type in ‘<objdir>\dist\include’ (I recommend to have built your project from command line for this step)
  • For debugging select ‘Debugging’ still under the property page, type in the absolute path to firefox.exe. Recommended command argument ‘-P “Minefield” -no-remote’.

I strongly recommend using ‘Console’ when working from the command line.

Optional: Add a build/clean target (Can otherwise be done outside of Visual Studio using the command line)

  • Create a single script,, that you can invoke that will trigger a build with the configuration you need. It should set all environment variables needed.
  • Copy the ‘mozilla-build/start-msvc10.bat’ to ‘mozilla-build/start-msvc10-build.bat’.
  • Replace the last line to read something like ‘”%MOZILLABUILD%”\msys\bin\bash –login <path-to-your-build-script>/’.
  • Select Project->Properties->NMake, for Build Command Line type ‘C:\mozilla-build\start-msvc10-build.bat’.
  • Advanced: Create multiple project configuration for each mozconfig build configuration you would like to work with then have them invoke specific build scripts and firefox.exe.

You can modify your script to do incremental builds to reduce your turn around time.


17 thoughts on “Using Visual Studio 2010 IDE

  1. Pingback: Benoit Girard: Using Visual Studio 2010 IDE | Firefox Latest News

  2. I followed exact steps and was able to create solution file but autocomplete and intellisense does not work at all which is the primary motive of me to create solution file. Does it work in you care (in that case, I might have missed some step)?

  3. Autocomplete should work, double check the following check:

    For autocomplete select Project ->Properties -> NMake.
    Under ‘Preprocessor Definitions’ add XP_WIN (return here later to add any definition your may be compiling with/find missing)
    Under ‘Include Search Path’ type in ‘\dist\include’ (I recommend to have built your project from command line for this step)

    and also make sure that you have already built and that the include show up in ‘/dist/include’

  4. Pingback: Tales of building Firefox « Musings of Raymond Hung

  5. Followed your instructions but yet to get Intellisense working with the code in VS 2010 ultimate. I have successfully built both nightly and aurora from teh command line and have the dist/include directory populated yet autocomplete doesn’t work. Debugging does work fine though. Were you able to resolve Atul’s problem?

  6. These steps worked for me. The key is letting VS know about the headers, which #define the builder system will define and it should know how to parse them. If the steps above don’t work you can try to ask on IRC #developers (best results during work hours).

    If you do find a problem please let me know so I can update the instructions.

  7. If you don’t have a ‘Project from Existing Code’ menu item, see here:

    “The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help depending on your active settings or edition. This Help page was written with the General Development settings in mind. To view or change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings. “

  8. Pingback: Hacking and debugging Firefox. « Scott Downe's Blog

  9. After the project has been built from the command line and compiled successfully the project was created also successfully with the manual provided above. The test was made with Visual studio 2010 and 2012 and a Thunderbird Project. However the auto complete did not work and the intelligence is also not working.
    In Thunderbird there is also a include folder located under:
    And this folder was set in the include directives however the intelicese still does not work.
    What is working is the debugger. Breakpoints are set and the debugger is stopping in the C++ code. Does anybody knows how to resolve this problem?
    Any help is appreciated.



    • Colin, from my experience you dont get full Intellisense suppport. What i do to get that is to “include the file in the project” (by right clicking on the specific file you want in the Solution Explorer). When done with editing the file of interest, then “exclude file from the project”.

      • thanks but it kept freezing when including a .h, checked with procmon and saw devenv.exe wasn’t doing anything. Someone said to try Visual Assist X and seems to work well, it has a Goto Implementation (Alt-G) which is what i was looking for. thanks for raising my hopes, ended up with something useful 🙂

  10. In VS2010: working Autocompte, go to definition (after following the guide):

    – To get autocomplete to work while editing file X: Add file X to the project (in Solution explorer: right click the file -> Add to project).

    – To get “Go to definition” working: Add the file where the definition is to the project (otherwise it’ll take you to the declaration at the h file within the include search path – sometimes that’s enough). It doesn’t always know to choose the right prototype, so if a function is overloaded, it’ll display a list of implementations at the bottom pane.

    – Warning: importing the entire source tree/folders (sans the obj dir) might take very long time or crash VS. I think it’s best to add just the files you’re interested at.

  11. after do all instruction when press debug (f5) get this exception :Unhandled exception at 0x063A5EBF (xul.dll) in firefox.exe: 0xC0000005: Access violation writing location 0x00000000.. what shoud i do ?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s