Vs tips (basic part)

Source: Internet
Author: User
Tags microsoft help

Part1:

1. How to Solve the Problem of incorrect connection to Visual C ++ 6.0
Scenario: if a file is changed, the entire project must be re-compiled and linked once. Just now the link is ready for operation, and the system prompts you to re-compile the link once.
This is because of the future file (the modification time and creation time are later than the system time. You can do this: Find the DEBUG directory under the project folder, delete all files created and modified at a time later than the system time, and then rebuild all again.

2. What are common errors that cause lnk2001?
The main lnk2001 error is: unresolved external symbol "symbol"
This error message is returned if the linked program cannot find the referenced function, variable, or tag in all libraries and target files.
Generally, there are two reasons for the error: one is that the referenced function or variable does not exist, the spelling is incorrect or the usage is incorrect; the other is that different versions of the Link Library may be used. The following are possible causes of lnk2001 errors:
<1> lnk2001 error caused by an Encoding Error
(1) mismatched program code or module definition (. Def) file causes lnk2001. For example, if a variable "var1" is declared in the C ++ source file, but the variable "var1" is attempted to access the change volume in another file.
(2) If the inline function is defined in the. cpp file, rather than being defined in the header file, lnk2001 errors will occur.
(3) When calling a function, if the parameter type used does not match the type declared in the header function, lnk2001 error will occur.
(4) lnk2001 error will occur when you attempt to call a virtual function from the constructors or destructor of the base class.
(5) Pay attention to the availability of functions and variables. Only global variables and functions are public. Static functions and static variables have the same scope of use. A compilation error or lnk2001 error occurs when you try to obtain any static variables not declared in the file from outside the file.
<2> lnk2001 errors caused by compilation and connection settings
(1) If the/nod (/noderaultlib) option is used during compilation, the Runtime Library and MFC required by the program will be written into the target file module by the compiler, however, these libraries will not be linked to the project file unless they are explicitly included in the file. In this case, using/nod will cause lnk2001 errors.
(2) If no program entry is set for wwinmaincrtstartup, the "unresolved external on _ winmain @ 16" lnk2001 error message will appear when Unicode and MFC are used.
(3) When compiling with the/MD option, since all the runtime libraries are kept in the dynamic link library, reference "_ imp _ FUNC" in the target file. If you try to use the static library libc. lib or libcmt. Lib for Link, lnk2001 error will occur on _ imp _ FUNC. If you do not use the/MD option for compilation, the lnk2001 error will also occur when you use the msvcxx. Lib link.
(4) When compiling with the/ml option, if libcmt. Lib is used, the lnk2001 error will occur on _ errno.
(5) When compiling and debugging an application, if you use the release modal library for link, the lnk2001 error will also occur. Similarly, the same error occurs when you use the debug modal library to link the release application.
(6) mixed use of libraries and compilers of different versions can also cause problems, because the new library may contain symbols and descriptions not available in earlier versions.
(7) using inner and non-inline compilation options in different modules can cause lnk2001 errors. If function inline (/ob1 or/ob2) is enabled when the C ++ library is created, but function inline (no inline keyword) is disabled in the header file that describes the function ), only the error message is returned. To avoid this problem, the inline keyword should be marked as an inline function in the corresponding header file.
(8) Incorrect/subsystem or entry settings can also cause lnk2001 errors.

3. How to debug a DLL called by an EXE file without source code
In Visual C ++ 6.0, go to the project Setting Dialog Box and select the debug tab. Generally, Visual Studio uses "executable for debug session" by default as the executable file name, but you can change it to any program you want. You can even specify different working directories and PASS Parameters to your program. This technique is often used to debug DLLs, namespace extensions, COM objects, and other plug-in programs called from certain EXE and third-party exe.

