Using Visual Studio 2010 IDE

This has been replaced by the following:

https://firefox-source-docs.mozilla.org/build/buildsystem/visualstudio.html

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, build.sh, 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>/build.sh’.
  • 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.

21 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:
    http://msdn.microsoft.com/en-us/library/754c3hy7%28v=VS.90%29.aspx

    Particularly:
    “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:
    thunderbird\obj-i686-pc-mingw32\mozilla\dist\
    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.

    Regards,

    Konstantin

    • 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 ?

  12. hOur company provides a wide variety of non prescription products. Look at our health contributing portal in case you want to look healthier. Our company provides a wide variety of non prescription products. Visit our health portal in case you want to look better with a help health products. Our company provides safe weight loss products. Look at our health contributing website in case you want to look healthier. Our company offers a wide variety of non prescription drugs. Visit our health site in case you want to to feel healthier with a help generic supplements. Our site offers a wide variety of non prescription products. Look at our health site in case you want to strengthen your health with a help of health products. Our company offers herb-based weight loss products. Visit our health contributing website in case you want to feel better.
    Our company offers a wide variety of non prescription products. Take a look at our health site in case you want to to improve your health with a help of health products. Our company provides a wide variety of non prescription products. Take a look at our health website in case you want to look healthier with a help health products. Our company provides supreme quality non prescription products. Visit our health contributing portal in case you want to strengthen your health. Our company provides herbal health products. Visit our health contributing site in case you want to look healthier. Our company provides supreme quality healthcare products. Look at our health contributing site in case you want to feel better.

  13. PTHC FORUM

    Pound CP Shortclip 2018 Pint-sized Garnering

    http://vvv.unoforum.pro/?0-0

    Of old-time files 2000-2017CONK Classy Whip-round Non-restricted 1201-1500 Files On the treacherous showing !!! SHAH !!!!!

    Siberian Mouse Mountain

    Purchase a hankering as a replacement in the direction of Modelkids Dvd 1 – 44 Concealed showing

    Crave in behalf of Anal Series 1 – 25 Ditch !!!

    As a replacement repayment for the duration of Pic Dvd 1 – 50 Vernissage !!! UNRESTRAINED !!!!!

  14. hOur company provides a wide variety of non prescription drugs. Take a look at our health site in case you want to strengthen your health with a help generic supplements. Our company provides general health products. Take a look at our health contributing website in case you want to look better. Our company offers generic pharmacy. Take a look at our health contributing portal in case you want to feel better. Our company offers a wide variety of non prescription drugs. Look at our health portal in case you want to to feel healthier with a help of health products. Our company provides a wide variety of non prescription drugs. Visit our health portal in case you want to feel better with a help generic supplements. Our company provides a wide variety of non prescription drugs. Look at our health portal in case you want to to improve your health with a help generic supplements.
    Our company offers a wide variety of non prescription products. Take a look at our health website in case you want to feel better with a help health products. Our company offers a wide variety of non prescription drugs. Look at our health portal in case you want to feel better with a help of generic supplements. Our company provides supreme quality healthcare products. Take a look at our health contributing website in case you want to strengthen your health. Our company provides general health products. Visit our health contributing portal in case you want to strengthen your health. Our company offers a wide variety of non prescription drugs. Take a look at our health website in case you want to to improve your health with a help of general health products.

Leave a reply to benoitgirard Cancel reply