Tracking and debugging methods for easy language static compilation support libraries

Source: Internet
Author: User

Author: Zhuang Xiaoli (liigo)

Date: 2012-6-19

Original: http://blog.csdn.net/liigo/article/details/7677507

Reprinted please indicate the source: http://blog.csdn.net/liigo/

A dynamic library that supports libraries in easy language (*. FNE) and static library (* _ static. lib) is usually the same set of source code, and the dynamic library debugging is often successful, so the static library should be fine. But I am afraid of 10 thousand. Even if I still encounter normal compilation (using the dynamic library of the supported database), the static compilation (using the static library of the supported database) runs abnormally. In this case, you can only debug the static library separately. At first, I did not find a way to debug the easy-language support for library static libraries. I just used the original methods such as the pop-up message box and Log File writing. However, this method is too stupid, you must rely on it to locate and solve bugs, except pray for good luck. The cruel reality forced me (liigo) to find a way to debug the easy-language support for library static libraries. I did not have to worry about it and finally found it. The procedure is as follows:

1. First, you need to set the easy-language static compilation parameters and modify <E> \ tools \ link. INI file, set show_command_line = Yes, retain_intermediate_files = Yes, and delete the semicolon (;) at the beginning of the corresponding line (;).

2. Compile the debug version of the static library, which overwrites the file with the same name under the <E> \ static_lib \ directory. The generated static database should be processed using resym.exe. For more information, see SDK \ static_docs \.

3. Compile a program in easy language, call the support library command, and then perform static compilation. At this time, the linker may prompt that libcmtd cannot be found. lib, libcpmtd. lib, libcimtd. the debug version of the C/C ++ Runtime Library such as Lib. This is because the vc98linker downloaded online does not contain the debug version library, but it doesn't matter. We will go to the vc6 installation directory to find it, can be found, copy to the lib directory of vc98linker and then OK. This step is not required when the vc6 linker installed on the local machine is automatically located in easy language.

4. Continue static compilation. The linker should prompt that there is a symbol conflict between libcmtd. lib and libcmt. Lib, and the static compilation fails. The reason is easy to understand. Our debug static library should be linked to the debug C Runtime Library libcmtd. lib, while the static library of the easy-to-use language core library is the release version, it needs to link the released version of the C Runtime Library libcmt. lib. But it doesn't matter. The subsequent steps will be solved by attaching command line parameters to the linker.

5. Because we have set "display chainer command line" (show_command_line = yes) in the previous step 1st, the command line of the linker will be output easily in step 4th, it is roughly as follows:

"C: \ Program Files \ e \ vc98linker \ bin \ link.exe" "E: \ liigo \ temp \ bt_static.obj" "C: \ Program Files \ e \ static_lib \ krnln_static.lib "C: \ Program Files \ e \ static_lib \ btdownload_static.lib" "C: \ Program Files \ e \ static_lib \ btdownload \ gzip. lib "kernel32.lib user32.lib
Gdi32.lib winmm. lib msimg32.lib winspool. lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib UUID. lib odbc32.lib odbccp32.lib "E: \ liigo \ temp \ bt_static.res"/libpath: "C: \ Program Files \ e \ static_lib"/nologo/machine: i386/subsystem: Windows/out: "E: \ liigo \ temp \ bt_static.exe"

Copy the command line and paste it to the console window (START-run-cmd.exe). Then add some parameters after the command line,/nodefaultlib: libcmt. LIB/PDB: "estatic. PDB "/debug/pdbtype: Sept, as follows:

C: \ Users \ liigo> "C: \ Program Files \ e \ vc98linker \ bin \ link.exe" "E: \ liigo \ temp \ bt_static.obj" "C: \ Program Files \ e \ static_lib \ krnln_static.lib "C: \ Program Files \ e \ static_lib \ btdownload_static.lib" "C: \ Program Files \ e \ static_lib \ btdownload \ gzip. lib "kernel32.lib
User32.lib gdi32.lib winmm. lib msimg32.lib winspool. lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib UUID. lib odbc32.lib odbccp32.lib "E: \ liigo \ temp \ bt_static.res"/libpath: "C: \ Program Files \ e \ static_lib"/nologo/machine: i386/subsystem: Windows
/Out: "E: \ liigo \ temp \ bt_static.exe"/Nodefaultlib: libcmt. lib/PDB: "estatic. PDB"/debug/pdbtype: sept

Here I will explain: the New Parameter/nodefaultlib: libcmt. lib is used to solve libcmt. lib and libcmtd. conflicts between Lib. If there are other libraries and libcmtd. lib has a symbolic conflict and is resolved in the same way. Other new parameters/PDB: "estatic. PDB "/debug/pdbtype: Sept is used to add debugging information to the statically compiled exe. The parameter/PDB:" estatic. PDB "specifies the name of the debugging file to be generated (with a path ). In my (liigo) test, even if. the PDB file is not in the same directory as the final compiled EXE file, and the file name is not the same. The vc6 debugger can also locate and load the file. PDB file. So we don't need to care about the path and file name of. PDB here. But if the debugger cannot locate. PDB in the future, we should modify it back.
/PDB: Specifies a. PDB with the same directory as the EXE and the same main file name (in this example/PDB: "E: \ liigo \ temp \ bt_static.pdb ").

6. Press enter to execute the link command in step 5th, so the static compilation is successful (if everything goes well). We get the EXE executable program containing debugging information. Where can I find this EXE? That is, the directory and file name you entered in easy language during static compilation in step 4th.

7. Run the EXE program generated in the previous step, press the system Hot Key CTRL + ALT + DEL to open the task manager, find the EXE process, right-click it, select "debug" from the menu, and click "attach to process" in the next confirmation dialog box. Then, vc6 starts and debugs the EXE process, it automatically locates and loads the data generated in step 5th. PDB debugging information file. Note: In this step, you must set vc6 as the system JIT Debugger by using the VC-tools-options-Debug Method and select "just-in-time debugging ".

8. Open the source code file of the static library of the supported library in the file-Open Main Menu of vc6. Press F9 to set the breakpoint and start the program XD. If you cannot set a breakpoint if you press F9 without any response, it should be because step 2nd or step 5th is incorrect. Go back and check and try again.

-- Full text --

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.