Hi,

i have created dll and lib files using vc++ 6.0..

how can i use this files in my program....
i want to know how to link the lib and dll file in which ever program i want using vc++ 6.0
please help.....


thank you....

Dani AI

Generated

Good follow-up for — building on ’s pointer, here are practical VC++ 6.0 steps and troubleshooting tips that go a bit deeper than the thread so far.

When you build a DLL in VC6 you usually get an import .lib plus the .dll. To consume it from another project, add the .lib in Project → Settings → Link → Object/library modules and make the DLL’s header available in Project → Settings → C/C++ → Preprocessor (or put the .lib in the project folder). If you prefer the other route mentioned earlier in the thread, the pragma technique is an alternative to listing the .lib in project settings.

Use an export/import macro in the shared header so the same header works for both DLL build and client use:

/* shared header */
#ifdef MYDLL_EXPORTS
#define MYAPI __declspec(dllexport)
#else
#define MYAPI __declspec(dllimport)
#endif

extern "C" MYAPI int Add(int a, int b);

If you want to avoid link-time dependency on the .lib, load the DLL at run-time with LoadLibrary/GetProcAddress; that gives you control when and where the DLL is loaded:

HMODULE h = LoadLibrary("MyDll.dll");
if (h) {
  typedef int (*PFADD)(int,int);
  PFADD pAdd = (PFADD)GetProcAddress(h,"Add");
  if (pAdd) { int r = pAdd(1,2); }
  FreeLibrary(h);
}

Quick troubleshooting checklist:

  • If you get unresolved externals, verify the client is linking the correct .lib and that function signatures (calling convention) match.
  • Use dumpbin /exports yourdll.dll (or Dependency Walker) to inspect exported names — name-mangling will break C++ symbol lookup unless you use extern "C".
  • Match runtime library settings (CRT) between DLL and EXE to avoid heap/CRT conflicts.
  • Avoid exporting STL types or C++ classes across the DLL boundary; prefer plain C-style APIs or factory functions.

These steps address common VC6 pitfalls and should make linking and runtime usage more reliable.

Recommended Answers

All 2 Replies

You don't link the dll -- only the *.lib. One way to do it is by using pragma #pragma comment(lib,"mydll.lib") Replace mydll.lib with whatever you named it.

You will have to put the dll in either the program's current working directory or one of the folders specified in the PATH environment variable.

You don't link the dll -- only the *.lib. One way to do it is by using pragma #pragma comment(lib,"mydll.lib") Replace mydll.lib with whatever you named it.

You will have to put the dll in either the program's current working directory or one of the folders specified in the PATH environment variable.

thank you............

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.