4. What do the project files in Visual C ++ 6.0 Project represent?
. Opt: parameter file of the project about the development environment. Such as the tool bar position and other information.
. APS (appstudio file) is a resource auxiliary file in binary format. You do not need to worry about it.
. CLW: classwizard information file is actually in the INI file format. If you are interested, please study it. Sometimes the classwizard has a problem. You can manually modify the CLW file to solve the problem. If this file does not exist, you will be prompted whether to re-create it each time you use classwizard.
. DSP (developstudio project): project file, text format, but do not modify it manually if you are not familiar with it.
. DSW (developstudio workspace): It is a workspace file. Other features are similar to. DSP.
. PLG: it is a compilation information file. The error and warning information files during compilation (actually an HTML file) are generally of little use. In the dialog box that appears, choose tool> Option to control file generation.
. HPJ (Help Project): a project that generates a Help file, which can be processed by Microsoft Help compiler.
. MDP (Microsoft devstudio project): It is an earlier version of the project file. To open this file, you will be prompted to convert it to a new. DSP format.
. Bsc: Used to browse project information. This file is required if source Brower is used. If you do not need this function, you can remove the generate browse info file in project options to speed up compilation.
. Map is the image information record file of the execution file. This file is generally not required unless it is at the underlying level of the system.
. PCH (pre-compiled file): it is used to compile files, which can speed up compilation, but the file size is very large.
. PDB (Program database): Records Program-related data and debugging information, which may be useful during debugging.
. Exp: it is generated only when the DLL is compiled. It records some information about the DLL file and is generally useless.
. NCB: no compile browser ). You can delete this file when the Automatic completion function fails. The project is automatically generated after compilation.

5. How to completely delete a class generated by classwizard
First, select. H and. to delete the CPP file, press delete to delete it, delete the two files in the file manager, and then run classwizard. If you want to remove the files, select Remove.

6. How to debug in the release status
Project-> setting => projectsetting dialog box, select the release status. In the C/C ++ label, select general for category, disable (Debug) for optimizations, and program database for debut info. Select the Generate debug info check box in the Link label.
Note: It is only an intermediate state between debug and release, and all assert and verify do not work. The function call method is actually called, rather than the table, however, in this status, the quickwatch and call queue tracking functions are still effective, just like the debug version.

7. What is the difference between release and debug?
The release version is called the release version, and the debug version is called the debug version.
Debug can be executed and tracked in one step, but the generated executable file is relatively large, and the code runs slowly. Release runs fast and has a small executable file, but cannot execute the debugging function under the compiling conditions.
The release EXE file is linked to the Standard mfc dll (use MFC in a shared or static DLL ). These DLL have been configured during Windows installation, so these programs can run on machines without visual C ++ 6.0 installed. The debug version EXE is linked to the debug version of the mfc dll file and cannot be run on a machine without visual C ++ 6.0 installed, because the corresponding DLL is missing, unless you select use static DLL when link.

8. What is the difference between assert and verify?
The content in assert is not compiled in the release version. Verify still translates the content, but does not judge whether the content is true or false. Therefore, the latter is safer.
For example, assert (file. Open (strfilename )).
Once in the release version, this line is ignored, and the file is not open () at all, and there is no error message. If verify () is used, this problem will not occur.

9. What is the relationship between workspace and project?
Each workspace can contain several projects, but only one of them is in the active state. Each project can have dependencies .. for example, the active project can depend on other static libraries that provide function calls.

Part2:

01. This is often the case when Vc is used for development projects:

Only one file is changed, but the entire project must be re-compiled and connected once. Just after the connection was established, I was prompted to re-compile the connection once, which is very annoying. This is because of the emergence of future documents.

Solution: Find the DEBUG directory in the corresponding folder, delete all future files, and rebuild all. (In the future, files will be created and modified later than the current system time)

02. Sometimes, the classview In the workspace is messy.The performance is as follows:

(1) added member variables or functions cannot be displayed;

(2) even if it is displayed, you cannot jump to the correct position after double-clicking.

Solution: Delete the. NCB file and rebuild all.

03. How can I delete a class cleanly?

(1) first Delete the corresponding. h and. cpp files from the FileView In the workspace;

(2) Close the project and delete the corresponding. h and. cpp files from the actual folder;

(3) Delete the. CLW file;

(4) Open the project and rebuild all.

04. Add a. cpp file to the project file and compile the connection. The pre-compilation header is not found.

Solution: # include "stdafx. H"

05. How do I add my own defined classes to the project?

There are many methods to introduce a simple one:

