home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / chplus / cpp / 3 / Tools.exe / tdump.txt < prev    next >
Text File  |  1998-02-09  |  60KB  |  1,527 lines

  1. TDUMP Help
  2.  
  3. 1.  TDUMP: The file inspecting utility
  4. 2.  Understanding "Undefined Symbol" Error Messages
  5. 3.  Resolving Undefined Symbol linker messages
  6. 4.  Borland Open Architecture: Name Mangling
  7.  
  8.  
  9. ===================================================================
  10. 1.  TDUMP: The file inspecting utility
  11. ===================================================================
  12. TDUMP.EXE is a utility that you use to examine the structure and
  13. contents of files.
  14.  
  15. TDUMP organizes the output display according to the extension of the
  16. file you're dumping. If the file extension is recognizable, TDUMP
  17. displays the file's components according to the file type. TDUMP
  18. recognizes many file extensions, including .EXE, .OBJ, and .LIB files.
  19. If TDUMP doesn't recognize an extension, it produces a hexadecimal dump
  20. of the file. You can control the output format by using command-line
  21. options when you start the TDUMP (these command-line options are
  22. described later).
  23.  
  24.  
  25. TDUMP syntax
  26. ------------
  27. The syntax for TDUMP is:
  28.  
  29.   TDUMP [<options>] <Inputfile> [<Listfile>] [<options>]
  30.  
  31.   o  <options> stands for any of the TDUMP options discussed in the
  32.      next section. For a list of the available command-line options,
  33.      type TDUMP, then press <Enter> at the DOS prompt.
  34.  
  35.   o  <Inputfile> is the file whose structure you want to display (or
  36.      "dump").
  37.  
  38.   o  <Listfile> is an optional output file name. Note that you can
  39.      also use the standard DOS redirection command ">" to create an
  40.      output file.
  41.  
  42.  
  43. TDUMP command-line options
  44. --------------------------
  45. You can use several option switches at a time with TDUMP. Because you can start
  46. each option with either a hyphen or a forward slash, the following two commands
  47. are equivalent:
  48.  
  49.   TDUMP -el -v demo.exe
  50.  
  51.   TDUMP /el /v demo.exe
  52.  
  53.  
  54. The -a and -a7 options
  55. - - - - - - - - - - - -
  56. TDUMP automatically adjusts its output display according to the file extension
  57. type. However, you can force an ASCII file display using either the -a or -a7
  58. options:
  59.  
  60.   o  -a  produces an ASCII file display that shows the offset and the
  61.      contents using the displayable ASCII characters. TDUMP displays
  62.      non-displayable characters (like control characters) as a period.
  63.  
  64.   o  -a7 converts high-ASCII characters to their low-ASCII
  65.      equivalents. This is useful if the file you are dumping sets
  66.      high-ASCII characters as flags (WordStar files do this).
  67.  
  68.  
  69. The -b# option
  70. - - - - - - - -
  71. The -b# option allows you to display information beginning at a specified offset.
  72. For example, if you wanted a dump of MYFILE starting from offset 100, you would
  73. use the following command:
  74.  
  75.   TDUMP -b100 MYFILE
  76.  
  77.  
  78. The -d option
  79.  - - - - - - -
  80. The -d option causes TDUMP to dump any Borland 32-bit debug information found in
  81. the .OBJ file. If you do not specify this option, TDUMP displays raw data only.
  82.  
  83.  
  84. The -e, -el, -er and -ex options
  85. - - - - - - - - - - - - - - - - -
  86. All four options force TDUMP to display the file as an executable (.EXE) file.
  87.  
  88. An .EXE file display consists of information contained within a file that is used
  89. by the operating system when loading a file. If symbolic debugging information is
  90. present (Turbo Debugger or MicrosoftCodeView), TDUMP displays it.
  91.  
  92. TDUMP displays information for DOS executable files, NEW style executable files
  93. (Microsoft Windows and OS/2 .EXEs and DLLs), and Linear Executable files.
  94.  
  95.   o  -el suppresses line numbers in the display.
  96.  
  97.   o  -er suppresses the display of the relocation table.
  98.  
  99.   o  -ex prevents the display of New style executable information.
  100.      This means TDUMP will only display information for the DOS
  101.      "stub" program.
  102.  
  103.  
  104. The -h option
  105. - - - - - - - -
  106. The -h option displays the dump file in hexadecimal (hex) format. Hex format
  107. consists of a column of offset numbers, 16 columns of hex numbers, and their ASCII
  108. equivalents (a period appears where no displayable ASCII character occurs).
  109.  
  110. If TDUMP doesn't recognize the input file's extension, it displays the file in hex
  111. format (unless an option is used to indicate another format).
  112.  
  113.  
  114. The -l and -li options
  115. - - - - - - - - - - - -
  116. The -l option displays the output file in library (.LIB) file format. A library
  117. file is a collection of object files (see the -o option for more on object files).
  118. The library file dump displays library-specific information, object files, and
  119. records in the object file.
  120.  
  121. The -li option tells TDUMP to display a short form of "impdef" records when
  122. dumping import libraries. You can also specify a search string using the following
  123. syntax:
  124.     -li=<string>
  125.  
  126. For example, the command
  127.     TDUMP -li=codeptr import.lib
  128. results in the following output:
  129.     Impdef:(ord) KERNAL.0336=ISBADCODEPTR
  130. This output shows that the function is exported by ordinal, whose ordinal value is
  131. 336 (decimal). In addition, the output displays the module and function name.
  132.  
  133. If you give the command
  134.     TDUMP -li=walk import32.lib
  135. TDUMP displays:
  136.     Impdef:(name) KERNEL32.????=HEAPWALK
  137. This shows the output of a function exported by name.
  138.  
  139.  
  140. The -m option
  141. - - - - - - -
  142. The -m option leaves C++ names occurring in object files, executable files, and
  143. Turbo Debugger symbolic information files in "mangled" format. This option is
  144. helpful in determining how the C++ compiler "mangles" a given function name and
  145. its arguments.
  146.  
  147.  
  148. The -o, -oc, -oi, and -ox options
  149. ---------------------------------
  150. The -o option displays the file as an object (.OBJ) file. An object file display
  151. contains descriptions of the command records that pass commands and data to the
  152. linker, telling it how to create an .EXE file.
  153.  
  154. The display format shows each record and its associated data on a record-by-record
  155. basis.
  156.  
  157.   o  -oc causes TDUMP to perform a cyclic redundancy test (CRC) on
  158.      each record encountered. The display differs from the -o display
  159.      only if an erroneous CRC check is encountered (the TDUMP CRC
  160.      value differs from the record's CRC byte).
  161.  
  162.   o  -oi<id> includes only specified record types in the object module
  163.      dump. Replace <id> with the name of the record to be displayed.
  164.      For instance,
  165.  
  166.         TDUMP -oiPUBDEF MYMODULE.OBJ
  167.  
  168.      produces an object module display for MYMODULE.OBJ that displays
  169.      only the PUBDEF records.
  170.  
  171.   o  -ox<id> excludes designated record types from the object module
  172.      dump. Replace <id> with the record name not to be displayed. For
  173.      instance,
  174.  
  175.         TDUMP -oxPUBDEF MYMODULE.OBJ
  176.  
  177.      produces an object module display for MYMODULE.OBJ that excludes
  178.      the PUBDEF records.
  179.  
  180.   o  The -ox and -oi options are helpful in finding errors that occur
  181.      during linking. By examining the spelling and case of EXTDEF and
  182.      PUBDEF symbols, you can resolve many linking problems. For
  183.      instance, if you receive an "unresolved external" message from
  184.      the linker, use "TDUMP -oiEXTDEF" to display the external
  185.      definitions occurring in the module causing the error. Then, use
  186.      "TDUMP -oiPUBDEF" on the module containing the public symbol
  187.      which the linker could not match.
  188.  
  189. Another use for the -oi switch is to check the names and sizes of the segments
  190. generated in a particular module. For instance,
  191.  
  192.   TDUMP -oiSEGDEF MYMODULE.OBJ
  193.  
  194. displays the names, attributes, and sizes of all of the segments in MYMODULE.
  195.  
  196. Note: To get a list of record types for -0i and -ox, use the command-line
  197.       options -oi? and -ox?.
  198.  
  199.  
  200. The -R option
  201. - - - - - - -
  202. The -R option causes TDUMP to dump relocation tables from 32-bit PE (Win32) format
  203. images. The default is to suppress these dumps.
  204.  
  205.  
  206. The -v option
  207. - - - - - - -
  208. The -v option is used to create a verbose display. If you use -v with an .OBJ or
  209. .LIB file, TDUMP produces a hexadecimal dump of the record's contents without any
  210. comments about the records.
  211.  
  212. If you use TDUMP on a Turbo Debugger symbol table, it displays the information
  213. tables in the order in which it encounters them. TDUMP doesn't combine information
  214. from several tables to give a more meaningful display on a per-module basis.
  215.  
  216.  
  217. ===================================================================
  218. 2.  Understanding "Undefined Symbol" Error Messages
  219. ===================================================================
  220. One of the most common error messages seen by developers using a C or
  221. C++ compiler is "undefined symbol." This document provides a general
  222. description of what causes undefined symbol error messages, as well as
  223. instructions on solving specific undefined symbol errors.
  224.  
  225. The following error message are treated in order:
  226.   UNDEFINED SYMBOL AT COMPILE TIME
  227.   UNDEFINED SYMBOL AT LINK TIME
  228.   OTHER UNDEFINED SYMBOL ERRORS
  229.   o  UNDEFINED SYMBOL WHEN LINKING A BORLAND EXAMPLE
  230.   o  UNDEFINED SYMBOL WHEN TLINKING FROM DOS COMMAND LINE
  231.   o  UNDEFINED SYMBOL LINKING C/C++ AND ASSEMBLY MODULES
  232.   o  UNDEFINED SYMBOL LINKING C++ WITH C OR ASSEMBLY MODULES
  233.   o  UNDEFINED SYMBOL: '_main' IN MODULE C0.ASM
  234.   o  UNDEFINED SYMBOL LINKING A DLL
  235.   o  UNDEFINED SYMBOL: A PSEUDO REGISTER (ie. _AX)
  236.   o  UNDEFINED SYMBOL: 'FIWRQQ'
  237.   o  UNDEFINED SYMBOL: AN IOSTREAM CLASS MEMBER
  238.   o  UNDEFINED SYMBOL: 'abort()'
  239.   o  UNDEFINED SYMBOL: '_exitclean()'
  240.   o  UNDEFINED SYMBOL: LLSH or SCOPY or FMUL or FDIV
  241.   o  UNDEFINED SYMBOL: STATIC POINTER TO A CLASS MEMBER FUNCTION
  242.   o  UNDEFINED SYMBOL: '_WSPRINTF'
  243.   o  UNDEFINED SYMBOL: 'fidrqq'
  244.   o  UNDEFINED SYMBOL IN WINDOWS.H
  245.   o  UNDEFINED SYMBOL USING TCLASDLL.LIB
  246.   o  UNDEFINED SYMBOL USING SELECTORS PROVIDED BY WINDOWS
  247.   o  UNDEFINED SYMBOL: 'ChangeSelector'
  248.   o  UNDEFINED SYMBOLS USING THE OBJECTWINDOWS LIBRARY (OWL)
  249.   o  UNDEFINED SYMBOL: 'Object::new(unsigned int)'
  250.   GETTING A CLOSER LOOK
  251.   o  USING TDUMP TO RESOLVE UNDEFINED SYMBOLS
  252.   o  USING IMPDEF TO RESOLVE UNDEFINED SYMBOLS IN A DLL
  253.  
  254.  
  255. UNDEFINED SYMBOL AT COMPILE TIME
  256. --------------------------------
  257. An undefined symbol at compile time indicates that the named
  258. identifier was used in the named source file, but had no definition in
  259. the source file. This is usually caused by a misspelled identifier
  260. name, or missing declaration of the identifier used.
  261.  
  262. EXAMPLE 1:
  263.     int main(void)
  264.     {
  265.         test = 1;
  266.         return 0;
  267.     }
  268.  
  269. The code shown in Example 1 generates an undefined symbol error if the
  270. variable "test" was not declared in either an included header file or
  271. in the actual source file itself.
  272.  
  273. EXAMPLE 2:
  274.     int main(void)
  275.     {
  276.         int test;
  277.         Test = 1;
  278.         return 0;
  279.     }
  280.  
  281. The code shown in Example 2 causes an undefined symbol error message
  282. to be displayed because the variable "Test" was not spelled as it was
  283. declared. Remember that C and C++ are case-sensitive languages.
  284.  
  285.  
  286. UNDEFINED SYMBOL AT LINK TIME
  287. -----------------------------
  288. When linking multi-file projects, the linker must resolve all
  289. references to functions and global variables shared between modules.
  290. When these references cannot be resolved, the linker generates
  291. an "undefined symbol" error message. This means that after searching
  292. all of the object files and libraries which are included in the link,
  293. the linker was unable to find a declaration for an identifier you
  294. used. This can be caused by:
  295.  
  296.   o  Forgetting to include a needed object module or library in
  297.      your link (project file, response file, or command line).
  298.  
  299.   o  Misspelling the name of the undefined symbol either where it
  300.      was used or where it was declared.
  301.  
  302.   o  Accidentally declaring a global variable as "extern."
  303.  
  304.   o  Forgetting to use extern "C" to disable name mangling when you're
  305.      mixing C++ with C or Assembly modules. See the specific entry on
  306.      this subject elsewhere in this document or consult the
  307.      HELPME!.DOC file included with the product.
  308.  
  309.   o  Turning OFF Generate Underbars in one of the modules you're
  310.      linking.
  311.  
  312. If all else fails, use TDUMP to dump both object modules and note any
  313. difference between the symbols used. This will usually give enough
  314. insight to resolve the problem. For more information on using TDUMP to
  315. resolve undefined symbol errors, see the "Getting a Closer
  316. Look "section in this document.
  317.  
  318.  
  319. OTHER UNDEFINED SYMBOL ERRORS
  320. ------------------------------
  321. The following list provides solutions to some of the more common
  322. causes of undefined symbol errors:
  323.  
  324.   o  UNDEFINED SYMBOL WHEN LINKING A BORLAND EXAMPLE
  325.      Almost all of Borland's examples come with project files. You
  326.      must use the project file when building the example to ensure
  327.      that all necessary modules are linked and all the necessary
  328.      settings are defined.
  329.  
  330.   o  UNDEFINED SYMBOL WHEN TLINKING FROM DOS COMMAND LINE
  331.      The TLINK command line must have the libraries in the following
  332.      order ( GRAPHICS.LIB + <user libs> + EMU.LIB + MATH (S,T,C,M,L -
  333.      for model) + C (S,T,C,M,L - for model)
  334.  
  335.   o  UNDEFINED SYMBOL LINKING C/C++ AND ASSEMBLY MODULES
  336.      There are several sources of undefined symbol errors when trying
  337.      to link assembly with C or C++ modules:
  338.  
  339.        o  Turbo Assembler generates all upper-case symbols unless you
  340.           specify /ml or /mx on the assembly command line. Since C
  341.           modules are, by default, case sensitive, failing to do this
  342.           will result in undefined symbols for all symbols that are
  343.           not completely upper case in the C module(s).
  344.  
  345.        o  The symbols in the assembly file being referenced from a C
  346.           module must be declared using a PUBLIC directive. TLINK does
  347.           not consider symbols which are not declared PUBLIC when it
  348.           attempts to resolve an undefined symbol.
  349.  
  350.        o  All symbols in the assembly module that are referenced in
  351.           the C module must be prototyped/declared as extern in the C
  352.           module -- the compiler generates undefined symbol errors for
  353.           all symbols not declared in this manner. In addition, all
  354.           symbols in the assembly module that are referenced from a C
  355.           module must have an underscore prefix. This naming
  356.           convention must be used in the assembly module. You can
  357.           either do this explicitly (_symbol) or you can use:
  358.  
  359.             .model <memory model used>, C
  360.  
  361.           to specify this implicitly for all symbols.
  362.  
  363.           IMPORTANT NOTE: If you put underscores in front of your
  364.           assembly routines and also use the .model (memory model)
  365.           C directive, the public symbol will be generated with two
  366.           underscores; consequently an undefined symbol error is
  367.           generated.
  368.  
  369.           If all else fails, TDUMP both object modules and note any
  370.           difference between symbols. This will usually give enough
  371.           insight to resolve the problem. For more information on
  372.           using TDUMP to resolve undefined symbol errors see the
  373.           "Getting a Closer Look" section in this document.
  374.  
  375.   o  UNDEFINED SYMBOL LINKING C++ WITH C OR ASSEMBLY MODULES
  376.      C++ is a strongly typed language. In order to support type-safe
  377.      linkage (as well as function overloading), Borland C++ must
  378.      attach information to the symbols generated for function names
  379.      and variables. When this is done, the symbol will no longer match
  380.      the standard C style function name. In order to link correctly
  381.      with C or assembly modules, the compiler must be notified that
  382.      the symbol is to be in the standard C style (non-encoded) rather
  383.      than employing C++ name-mangling (encoded). This is done by
  384.      prototyping the function as type extern "C". Here is a quick
  385.      example:
  386.  
  387.        extern "C" int normal_c_func( float, int, char );
  388.  
  389.      For an additional example, you may want to look at the header
  390.      files which came with the product. One such header file is
  391.      stdio.h.
  392.  
  393.   o  UNDEFINED SYMBOL: '_main' IN MODULE C0.ASM
  394.      Every DOS C program must contain a function called main(). This
  395.      is the first function executed in your program. The function name
  396.      must be all in lower case. If your program does not have one,
  397.      create one. If you are using multiple source files, the file that
  398.      contains the function main() must be one of the files listed in
  399.      the project.
  400.  
  401.      Note that an underscore character '_' is prepended to all
  402.      external Borland C++ symbols.
  403.  
  404.      In addition to an absent, misspelled or mis-cased symbol main,
  405.      there are two additional common causes:
  406.  
  407.        o  The "generate underbars" option is disabled.
  408.  
  409.        o  The Pascal calling Convention rather than the C calling
  410.           convention is selected.
  411.  
  412.  
  413.   o  UNDEFINED SYMBOL LINKING A DLL
  414.      It is relatively simple to link a DLL to your source:
  415.  
  416.        1)  Create a .LIB from the .DLL using Borland's implib utility.
  417.  
  418.        2)  Include the .LIB in your project if you're using the IDE or
  419.            in your TLINK command if you're using the command-line
  420.            compiler or linker.
  421.  
  422.        3)  Turn case sensitive link ON.
  423.  
  424.        4)  Turn case sensitive exports ON.
  425.  
  426.      The issues of linking C++ with C, assembly, or any other language
  427.      still apply. See the sections on linking C++, C, and assembly in
  428.      this document.
  429.  
  430.      If the link still fails, the techniques in the section "Getting A
  431.      Closer Look" should help you resolve the problem.
  432.  
  433.   o  UNDEFINED SYMBOL: A PSEUDO REGISTER (i.e. _AX)
  434.      Pseudo registers are only allowed in the Borland C++ and ANSI
  435.      modes of the compiler. You can change this setting in the
  436.      Options | Compiler | Source menu.
  437.  
  438.   o  UNDEFINED SYMBOL: 'FIWRQQ'
  439.      Your program uses floating point routines directly (or
  440.      indirectly) and you have NONE selected for floating point. Or,
  441.      you are using TLINK and have forgotten to include EMU.LIB or
  442.      FP87.LIB on the command line.
  443.  
  444.   o  UNDEFINED SYMBOL: AN IOSTREAM CLASS MEMBER
  445.      If you are using the Integrated Development Environment, simply
  446.      turn off Options | Compiler | Code Generation | Unsigned
  447.      Characters.
  448.  
  449.      If you are using the command-line compiler, simply remove the
  450.      '-K' option.
  451.  
  452.   o  UNDEFINED SYMBOL: 'abort()'
  453.      The sole purpose of abort is to print the error message
  454.  
  455.        "Abnormal Program Termination"
  456.  
  457.      and exit the program with an error code of 3. This function is
  458.      located in the startup code C0.ASM. Linker errors indicating that
  459.      abort() is an undefined symbol are only possible if the standard
  460.      startup code is not being linked into a project. Although this is
  461.      not a common C/C++ development practice, it is to be expected
  462.      when linking in code written other languages such Microsoft
  463.      Fortran, Clipper, or in cases where embedded systems are being
  464.      developed. To resolve the undefined symbol, extract the abort()
  465.      function from the startup code and make a separate object out of
  466.      it to be linked into the project.
  467.  
  468.   o  UNDEFINED SYMBOL: '_exitclean()'
  469.      There is a function called _exitclean which is new to Turbo C++.
  470.      Users moving from Turbo C 2.0 to Turbo C++ may encounter
  471.      _exitclean() as an undefined symbol at link time. _exitclean() is
  472.      defined in the Turbo C++ startup code. Users creating embedded
  473.      system (ROMable code), who do not use the standard Turbo C++
  474.      startup code, are likely to encounter _exitclean() as an
  475.      undefined symbol. These users can strip the function from the
  476.      C0.ASM file and create a separate .OBJ file which can be linked.
  477.      Another option would be to purchase the Borland C++ RTL source and make
  478.      the necessary adjustments.
  479.  
  480.   o  UNDEFINED SYMBOL: LLSH or SCOPY or FMUL or FDIV
  481.      The helper functions have changed their names from Turbo C 2.0 to
  482.      Turbo C++. This can lead to many undefined symbol issues.
  483.  
  484.      When LLSH or SCOPY or FMUL or FDIV (note no underscores here)
  485.      appear as undefined symbols at link time, it is likely that an
  486.      object module or library has code generated a call to some helper
  487.      function from the Turbo C 2.0 libraries. The solution is to
  488.      simply recompile all objects from source. You can do this by
  489.      choosing Compile | BuildAll from the menu in the IDE.
  490.  
  491.   o  UNDEFINED SYMBOL: STATIC POINTER TO A CLASS MEMBER FUNCTION
  492.      Any static member of a class must be initialized--if not that
  493.      static member generates an undefined symbol error. The following
  494.      is an example of how to initialize a static pointer to class
  495.      member function of a class is initialized:
  496.  
  497.      // When testing static member initialization, you must
  498.      // declare an instance of the class in a main function;
  499.      // otherwise, the linker has no reference which it must
  500.      // try to resolve, and the undefined symbol error will
  501.      // not be seen - thus you won't know that your
  502.      // initialization was in error.
  503.  
  504.      #include <iostream.h>
  505.  
  506.      // used to allow global initialization of static member pointer
  507.      typedef void (*fptr)();
  508.  
  509.      // declare class containing static members
  510.      class First
  511.      {
  512.        public:
  513.           static fptr statptr;
  514.      };
  515.  
  516.      // initialize static members of class First
  517.      fptr First::statptr = NULL;
  518.  
  519.      int main(void) {
  520.           First fVar;
  521.  
  522.           if (fVar.statptr == NULL)
  523.                cout << "fVar.statptr is NULL: " <<
  524.                fVar.statptr << endl;
  525.  
  526.           return 0;
  527.      } // end of main()
  528.  
  529.   o  UNDEFINED SYMBOL: '_WSPRINTF'
  530.      Turn off the "Case-sensitive exports" and "Case-sensitive link"
  531.      options. If you are using the command linker, don't use the /c
  532.      switch. If you are invoking the linker from the BCC(x) command
  533.      line, use the -lc- switch. If you are using the IDE, go to the
  534.      linker options dialog box and turn off the case sensitivity
  535.      switch.
  536.  
  537.   o  UNDEFINED SYMBOL: 'fidrqq'
  538.      You will get an undefined symbol fidrqq when using the Integrated
  539.      Development Environment if you have the Options | Compiler | Code
  540.      Generation | More | Floating Point Option set to NONE and you are
  541.      using floating point arithmetic in your program. In order to best
  542.      solve this problem you must set the IDE option for Floating Point
  543.      to either the emulation choice or to the 80x87 choice. Note that
  544.      if you choose an 80x87 setting the application generated by the
  545.      compiler will require an 80x87 chip to be present at run-time.
  546.      Use this setting only when truly appropriate.
  547.  
  548.   o  UNDEFINED SYMBOL IN WINDOWS.H
  549.      Make sure you are using the windows.h file that came with Borland
  550.      C++, NOT the windows.h that came with the Microsoft Windows SDK.
  551.      If you include the Microsoft windows.h file you will get many
  552.      undefined symbols including WINMAIN in caps and translatemessage
  553.      in lower case. Use our windows.h file instead of Microsoft's when
  554.      you are using our compiler.
  555.  
  556.   o  UNDEFINED SYMBOL USING TCLASDLL.LIB
  557.      To use the DLL version of the container class library you must do
  558.      ALL of the following:
  559.  
  560.        o  Use the large memory model
  561.  
  562.        o  Use Smart Callbacks
  563.  
  564.        o  Turn case sensitive link ON
  565.  
  566.        o  Turn case sensitive exports ON
  567.  
  568.        o  Use the DLL version of the RTL
  569.  
  570.        o  Define _CLASSDLL
  571.  
  572.   o  UNDEFINED SYMBOL USING SELECTORS PROVIDED BY WINDOWS
  573.      If you are using _C000h or other selectors provided by Windows
  574.      and they are coming up as undefined symbols, perhaps you are
  575.      compiling in C++ mode and forgot to extern "C" them.
  576.  
  577.      Programming in C:
  578.        extern WORD _C000h
  579.  
  580.      Programming in C++:
  581.        extern "C" WORD _C000h
  582.  
  583.   o  UNDEFINED SYMBOL: 'ChangeSelector'
  584.      The Windows API function ChangeSelector() has the wrong name in
  585.      KERNEL.EXE for Windows 3.0, and therefore in IMPORT.LIB. The name
  586.      given to this function (and this is NOT a joke) is 
  587.      PrestoChangoSelector().
  588.  
  589.      Use PrestoChangoSelector() in your program in place of
  590.      ChangeSelector() and all will be well.
  591.  
  592.   o  UNDEFINED SYMBOLS USING THE OBJECTWINDOWS LIBRARY (OWL)
  593.      If you get any of the following the undefined symbols:
  594.  
  595.        TApplication(unsigned char far *, unsigned int, unsigned int,
  596.            unsigned char far *, int )
  597.  
  598.        and
  599.  
  600.        TWindow::TWindow(TWindowsObject near *, unsigned char far *,
  601.            TModule near *)
  602.  
  603.        and are using the DLL versions of OWL and the Class Library,
  604.        you must define _CLASSDLL in Options | Compiler | Code
  605.        Generation | defines combo box.
  606.  
  607.        It could be because you have forced unsigned characters. The
  608.        functions in the .lib take signed characters and thus if you
  609.        compile to use unsigned characters, the symbols will not match.
  610.  
  611.        Using the Integrated Development Environment be sure to turn
  612.        off Options | Compiler | Code Generation | Unsigned Characters.
  613.  
  614.        If you are using the command line compiler be sure to remove
  615.        the -K option to solve this problem.
  616.  
  617.   o  UNDEFINED SYMBOL: 'Object::new(unsigned int)'
  618.      You forgot to link with the TCLASDLL.LIB file where it is
  619.      defined!
  620.  
  621.      Basically the problem is that you are mixing both STATIC and
  622.      DYNAMIC LINK libraries into the application. You must use only
  623.      one or the other. If you are working in the IDE, change the
  624.      LINKER options section for libraries.
  625.  
  626.      If you are using the dynamic link library, remember to set
  627.      _CLASSDLL and Build All.
  628.  
  629.      If you are using the command line compiler and linker, just be
  630.      sure to specify the correct set of library files. For specific
  631.      information on the "correct set of library files" please see the
  632.      documentation included with the product as library names tend to
  633.      change from version to version.
  634.  
  635.  
  636. GETTING A CLOSER LOOK
  637. ---------------------
  638. Borland provides tools that you can use to determine exactly what the
  639. linker is seeing when it is trying to match symbols: TDUMP and IMPDEF.
  640. This section provides some simple techniques for using these utilities
  641. to resolve undefined symbol errors.
  642.  
  643.   o  USING TDUMP TO RESOLVE UNDEFINED SYMBOLS
  644.      TDUMP can be used to list the symbols in a .OBJ or a static .LIB
  645.      that the linker is having trouble matching.
  646.  
  647.      First, TDUMP the module that is trying to reference the symbol.
  648.      For example, if main.cpp is trying to access a function, myfunc()
  649.      in myfuncs.cpp and is getting "Undefined symbol myfunc() in
  650.      module main.cpp",
  651.  
  652.          tdump -m -oiEXTDEF main.obj > main.ext
  653.  
  654.      Then, TDUMP the module in which the symbol is defined.
  655.  
  656.          tdump -m -oiPUBDEF myfuncs.obj > myfunc.pub
  657.  
  658.      Using a text editor find the symbol associated with the error in
  659.      each file. If they are not the same, then you have verified that
  660.      the linker is correct in generating the error. You must check
  661.      your code and verify that the compiler is seeing the same
  662.      declaration for the symbol when each module is being compiled.
  663.  
  664.      You can use TDUMP to look at a static .LIB file the same way you
  665.      look at an .OBJ. file.
  666.  
  667.          tdump -m -oiPUBDEF mystatic.lib > mystatic.pub
  668.  
  669.      To use TDUMP with an implib,
  670.  
  671.          tdump -m -oiTHEADR mydll.lib > mydll.pub
  672.  
  673.      You can also use IMPDEF to view the symbols exported by a DLL.
  674.  
  675.  
  676.   o  USING IMPDEF TO RESOLVE UNDEFINED SYMBOLS IN A DLL
  677.      If you are trying to link a Borland generated DLL with another
  678.      language or product and are getting undefined symbol errors, you
  679.      should verify that the names or the ordinals that are being
  680.      exported by the DLL are the same as your application expects.
  681.  
  682.      This can be done by generating a .DEF file with the utility
  683.      IMPDEF. For example, to create a .DEF file for MY.DLL,
  684.  
  685.         impdef my.def my.dll
  686.  
  687.      The .DEF file will have the exported symbol name and its ordinal
  688.      number. Remember that C++ mangles names. Your application must
  689.      expect the mangled symbol name to call the function in the DLL
  690.      properly. This can be a problem if the application automatically
  691.      uppercases the symbol name before trying to call the function. If
  692.      this is so, you must change the declaration of the function and
  693.      re-build your DLL.
  694.  
  695.  
  696. ===================================================================
  697. 3.  Resolving Undefined Symbol linker messages
  698. ===================================================================
  699. This section provides an overview of the Linking process and helps to
  700. identify causes of 'unresolved external symbols'.
  701.  
  702. The code for printf() is in a module in the run time library. When you
  703. call printf() in a C/C++ module, the compiler creates a record
  704. (referred to as EXTDEF - EXTernal DEFinition) that indicates the call
  705. to an external function. The linker then looks at that OBJ, along with
  706. all the other modules and libraries specified and attempts to find
  707. another module (.OBJ or .LIB) which defines/provides the
  708. symbolprintf().
  709.  
  710. If the linker cannot resolve the call to printf(), the linker
  711. generates an error indicating that printf() is an undefined symbol.
  712. The error message, however, is very often not the result of leaving
  713. out the module containing the symbol being looked for, but rather a
  714. discrepancy between the name used by the caller (the C/C++ module
  715. calling printf() in the case mentioned above) and the supplier (the
  716. LIBRARY containing the code to printf() ).
  717.  
  718. The *real* name of any symbol is almost always different from the
  719. name/identifier used by the programmer. For example, the *real* name
  720. (by *real* name we mean the identifier used/generated by the tools) of
  721. strcpy() is: '_strcpy()'. The *real* name of a symbol depends on the
  722. various settings and options. The relevant settings are list below:
  723.  
  724.   Calling Conventions:
  725.         > cdecl
  726.         > pascal
  727.         > fastcall
  728.  
  729.   Compiler Settings:
  730.         > generate underbars
  731.         > unsigned chars    ( C++ only )
  732.  
  733.   Optimizations:
  734.         > Object Data Calling   ( C++ only )
  735.  
  736.   Virtual Table:
  737.         > Far Virtual Tables
  738.  
  739.   Language used:
  740.         > C
  741.         > C++
  742.         > Assembly
  743.  
  744. Furthermore there are two options which affect how the linker attempts
  745. to match symbols:
  746.  
  747.         > Case sensitive link
  748.         > Case sensitive exports ( Windows only )
  749.  
  750. The following is a discussion of how the above mentioned options
  751. affect the *real* name of symbols, hence the resolution of symbols.
  752.  
  753.  
  754. Calling Conventions
  755. -------------------
  756. Borland and Turbo C++ both allow you to specify the default calling
  757. convention. This default can be overridden by using the
  758. 'pascal', '_fastcall' or 'cdecl' keywords. Whether set globally or on
  759. individual function instances, the calling convention affects the name
  760. of functions. By default, when the compiler encounters a function
  761. declared as,
  762.  
  763.     int Foo( int );    // or: int cdecl Foo( int );
  764.  
  765. the name generated is _Foo; that is, the resulting name has the same
  766. case but is preceded with a leading underscore. The generation of the
  767. underscore is the default behavior and is necessary when you link to
  768. the run time libraries. There is no 'printf()' symbol in the RTL
  769. (!),but there is a '_printf()'.
  770.  
  771. While the C calling convention implies 'Case Sensitivity' and
  772. 'Generation of Underbars', Borland/Turbo C++ provides separate
  773. settings for the generation of underbars and the calling convention
  774. Generation of Underbars can be controlled from the Options | Compiler|
  775. Advanced Code Generation Dialog, or the -u option from the command
  776. line ( -u- would turn it off, it is on by default). The 'Calling
  777. Convention' can be modified via the Options | Compiler |
  778. Entry/ExitCode Dialog.
  779.  
  780. If our function 'Foo' is declared with the pascal modifier, for
  781. example:
  782.  
  783.     int pascal Foo( int );
  784.  
  785. (or if the default 'Calling Convention' is set to 'PASCAL') the
  786. resulting name will be FOO--that is, all upper-case with no
  787. underscore. The '_fastcall' modifier is similar to 'cdecl' in regards
  788. to Case Sensitivity but the underscore character is replaced with '@'.
  789. Hence:
  790.  
  791.     int _fastcall Foo( int );
  792.  
  793. will result in the '@Foo' symbol.
  794.  
  795. Therefore, mismatching the calling conventions might result in
  796. 'Undefined Symbols.' Watch for clues in the undefined symbol name
  797. provided in the Linker error messages (look at the Case Sensitivity
  798. and any leading characters) to spot cases of incorrect settings in the
  799. 'Calling Convention' and/or 'Generation of Underbars'.
  800.  
  801.  
  802. NAME MANGLING:
  803. --------------
  804. The C++ language uses yet another naming convention as part of its
  805. implementation of 'type safe linkage.' Imagine a function myfunc()
  806. which take two longs [void myfunc( long, long );]. What if someone has
  807. it incorrectly prototyped in a calling module as taking two floats,
  808. for example void myfunc( float, float );. The results of such a call
  809. will be unpredictable. When using the C language, the linker would
  810. resolve such a call since the symbol the compiler uses to call the
  811. function taking two floats will be '_myfunc()', and the name the
  812. compiler used in the module which implements the function taking two
  813. longs is also '_myfunc()'.
  814.  
  815. In C++, however, the name the compiler generates for a function is a
  816. 'mangled' name: it is 'encrypted' based on the parameters types the
  817. function expects. In the scenario described in the prior paragraph, the
  818. call to myfunc() will not be resolved since the compiler generates
  819. different names for 'void myfunc( float, float )' and 'void myfunc(
  820. long, long )'.
  821.  
  822. Because a C++ function's mangled real name depends on the types of its
  823. parameters, if unsigned chars is used as a compiler option, it changes
  824. the name of functions declared to take a char, or char *. Unsigned
  825. chars is off by default, it is turned on under the Options |Compiler |
  826. Code generation menu. Or by specifying the -K option with the command
  827. line compiler. Watch out for potential 'Undefined Symbol' messages
  828. caused by a mismatched of char vs. unsigned char.
  829.  
  830. The 'virtual mechanism' of C++ is implemented via a table commonly
  831. referred to as the Virtual Table or the VMT (Virtual Method Table).
  832. Various settings of the Compiler dictate whether the Table ends up in
  833. the Default Data Segment or in a Far Segment (namely Memory
  834. Model, '_export' and 'huge' class modifiers, Virtual Table Control
  835. Optionsetc). To further enforce 'type- safe-linkage', the
  836. Borland/Turbo C++ compilers include the 'distance' of the Virtual Table
  837. as part of its 'Name-Mangling' logic. This prevents the linker from
  838. resolving function calls which would crash at run-time because of
  839. mismatched 'Virtual Table Control' settings. In the same token,
  840. Borland provides the 'Object Data Calling convention' for improved
  841. efficiency of C++ code. Once again, the 'Name-mangling' algorithm also
  842. reflects the enabling of 'Object Data Calling'. This ensures that
  843. function calls involving mismatched 'Object Data Calling' convention
  844. between caller and callee will be caught at link time (instead of
  845. resulting in erratic run-time behavior).
  846.  
  847. To illustrate the effect of 'Virtual Table Control' and 'Object
  848. DataCalling,' let's create a simple class and look at the effects of
  849. the various settings on the resulting names:
  850.  
  851. class  Test
  852. {
  853.      public:
  854.          virtual int Process( void );
  855. };
  856.  
  857. int main( void )
  858. {
  859.      Test t;
  860.      return t.Process();
  861. }
  862.  
  863. The following table illustrates the effects of Compiler Settings on
  864. the *actual* name generated for the member function 'int
  865. Test::Process(void)'.
  866.  
  867.      +----------------------------------------------------------+
  868.      | Object Call. | Far V. Tbl. | Huge Md. |  [ REAL  NAME ]  |
  869.      |--------------+-------------+-----------------------------+
  870.      |      No      |     No      |  No     > @Test@Process$qv  |
  871.      |--------------+-------------+-----------------------------+
  872.      |      No      |     Yes     |  No     > @Test@0Process$qv |
  873.      |--------------+-------------+-----------------------------+
  874.      |      Yes     |     No      |  No     > @Test@1Process$qv |
  875.      |--------------+-------------+-----------------------------+
  876.      |     Yes      |     No      |  Yes    > @Test@2Process$qv |
  877.      +--------------+-------------+-----------------------------+
  878.  
  879. NOTE: Using the '_export' or 'huge' keyword when defining a class
  880.       results in Far Virtual Tables for the class.
  881.  
  882. 'Undefined Symbol Messages' caused by mismatching Virtual Table
  883. Controls or Object Data Calling conventions may be hard to identify; it
  884. is often useful to use TDUMP.EXE to find the actual names of the
  885. unresolved symbols (however, watch out of any '0', '1' or '2' following
  886. the '@ClassName@' portion of the real names).
  887.  
  888.  
  889. LANGUAGE USED
  890. -------------
  891. By default assemblers (including TASM) do not modify public
  892. names--they merely convert symbols to upper case. With TASM, the /mx
  893. option forces the assembler to treat public symbols with case
  894. sensitivity. Without /mx, a call to _myfunc from an assembly module
  895. looks like _MYFUNC to the linker (this causes undefined symbol errors
  896. when linking C and assembly).
  897.  
  898. NOTE: TASM has an extension which causes the automatic generation of
  899. underscores. See. .MODEL <model>, Language directives in the TASM
  900. User's Guide.
  901.  
  902. As previously mentioned in the section about 'Name Mangling,' the
  903. C++ language uses a different naming convention than does the C
  904. language. This can result in undefined symbols when calling C from C++
  905. (or vice-versa). C++ modules should use the 'extern "C"' syntax when
  906. interfacing with C modules (see the Name Mangling section of
  907. Programmer's Guide for the proper syntax).
  908.  
  909.  
  910. LINKER SETTINGS
  911. ---------------
  912. By default, the linker treats _myfunc and _MYFUNC as different
  913. symbols. However, you can control whether the linker pays attention to
  914. Case Sensitivity via the Options | Linker | Settings dialog (IDE), or
  915. the /c option with TLINK (/c: Enables Case Sensitivity [default],
  916. /c-turns the option off).
  917.  
  918. For example, if the option is disabled, a call to _myfunc could be
  919. resolved to _MYFUNC.
  920.  
  921. When creating a Windows application, not only can you link to 'static'
  922. modules (.OBJs or .LIBs which are a collection of .OBJs), but you can
  923. also link to dynamic libraries where the resolution of the call is
  924. completed by Windows at load time. Functions residing in DLLs and
  925. called from an .EXE are said to be imported. Functions that are coded
  926. in an .EXE or .DLL, and are called by either Windows, .EXEs, or .DLLs
  927. are said to be exported.
  928.  
  929. Functions are imported in two ways: by listing them in the IMPORTS
  930. section of the .DEF file, or by linking to an import library. Functions
  931. can be exported by two methods: by using the _export keyword in the
  932. source code or listing the functions in the EXPORTS section of the
  933. .DEF file.
  934.  
  935. Suppose your application calls the symbol _myfunc which is in a
  936. DLL. The linker can treat symbols coming from an import library, or
  937. IMPORTS section of the .DEF file with or without case sensitivity,
  938. (determined by the setting of case sensitive exports under the Options
  939. | Linker | Settings Dialog or /C option on the TLINK command line). If
  940. this setting is NOT enabled, then the Linker treats symbols in import
  941. libs or IMPORTS sections as all uppercase. It then considers upper
  942. case symbols during the link phase. At that point it is doing normal
  943. linking using the setting of the case sensitive link option. If we are
  944. importing both _myfunc and _MYFUNC without the /C option, the linker
  945. can only resolve the call to _MYFUNC.
  946.  
  947. If you are calling _myfunc (a cdecl function) and are performing a
  948. case sensitive link, but do not have case sensitivity on
  949. EXPORTS, _myfunc will show up as undefined.
  950.  
  951.      > Imported cdecl functions and C++ names will link when /c
  952.      > and /C are both enabled, or neither are enabled.
  953.  
  954. C++ names are always generated with lowercase letters. When importing
  955. or exporting C++ names, it's recommended that you use both the /c
  956. and/C options.
  957.  
  958. Now let's apply the above to some common scenarios and provide
  959. possible diagnostics and suggestions:
  960.  
  961.  
  962. PROBLEM:
  963.      All the functions in a 3rd party library are undefined!
  964.  
  965. SOLUTION:
  966.      3rd party libraries must be explicitly linked in. To explicitly
  967.      link to a 3rd party library from the IDE, open a project file and
  968.      insert the .LIB file into the project file. The project file also
  969.      needs to have all of your source code files listed in it. From
  970.      the command line, insert the .LIB on your command line to TLINK.
  971.  
  972.  
  973. PROBLEM:
  974.      All the functions in the RTL are undefined!
  975.  
  976. SOLUTION:
  977.      You need to link in Cx.LIB, where x is the memory model. A
  978.      feature of the IDE in Turbo C++ and Borland C++ v2.x is that if
  979.      you put a .LIB in the project file which starts out as Cx where x
  980.      is a memory model, the new library overrides the normal run time
  981.      library, and the latter will not be linked in (for example, if
  982.      you're using a library named CSERVE.LIB). Rename any such
  983.      libraries, then the normal Cx.LIB will automatically be linked
  984.      in. (Borland C++ 4.x has a dialog for specifying which Run Time
  985.      Libraries should be linked in).
  986.  
  987.  
  988. PROBLEM:
  989.      When mixing C and C++ modules (.c and .cpp source) symbols are
  990.      undefined.
  991.  
  992. SOLUTION:
  993.      Because of name mangling (see above) the symbol the linker sees
  994.      being called from a C++ module will not look like the symbol in
  995.      the Cmodule. To turn name mangling off when prototyping
  996.      functions:
  997.  
  998.      // SOURCE.CPP
  999.  
  1000.      extern "C" {
  1001.           int Cfunc1( void );
  1002.           int Cfunc2( int  );
  1003.      }
  1004.  
  1005. NOTE:  You can also disable name-mangling for functions written in
  1006. C++ and called from C.
  1007.  
  1008. A C++ compile will happen if the source code has a .CPP extension, or
  1009. Options | Compiler | C++ options use C++ compiler is set to always.
  1010.  
  1011.  
  1012. PROBLEM:
  1013.      randomize and other macros are coming up as undefined symbols.
  1014.  
  1015. SOLUTION:
  1016.      Turn keywords to Borland C++. Since some macros are not ANSI
  1017.      compatible, the header files will not define them if compiled
  1018.      with ANSI or UNIX keywords on.
  1019.  
  1020.  
  1021. PROBLEM:
  1022.      min and max are coming up undefined.
  1023.  
  1024. SOLUTION:
  1025.      These macros are only included in a C compile, and will not be
  1026.      seen by the compiler if compiling in C++. In C, you must
  1027.      #include <stdlib.h> to use them.
  1028.  
  1029.  
  1030. PROBLEM:
  1031.      I cannot get my assembly modules to link with my C/C++ program.
  1032.  
  1033. SOLUTION:
  1034.      For C++, see above. Otherwise, the .ASM must be assembled with
  1035.      case sensitivity on public symbols (/mx for TASM). It must also
  1036.      match the C naming convention, which will have an underscore in
  1037.      front of the name. So given the following code in a C module,
  1038.  
  1039.      int myfunc( void );
  1040.  
  1041. you need to
  1042.  
  1043.      call _myfunc
  1044.  
  1045.      from the assembly module. (NOTE: TASM has extensions which will
  1046.      automatically generate underscores for you). Also, make sure the
  1047.      .OBJ which has the assembly code is listed in the project file,
  1048.      or on the tlink line.
  1049.  
  1050.  
  1051. PROBLEM:
  1052.      wsprintf is coming up undefined.
  1053.  
  1054. SOLUTION:
  1055.      In Borland C++ 2.0, to use wsprintf when case sensitive exports
  1056.      is on, you need to reverse a define in windows.h via the
  1057.      following:
  1058.  
  1059.      #ifdef   wsprintf
  1060.      #undef   wsprintf
  1061.  
  1062.      #define  wsprintf wsprintf
  1063.      extern   "C" int FAR cdecl wsprintf( LPSTR, LPSTR, ... );
  1064.      #endif
  1065.  
  1066.      To call wsprintf (or any cdecl imported function ) with case
  1067.      sensitive exports off, you need to match an upper case name. Thus
  1068.      windows.h #defines wsprintf to be WSPRINTF. wsprintf is one of the
  1069.      cdecl functions from windows, so the compiler will generate a
  1070.      lower case symbol for when calling it.
  1071.  
  1072.  
  1073. PROBLEM:
  1074.      FIWRQQ and FIDRQQ are undefined
  1075.  
  1076. SOLUTION:
  1077.      These symbols are in the EMU or FP87 library. You must link it
  1078.      in explicitly when using TLINK, or set the IDE to link it in under
  1079.      the Options | Compiler | Advanced Code Generation Floating point
  1080.      box.
  1081.  
  1082.  
  1083. PROBLEM:
  1084.      Warning attempt to export non-public symbol ...
  1085.  
  1086. SOLUTION:
  1087.      The exports section of the .DEF file has a symbol which does not
  1088.      match one the compiler generated in the source code. This happens
  1089.      if:
  1090.  
  1091.   o  The source was compile in C++ (the symbol name is mangled).
  1092.      Resolve by exporting with the _export keyword, compiling in C,
  1093.      or by declaring the function as extern "C".
  1094.  
  1095.   o  Case sensitive exports is ON, you are exporting a PASCAL
  1096.      function, and exporting it like: WndProc. Resolve by
  1097.      exporting as WNDPROC or by turning case sensitive exports off.
  1098.  
  1099.   o  You are exporting a cdecl function. If declared as
  1100.          int myfunc( void );
  1101.      export as _myfunc and turn case sensitive exports on (or
  1102.      just use the _export keyword).
  1103.  
  1104.      NOTE: When using the '_export' keyword, it must be used in
  1105.            the prototype of the function. For example:
  1106.                int FAR _export myfunc( int );
  1107.  
  1108.  
  1109. PROBLEM:
  1110.      C++ and DLL linking problems.
  1111.  
  1112. SOLUTION:
  1113.      Classes declared in the DLL need to be declared as the following:
  1114.  
  1115.      class _export A
  1116.      {
  1117.         ...
  1118.      };
  1119.  
  1120.      When defined in the EXE, the same must be prototyped as:
  1121.  
  1122.      class huge A
  1123.      {
  1124.           ...
  1125.      };
  1126.      // see User's Guide for more information
  1127.  
  1128.      Then link with /c and /C on (both case sensitive link and case
  1129.      sensitive exports ENABLED) when building BOTH the .DLL and the
  1130.      calling.EXE.
  1131.  
  1132.  
  1133. PROBLEM:
  1134.      OWL and undefined symbols.
  1135.  
  1136. SOLUTION:
  1137.      If you're linking to the static libraries:
  1138.           - with BC 2.0, link in owlwx.lib, tclasswx.lib, and
  1139.             sallocwx.lib. (You don't need sallocwx.lib with BC
  1140.             v 3.x ).
  1141.  
  1142.           - do NOT define _CLASSDLL in the code generation
  1143.             dialog, or before including owl.h.
  1144.  
  1145.           - link with /c and /C. (from IDE, under linker
  1146.             options, case sensitive link and case sensitive
  1147.             exports).
  1148.  
  1149.           - Do NOT compile with -K or unsigned char's on. You
  1150.             will get several undefined symbols in this case.
  1151.  
  1152.      If you're linking to the OWL .DLL, DO define _CLASSDLL before
  1153.      including OWL.H, and use /c and /C linker options (both Case
  1154.      Sensitive Link and Case Sensitive Exports ENABLED).
  1155.  
  1156.  
  1157. PROBLEM:
  1158.      With an OWL application, wsprintf is undefined in module when
  1159.      linking to the static libraries.
  1160.  
  1161. SOLUTION:
  1162.      Link with /C (case sensitive exports ENABLED).
  1163.  
  1164.  
  1165. PROBLEM:
  1166.      _main is an undefined symbol.
  1167.  
  1168. SOLUTION:
  1169.      main is the entry point for every DOS C/C++ program. Make sure
  1170.      you write a function called main (all lowercase) in your program.
  1171.      If you have a project file loaded, make sure your source code
  1172.      file (.c or .cpp file) which has main in it is listed in the .prj
  1173.      file. Make sure generate underbars is turned on.
  1174.  
  1175.  
  1176. PROBLEM:
  1177.      iostream members, like << operator are undefined
  1178.  
  1179. SOLUTION:
  1180.      Turn options | compiler | code generation | unsigned chars off
  1181.      (do not use -K on the command line).
  1182.  
  1183.  
  1184. PROBLEM:
  1185.      Getting undefined symbols LLSH, SCOPY FMUL, FDIV, etc
  1186.  
  1187. SOLUTION:
  1188.      Many of the helper functions have changed names from Turbo C
  1189.      2.0 to Borland C++. This functions were called from Turbo C 2.0.
  1190.      The solution is to recompile any .OBJ or .LIB them with Borland
  1191.      C++.
  1192.  
  1193.  
  1194. SNOOPING AT THE REAL NAMES:
  1195. ---------------------------
  1196. An .OBJ file is a collection of records. When you call a function or
  1197. reference a symbol not defined in your module, the compiler generates
  1198. an external definition record in the OBJ. This external definition
  1199. record has the symbol which the linker must resolve. When you define a
  1200. function, or make storage for some data, the compiler generates a
  1201. public definition record for that module (unless you declared the item
  1202. as static, that makes it private to that module). One of the tasks of
  1203. the Linker is to match Public Definitions and External
  1204. Definitions(PUBDEFs and EXTDEFs).
  1205.  
  1206. To see the symbols the LINKER has to deal with, use TDUMP.EXE provided
  1207. with the Borland C++ package. For example:
  1208.  
  1209.     tdump -m -oiEXTDEF some.obj
  1210.  
  1211. The above shows all the EXTDEF (external definition) records in an .OBJ
  1212. file. Be sure to add the -m option when coding in C++.
  1213.  
  1214.     tdump -m -oiPUBDEF some.obj
  1215.  
  1216. The above will display all the PUBDEF (public definition) records.
  1217.  
  1218. Let's assume you've purchased a third party library and a symbol
  1219. provided the library is unresolved; the possible steps in
  1220. identifying the problem could include:
  1221.  
  1222.      - Create a Listing of symbols in the Library using TLIB. For
  1223.        example:
  1224.           TLIB NEWLIB.LIB, NEWLIB.LST
  1225.  
  1226.      - TDUMP the .OBJ file which was created from the .C/.CPP
  1227.        module calling the desired function.
  1228.           TDUMP  -m -oiEXTDEF MYCODE.OBJ MYCODE.LST
  1229.  
  1230.      - Attempt to find any discrepancies between the name in
  1231.        NEWLIB.LST and the one in MYCODE.LST and ascertain that
  1232.        the Library does indeed provide the desired function.
  1233.  
  1234. Windows Programmers will find the IMPDEF.EXE utility (in addition to
  1235. TDUMP and TLIB) a very useful tool to help identify unresolved symbols
  1236. when DLLs and/or Import Libraries are involved.
  1237.  
  1238.  
  1239. ===================================================================
  1240. 4.  Borland Open Architecture:  Name Mangling
  1241. ===================================================================
  1242. There are four basic forms of encoded names in Borland C++:
  1243.  
  1244. 1. @className@functionName$args
  1245.  
  1246. This encoding denotes a member function Name belonging to
  1247. class Name and having arguments args.
  1248.  
  1249. Class names are encoded directly. The following example shows a
  1250. className in an encoded name:
  1251.  
  1252.       @className@...
  1253.  
  1254. The class name may be followed by a single digit; the digit value
  1255. contains the following bits (these can be combined):
  1256.  
  1257.     0x01 : the class uses a far vtable
  1258.  
  1259.     0x02 : the class uses the -po calling convention
  1260.  
  1261.     0x04 : the class has an RTTI-compatible virtual table; this bit is
  1262.            only used when encoding the name of the virtual table for
  1263.            the class
  1264.  
  1265. The digit is encoded as an ASCII representation of the bit mask
  1266. value, with 1 subtracted (so that, for example, the class prefix for a
  1267. class 'myfunc' that uses far vtables would be '@myfunc@0').
  1268.  
  1269. See the next section on the encoding of function names and argument
  1270. types.
  1271.  
  1272. 2. @functionName$args
  1273.  
  1274. This form of encoding denotes a function functionName with arguments
  1275. args.
  1276.  
  1277. 3. @className@dataMember
  1278.  
  1279. This form of encoding denotes a static data member dataMember
  1280. belonging to class className. Names of classes and data members are
  1281. encoded directly. The following example shows a member myMember in
  1282. class myClass:
  1283.  
  1284.       @myClass@myMember
  1285.  
  1286. 4. @className@
  1287.  
  1288. This name denotes a virtual table for a class className. As mentioned
  1289. previously, class names are encoded directly.
  1290.  
  1291.  
  1292. Encoding of nested and template classes
  1293. ---------------------------------------
  1294. The following form encodes a name of a class lexically nested within
  1295. another class:
  1296.  
  1297.   @outer@inner@...
  1298.  
  1299. A template instance class encodes the name of the template class, along
  1300. with the actual template arguments, in the following way:
  1301.  
  1302.   %templateName$arg1$arg2 ..... $argn%
  1303.  
  1304. Each actual argument starts with a letter, specifying the kind of
  1305. argument it is:
  1306.  
  1307.   o  t type argument
  1308.  
  1309.   o  i nontype integral argument
  1310.  
  1311.   o  g nontype nonmember pointer argument
  1312.  
  1313.   o  m nontype member pointer argument
  1314.  
  1315. The first letter is followed by the encoded type of the argument. For
  1316. a type argument, this code also represents the argument's actual
  1317. value. For other kinds of arguments, the type code is followed by $and
  1318. the argument value, encoded as an ASCII number or symbol name. An
  1319. instance of template<class T, int size> whose name is
  1320. vector<long,100>is encoded as shown in the following example:
  1321.  
  1322.   %vector$tl$ii$100%
  1323.  
  1324.  
  1325. Encoding of function names
  1326. --------------------------
  1327. The encoded function Name might denote either a function name, a
  1328. function such as a function such as a constructor or destructor, an
  1329. overloaded operator, or a type conversion.
  1330.  
  1331.  
  1332. Ordinary functions
  1333. ------------------
  1334. Ordinary function names are encoded directly, as shown in the
  1335. following examples:
  1336.  
  1337.   foo(int) --> @foo$qi sna::foo(void) --> @sna@foo$qv
  1338.  
  1339. The string $qi denotes the integer argument of function myfunc();'$qv'
  1340. denotes no arguments in sna::myfunc.
  1341.  
  1342.  
  1343. Constructors, destructors, and overloaded operators
  1344. ---------------------------------------------------
  1345. The following information covers argument encoding in more
  1346. detail. Constructors, destructors, and overloaded operators encoded
  1347. with a $bcharacter sequence, followed by a character sequence from the
  1348. following table:
  1349.  
  1350.             Character        Meaning Sequence
  1351.             _________________________________
  1352.  
  1353.             ctr              constructor
  1354.             dtr              destructor
  1355.             add              +
  1356.             adr              &
  1357.             and              &
  1358.             arow             ->
  1359.             arwm             ->*
  1360.             asg              =
  1361.             call             ()
  1362.             cmp              ~
  1363.             coma             ,
  1364.             dec              --
  1365.             dele             delete
  1366.             div              /
  1367.             eql              ==
  1368.             geq              >=
  1369.             gtr              >
  1370.             inc              ++
  1371.             ind              *
  1372.             land             &&
  1373.             lor              ||
  1374.             leq              <=
  1375.             lsh              <<
  1376.             lss              <
  1377.             mod              %
  1378.             mul              *
  1379.             neq              !=
  1380.             new              new
  1381.             not              !
  1382.             or               |
  1383.             rand             &=
  1384.             rdiv             /=
  1385.             rlsh             <<=
  1386.             rmin             -=
  1387.             rmod             %=
  1388.             rmul             *=
  1389.             ror              |=
  1390.             rplu             +=
  1391.             rrsh             >>=
  1392.             rsh              >>
  1393.             rxor             ^=
  1394.             sub              -
  1395.             subs             []
  1396.             xor              ^
  1397.             nwa              new[]
  1398.             dla              delete []
  1399.             __________________________________
  1400.  
  1401. The following examples show how arguments are encoded with character
  1402. sequences, add, ctr, and dtr from the previous table:
  1403.  
  1404.   operator+(int)  -->     @$badd$qi plot::plot() --> @plot@$bctr$qv
  1405.   plot::~plot()   --> @plot@$bdtr$qv
  1406.  
  1407. The string $qv denotes no arguments in the plot constructor or
  1408. destructor.
  1409.  
  1410.  
  1411. Type conversions
  1412. ----------------
  1413. Encoding of type conversions accomplished with the $o character
  1414. sequence, followed by distinguishing return type of the conversion as
  1415. part of function name. The return type follows the rules for argument
  1416. encoding, explained later. The lack of arguments in one version is
  1417. made explicit in the mangling by adding $qv the end of the encoded
  1418. string.
  1419.  
  1420. Example:
  1421.  
  1422.   myfunc::operator int() --> @myfunc@$oi$qv myfunc::operator char *()
  1423.   -->     @myfunc@$opzc$qv
  1424.  
  1425. The i following $o in the first example denotes int; the pzc in the
  1426. second example denotes a near pointer to an unsigned char.
  1427.  
  1428.  
  1429. Encoding of arguments
  1430. ----------------------
  1431. The number and combinations of function arguments make argument
  1432. encoding the most complex aspect of name mangling.
  1433.  
  1434. Argument lists for functions begin with the characters $q. Type
  1435. qualifiers are then encoded as shown in the following table:
  1436.          _____________________________
  1437.  
  1438.           Character   Meaning Sequence
  1439.          _____________________________
  1440.  
  1441.            up          huge
  1442.            ur          _seg
  1443.            u           unsigned
  1444.            z           signed
  1445.            x           const
  1446.            w           volatile
  1447.            ____________________________
  1448.  
  1449. Encoding of built-in types follows that for applicable type
  1450. qualifiers, in accordance with the following table:
  1451.  
  1452.            ______________________________
  1453.  
  1454.              Character   Meaning Sequence
  1455.            ______________________________
  1456.  
  1457.              v           void
  1458.              c           char
  1459.              s           short
  1460.              i           int
  1461.              l           long
  1462.              f           float
  1463.              d           double
  1464.              g           long double
  1465.              e           ...
  1466.            ______________________________
  1467.  
  1468. Encoding of non-built-in types follows that for applicable type
  1469. qualifiers, in accordance with the following table:
  1470.  
  1471.          ______________________________
  1472.  
  1473.            Character   Meaning Sequence
  1474.          ______________________________
  1475.  
  1476.            <a digit>   (an enumeration or class name)
  1477.            p           near *
  1478.            r           near &
  1479.            m           far &
  1480.            n           far *
  1481.            a           array
  1482.            M           member pointer (followed by class and
  1483.                        base type)
  1484.            ______________________________
  1485.  
  1486. The appearance of one or more digits indicates that an enumeration or
  1487. class name follows; the value of the digit(s) denotes the length of
  1488. the name, as shown in the following examples:
  1489.  
  1490.   foo::myfunc(myClass near&)      is mangled as @foo@myfunc$qr7myClass
  1491.   foo::myfunc(anotherClass near&) is mangled as
  1492.   @foo@myfunc$qr12anotherClass
  1493.  
  1494. A character x or w may appear after p, r, m, or n to denote a constant
  1495. or volatile type qualifier, respectively. The character q appearing
  1496. after one of these characters denotes a function with arguments the
  1497. follow in the encoded name, up to the appearance of a $ character, and
  1498. finally a return type is encoded. The following example show how these
  1499. encoding rules are applied:
  1500.  
  1501.   @foo@myfunc$qpxzc      is mangled as foo::myfunc(const char near*)
  1502.   @func1$qxi is mangled as   func1(const int) @foo@myfunc$qpqii$i is
  1503.   mangled as foo:myfunc(int (near*)(int,int))
  1504.  
  1505. Array types are encoded as a, followed by a dimension encoded as an
  1506. ASCII decimal number and a $, and finally the element type, as shown
  1507. in the following example.
  1508.  
  1509.   myfunc( int (*x)[20] )    is mangled as @myfunc$qpa20$i
  1510.  
  1511. Encoded arguments are concatenated in the order of appearance in the
  1512. function call. The character t followed by an ASCII character encodes
  1513. the arguments when a number of identical non-builtin types are
  1514. function arguments. The ASCII character, ranging from ASCII 31H -
  1515. 39Hand 61H - 7FH (1 to 9 and a onward), denotes which argument type to
  1516. duplicate, as shown in the following example:
  1517.  
  1518.   @plot@func1$qdddiiilllpzctata is unmangled to plot::func1(double,
  1519.           double, double, int, int, int, long, long, long, char near*,
  1520.           char near*, char near*)
  1521.  
  1522. The two duplicate ta character sequences at the end of the encoded
  1523. name denote the tenth argument, encoded as pzc.
  1524.  
  1525. /*************************************************************************/
  1526.  
  1527.