Resolving link errors in Win32

Note: this doc assumes that you have access to the SmartHeap Getting Started Guide for Win32

The goal is to successfully link your application or DLL to SmartHeap. The Getting Started Guide (GSG) gives you two different paths to this goal:

  • The “quick start” procedure described in the GSG under the heading “Quick Start” (see the table of contents)
  • A somewhat more involved procedure where you specify a SmartHeap library in the VC++ Project/Settings/Link dialog (or the appropriate property page in VC++ 7) . This procedure is described in the GSG under the headings “Setting up your application for the SmartHeap runtime library” (for release builds) and “Debugging an application with SmartHeap” (for debug builds).

If you’re reading this, then presumably one of the above procedures didn’t work for you. In that case, here’s what you can do:

If you got link errors when you used the ‘Quick Start’ procedure, try this

If you got link errors when you listed a SmartHeap lib on the Link dialog Object/library modules line (Property Page in VC++ 7), try this


If you got link errors when you used the ‘Quick Start’ procedure...

  1. Undo the changes you made to stdafx.cpp as part of the quick start procedure.
  2. Open the file stdafx.h. At the top of that file, before any #include statements, add the text
  3. #include "[SHFILE]", where [SHFILE] is the file that quick start instructed you to #include in stdafx.cpp
  4. Save your changes to stdafx.h
  5. Choose Rebuild All from the Build menu
  6. Repeat the Rebuild All command for both Release and Debug project configurations.

Note that this procedure is just ‘quick start’, but you’re using stdafx.h instead of stdafx.cpp. If you still get link errors, see the next paragraph.

Linking the old fashioned way:

Quick Start is the procedure we recommend, but if it just won’t work for you then you should be able to link using the following procedure:

  1. Undo any changes you made to your project (modifications to stdafx.h, etc) to support the quick start procedure.
  2. Use the tables in the GSG to determine which SmartHeap lib(s) your application should be linked to. These tables are found under the heading “Setting up the Visual C++ project file”; there are separate tables for runtime and debug builds.
  3. If you’re using VC++ versions 5 or 6,  open the Project/Settings/Link dialog. At the front of the Object/library modules line, before any other libs, list the SmartHeap libs that you want to use. Then, still in the Link dialog, change to “Input” category. On the Force symbol references line put these two symbols: SmartHeap_malloc SmartHeap_new. If you're using MFC, and if you're trying to link to SmartHeap 7 or later, also put SmartHeap_mfc on the force symbol references line.
  4. If you’re using VC++ version 7 or 8, open the property page for your configuration. Click the Linker folder, then the Input property page, and add the SmartHeap libs you want to use to the front of the Additional Dependencies property input line. On the same Input page, add _SmartHeap_malloc and _SmartHeap_new to the Force symbol references property (for 64-bit windows, drop the initial underscore: SmartHeap_malloc and SmartHeap_new).
  5. Rebuild. <Top>


 

 

If you got link errors when you listed a SmartHeap lib on the Link dialog Object/library modules line

  1. Check that you have not applied to your project any of the changes required to use the ‘quick start’ linking procedure (such as modifying stdafx.cpp, adding smrtheap.c to the project, et al)
  2. Check that you are linking to the correct SmartHeap lib(s) for your configuration. Note that SmartHeap has separate libs for debug and release builds.
  3. If you’re using VC++ versions 5 or 6,  open the Project/Settings/Link dialog. Change to “Input” category. On the Force symbol references line put _SmartHeap_malloc
  4. If you’re using VC++ version 7 or 8, open the property page for your configuration. Click the Linker folder, then the Input property page, and add SmartHeap_malloc and SmartHeap_new to the Force symbol references property.
  5. Rebuild.

If these procedures do not resolve the link error, then trying linking using Quick Start. Before you apply Quick Start, be sure to remove the SmartHeap lib(s) from the Link dialog’s Object/library modules line. <Top>