(1) Select Insert/New Class Menu

(2) In the dialog box that appears, set class type to generic class;

(3) enter the class name.

Of course, you can also decide the base class of the class.

06. How to import multiple projects in the workspace )?

Open a project (*. DSP file), select another project file (*. DSP file), you can insert another project.

In the classview view, right-click a project to activate it. inserting multiple projects in the workspace facilitates copying code and resources between different projects.

07. How to organize too many classes in the classview view?

You can right-click the classview view to create a folder (new folder) and drag classes of similar properties to the corresponding folder to make the entire view clear.

08. How to quickly delete temporary files in the debug folder of a project?

In the FileView, right-click the project and choose clean.

09. It is very slow to edit a project with a large source file. What should I do?

Do not open the project file (*. DSP file). Open a single source file (*. h or *. cpp) to edit. It is much faster.

10. If you want to copy the entire project to a floppy disk, which files can be deleted?

In addition to deleting the debug folder in the project folder, *. NCB, *. Opt, *. PLG, and other files can also be deleted. These files can be rebuilt all and re-generated.

11. How to quickly generate a new project that is identical to the existing project except the project name?

Use the "file" menu to generate the custom Appwizard in the new project, select an existing project, and select the project name of the existing project (*. DSP) finish. After compilation, an Appwizard is generated for a project that is the same as an existing project but can be renamed again. You can use it like MFC Appwizard. If you do not want to use it, you can delete the. awx and. PDB files in the Wizard from the common \ msdev98 \ template directory under the VC installation directory.

12. How to position the cursor in the source file to symmetric {} and # If, # endif?

The former uses"Ctrl" + "}"The latter uses "Ctrl" + "K ".

13. How to set the header file and library file in VC?

In addition to the default VC header files and library files, if you often need to use third-party header files and library files, you can set them in the directories of Tools Options. If you only need to use this project, you can set the library file in project setting-> link object/library modules.

14. If you want the console application to support the MFC class library?

You can include the MFC library in the console application, but the console application is single-threaded by default, and the MFC is multi-threaded. To solve this problem, in the project setting-> C/C ++ option, select code generation and select debug multithread in the use run-time library drop-down box.

15. How can I add ODBC functions to an MFC application?

(1) Add the following line at the end of the stdafx. h file:

# Include <afxdb. h> // mfc odbc database classes

(2) edit the RC file in text mode (using file-> open as text)

In the following program line (there are two parts in total ):

# Include "L. CHS \ afxprint. RC" // printing/print preview resources

Add the following line:

# Include "L. CHS \ afxdb. RC" // database resources

16. After the database table is modified, how can I quickly update a crecordset record set bound to the table?

Updatecoloumns and bind all are used after the record set class is selected under the member variables label in classwizard.

17. How can I find only executable code. EXE files?

Use VC open file to open *. EXE in resources mode, modify the resource file directly, and save the file.

18.File normalization function key
When the source file is compiled, Visual C ++ providesAlt + F8Function keys are used to normalize files. This key is often used to normalize the files. (Note: if the Alt + F8 function keys are used for two consecutive case statements, a processing error occurs and the data cannot be normalized ).

Part 3: 

Tips

1) Sometimes, during compilation, the computer suddenly shuts down illegally (maybe someone accidentally hits the power or your memory is unstable ). After you restart the machine, open the project and re-compile it. Then, the VC will crash. You may think that your VC compiler is broken, but it is not (you should try to compile other projects !), You only need to delete the project's. NCB,. Opt,. APs,. CLW files, and all the files under the debug and release directories, and then recompile them.

2) If you want to share your source code project with others, but copying the entire project is too large. You can delete the following files:. DSW,. NCB,. Opt,. APs,. CLW,. PLG, and all files in the debug and release directories.

3) when your workspace contains multiple projects, you may not be able to intuitively and intuitively see which project is the current one. You can set the settings as follows: Tools-> options-> Format, select workspace window in category, and change its default font (for example, set it to fixedsys.

4) how to change the name of an existing project? Turn off the project. Open the. DSP file in text format and replace the original project name.

