VS2012 for Linux application Development (2): Patterns

Source: Internet
Author: User

1.1Code hints feature

In the development of vs ,Visual Assist is a great plug-in and we can still use it for code analysis, but it only supports vcxprojproject, so we choose to Vcxproj Project is extended so that the visualassist can be used normally.

In addition, the IntelliSense forVS does not support some of the GCC extensions, which can be error-prone when doing code analysis. We have solved some of the problems by forcing the header file to be included:

Note that the purpose of this file is to allow vs to parse the code, instead of having the ability to compile the code for vs !!

This header file is similar to this:

#pragma once

// The purpose of this document is only to make VS syntax errors can be resolved, not to allow the program to execute correctly!

#define __attribute__ (x)

#define __signed__ signed

#define inline __inline

#define Bits_per_long 4

#define _time_t

#define __inline__

#define __u64 int

.......

1.2Code compilation

Very early on, I wanted to compile by porting GCC to Cywin and finally gave up.

One reason for this is that the Cywin is slower, albeit a local application under Windows . But it is much slower to compile than to execute GCC in a virtual machine.

The main reason for this is that the technology used by Cywin in simulating fork operation affects its speed (see other article Analysis).

Another reason to abandon Cywin is that the compilers provided by the embedded Linux platform are Linux -based, and it is very difficult to migrate these compilers.

So we use the method of remote compilation, when the VS is compiled, use SSH to log into the virtual machine's Linux system to compile, and then analyze the information generated during the compilation, converting it to vs Information that can be identified. This way VS is the right location in the IDE to correctly locate the file where the error occurred!

In such a way. the error message generated by make or gcc is different because of the differences in the compilation method, and in order to deal with such differences, we will use python to complete this process. This makes it possible to make only a few changes to the Python script in different projects. This script can be completely part of the project.

Another advantage of this approach is that the code for the vs extension is greatly reduced, ensuring that it does not affect the stability of vs .

1.3Build Process Control

VS2012 uses MSBUILD to build, and it agrees to overwrite its own build process in a project. The default behavior points to the extensions that you define, which is the way we use them.

1.4Configuration of parameters

The compilation parameters against the VC and GCC can be found to have a very many number of parameters. such as macro definition, additional folders, and so on, this part can be used directly. In addition to some other specific parameters, we support it by adding new platforms and property pages to VS .

This allows us to configure specific parameters for GCC through the project properties of the VC .

The configuration of the Linux kernel is actually completed by the scripts/kconfig/mconf or scripts/kconfig/qconf program. In fact, the process is to read the Kconfig file Generation menu. Then, based on the user's choice to generate the . config file, we will simply change it to be configured under Windows :

It's easy to do this in VS , based on project configuration calls.

1.5Debugging

For debugging applications,VS provides the engine for the debugger. We extend this debugger engine to use ssh to connect to the virtual machine's system when debugging, or to connect directly to the target board. On it, use gdb to load the application for debugging, or use gdb to connect the gdbserver of the target board.

We will use GDB 's machine interfaceinstead of the interactive interface that is used frequently.

Drive debugging try to use KGDB, have not played, play time to talk about it.

1.6Project templates

After debugging, UBOOT,LINUX and other project are cured as templates, like this:

1.7Accessibility features

Integrate python console,ssh console, serial console into VS , hey, it's strong enough ~ ~ ~

Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

VS2012 for Linux application Development (2): Patterns

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.