Attach Visual Studio to the end

Source: Internet
Author: User

In Visual C ++ 2005, how does one call other compilers to compile CPP files? In other words, how can we integrate other compilers into the vc2005 ide? This article introduces a simple method.
In Visual C ++ 2005, how does one call other compilers to compile CPP files? In other words, how can we integrate other compilers into the vc2005 ide?

Compilers such as ICC will be automatically integrated after installation. To integrate other compilers, you have to do it yourself. The following describes a simple and superficial "integration" method.

You may have noticed that a single. cpp file cannot be compiled in the vc2005 ide unless it is placed in the project. However, we can call external tools to compile a single file.

The following describes how to compile a single. cpp file by calling g ++. To compile a single. c file, use GCC.

Maybe you do not know G ++ yet. G ++ is a member of GCC. The meaning of GCC is the GNU Compiler Collection, which includes C, C ++, objective-C, Fortran, Java, and Ada libraries that match these languages. GCC is hailed as "the most important software in the world ". Many free compilers are the compilers carried in the GCC-mingw (minimalist GNU for Windows.

Taking mingw as an example, we can download the latest version of Dev C ++ and Dev C ++: 4.9.9.2. Mingw is installed when Dev C ++ is installed, including g ++ 3.4.2.

Assume that Dev C ++ is installed in the D:/dev-CPP directory.

Click "Tools"> "external tools"> "add" in the menu of vc2005 )".

Enter:

Title: gnu c ++ Compiler

Command: D:/dev-CPP/bin/g1_cmd.exe

Parameter (arguments):-wall-o $ (itemfilename) $ (itemext)-time

Initial directory (initial directory): $ (itemdir)

Check the following "use output window )".

Note: If you have added the D:/dev-CPP/bin/directory to the system environment variable, you can define commandcommand as g‑cmd.exe. Cygwin is the same.

These parameters are just a reference. You can refer to the macro settings of the VC compiler to set the parameters you need.

Simply add reference parameter settings for the digital Mars C ++ Compiler:

Title: Digital Mars

Command: C:/dm/bin/dmc.exe

Parameter (arguments): $ (itemfilename) $ (itemext)

Initial directory (initial directory): $ (itemdir)

Next, switch to the file where the main function is located, and click "gnu c ++ compiler" under the Tools menu to start compilation.

Note that G ++ is compiled by a pure C ++ program. For a program that contains int _ tmain (INT argc, _ tchar * argv []), c ++ programs specific to such VC cannot be compiled.

If there is no compilation error, for earlier versions of G ++, the output window has no output.

For newer versions of G ++, the following information is output:

# Cc1plus 0.67 0.22
# As 0.05 0.01
# Collect 2 0.36 0.19

This is the CPU time used by each sub-process in the compilation process of the-time report.

Of course, you can also change the compilation parameters so that other compilation information is output in the output window.

We can also use external tools to run the program generated by G ++. The procedure is as follows:

In vc2005, choose tools> external tools> Add )".

Enter:

Title: Run as C ++ Application

Command: % SystemRoot %/system32/cmd.exe

Parameter (arguments):/C producer (itemfilenamecmd.exe

Initial directory (initial directory): $ (itemdir)

Do not select the following "use output window" and "close upon exit ".

Note: The CPP file must be placed in the project, and the program generated by G ++ can be run!

A program compiled with G ++ of mingw can be run on a Windows system without mingw installed!

However, the program compiled in cygwin/GCC must depend on cygwin1.dll in windows.

Use vc2005 to create an empty environment for Win32 console applications without pre-compiled headers. In this way, compiled executable files cannot be run on any server. However, this can be done in a conventional empty environment.

The following describes how to set shortcuts.

Click "Tools> Custom" in the menu ",

Click "keyboard" in the lower right corner ",

Click the text box below "press the shortcut key,

Press SHIFT + Ctrl + F7. If the shortcut key has been assigned to other commands, replace one.

Enter "tool. External Command 6" in "display command inclusion", and then click "allocate.

Click "OK", and then click "close ".

In this way, the shortcut key shift + Ctrl + F7 is assigned to gnu c ++ compiler.

Note that when gnu c ++ compiler is located in item 6th of the external tool menu, enter "tool. External Command 6" in "display command inclusion "!

Similarly, we can assign a shortcut key to run as C ++ application.

Let's talk about how to allocate a toolbar.

Click "tools-> Custom" in the menu, and click the "toolbar" tab.

Click "new ",

Enter "G ++" in the toolbar name ",

Switch to the "command" tab.

Click "Tools" in "category ",

In the command on the right, drag "external command 6" to the created g ++ toolbar.

Do not close the "Custom" dialog box first.

Click the gnu c ++ compiler button on the G ++ toolbar.

Click the "Modify selected content" button in the Custom dialog box to set attributes such as the name and text of the buttons in the toolbar.

Run as C ++ application can also be put in the G ++ toolbar in this way.

However, if you want to output the output result of G ++ to the error list, or use the VC ide to debug the program generated by G ++, it is absolutely impossible.

G ++ error prompts are much more intelligent than VC, which helps us quickly find the root cause of the problem.

If you are interested, you can add make.exe and so on to the external tool of vc2005 to compile the entire project. Of course, makefile is indispensable in the project.

Gdb.exe can also be integrated, but do not forget that the parameter (arguments) should be-g-wall-o $ (itemfilename) $ (itemext)-time, the parameter-G generates debugging information. The GNU Debugger can use this information.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.