5) vc6 is useful for smart prompting of class members, but sometimes it fails. You can close the project first. CLW and. delete NCB and re-open the project. Click View> classwizard in the menu item. In the displayed dialog box, click "add all" and rebuild all. The problem should be solved.

 

Appendix:

Explanation of VC file extensions

. APs: An intermediate file for storing binary resources. VC converts the current resource file to a binary format and stores it in the APs file to accelerate resource loading. Resource auxiliary file.

. BMP: a bitmap resource file.

. Bsc: a browser information file generated by the browser information maintenance tool (BSCMAKE) from the original browser information file (. SBR). The BSC file can be used to quickly locate the file in the source code editing window. This file is required if source Brower is used to browse project information. You can remove generate browse info file from project options to speed up compilation.

. CLW: files generated by classwizard to store class information. Classwizard information file, INI file format.

. CNT: used to define the "contents" structure in the Help file.

. Cpp or. cxx: source code file written in C ++.

. Cur: The cursor resource file.

. Def: module definition file, which can be used to generate a dynamic link library.

. DLG: defines the independent files of the dialog box resources. This file is not required for the VC project, Because VC generally places the dialog box Resources in the. RC resource definition file.

. DSP: The project file generated by the VC development environment. vc4 and earlier versions use the Mak file to define the project. Project file, in text format.

. DSW: Workspace file generated by the VC development environment, which is used to organize multiple projects into one workspace. Workspace files, similar to. DSP.

. Exp: the output file generated by the Lib tool from the def file, which contains the output information of functions and data items. The link tool uses the exp file to create a dynamic link library. It is generated only when the DLL is compiled, and some information in the DLL file is recorded.

. H,. HPP, or. hxx: header files written in C/C ++ are usually used to define data types and declare variables, functions, structures, and classes.

. HLP: Windows Help file.

. HM: In the help project, this file defines the correspondence between the Help file and the id value between the dialog box, menu or other resources.

. HPJ: The help project file generated by Help Workshop, which is used to control the creation process of the Help file.

. HPG, the project that generates the Help file.

. Ilk: An intermediate file generated during the connection process. It is only used by the link tool.

. Lib: library file. The link tool will use it to connect various input libraries to generate the EXE file.

. LIC: user license file, which is required when using certain ActiveX controls.

. Mak: Make file. The project files used in vc4 and earlier versions are used to specify how to create a project. vc6 converts the Mak file into a DSP file for processing.

. MAP: a text file generated by the link tool, which contains information about the connected program, such as group information and public symbol information in the program. The image information of the execution file.

. MDP: The old project file, which is equivalent to. DSP

. NCB: NCB is the abbreviation of "no compile Browser". It stores information used by classview, wizardbar, and component gallery, which is automatically generated by the VC development environment. The Browser file is not compiled. You can delete this file when the Automatic completion function fails. The project is automatically generated after compilation.

. OBJ: the target file generated by the compiler or assembler. It is the binary intermediate file of the module.

. Odl: source code file written in the Object Description Language. VC uses it to generate a TLB file.

. Olb: A special dynamic link library with type library resources, also known as object library files.

. Opt: files automatically generated by the VC development environment to store various options in the workspace. The parameter file of the project about the development environment. For example, tool bar location information.

. PBI,. PbO, And. PBT: three files generated and used by the VC performance analysis tool profile.

. PCH: Pre-compiled header file, which is large and automatically generated by the compiler when a project is created. It stores some of the Code that has been compiled in the project and will not be re-compiled when the project is created in the future, to speed up the entire compilation process.

. PDB: A program database file that is automatically generated when a project is created. It stores various program information and is used to speed up the debugging process. Records Program-related data and debugging information.

. PLG: compile the information file, the error and warning information files during compilation.

. RC: Resource definition file.

. RC2: Resource definition file for use in special cases.

. Res: Binary resource file. After the resource compiler compiles the resource definition file, the res file is generated.

. SBR: The VC compiler generates the original browsing information file for each OBJ file. The browser information maintenance tool (BSCMAKE) will generate the BSC file using the SBR file.

. TLB: Ole library file, which stores the data types, modules, and interface definitions of OLE automation objects. The Automation server can understand how to use automation objects through the TLB file.

 

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.