Show: Object Pascal C++
Display Preferences

E2172 Necessary library helper function was eliminated by linker (%s) (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

The integrated debugger is attempting to use some of the compiler helper functions to perform the requested evaluate. The linker, on the other hand, determined that the helper function was not actually used by the program and it did not link it into the program.

  1. Create a new application.
  2. Place a button on the form.
  3. Double click the button to be taken to the 'click' method.
  4. Add a global variable, 'v', of type String to the interface section.
  5. Add a global variable, 'p', of type PChar to the interface section.

The click method should read as:

  1. procedure TForm1.Button1Click(Sender: TObject); begin v := 'Initialized'; p := NIL; v := 'Abid'; end;
  2. Set a breakpoint on the second assignment to 'v'.
  3. Compile and run the application.
  4. Press the button.
  5. After the breakpoint is reached, open the evaluator (Run|Evaluate/Watch).
  6. Evaluate 'v'.
  7. Move the cursor to the 'New Value' box.
  8. Type in 'p'.
  9. Choose Modify.

The compiler uses a special function to copy a PChar to a String. In order to reduce the size of the produced executable, if that special function is not used by the program, it is not linked in. In this case, there is no assignment of a PChar to a String, so it is eliminated by the linker.


  procedure TForm1.Button1Click(Sender: TObject);
  begin
       v := 'Initialized';
       p := NIL;
       v := 'Abid';
       v := p;
  end;

Adding the extra assignment of a PChar to a String will ensure that the linker includes the desired procedure in the program. Encountering this error during a debugging session is an indicator that you are using some language/environment functionality that was not needed in the original program.

Personal tools
In other languages