Click here to Skip to main content
15,912,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionprint problem Pin
Y_Kaushik22-Jun-07 20:43
Y_Kaushik22-Jun-07 20:43 
AnswerRe: print problem Pin
MANISH RASTOGI22-Jun-07 21:58
MANISH RASTOGI22-Jun-07 21:58 
GeneralRe: print problem Pin
Y_Kaushik22-Jun-07 22:09
Y_Kaushik22-Jun-07 22:09 
QuestionInstaller created shortcut Pin
rp_suman22-Jun-07 16:41
rp_suman22-Jun-07 16:41 
QuestionQueryPerformanceCounter - unreliable timing on win32 but perfect on x64 [modified] Pin
Cyrilix22-Jun-07 16:34
Cyrilix22-Jun-07 16:34 
QuestionHow to share a class between different projects in VC++? Pin
Skywalker200822-Jun-07 11:34
Skywalker200822-Jun-07 11:34 
AnswerRe: How to share a class between different projects in VC++? Pin
Hans Dietrich22-Jun-07 12:10
mentorHans Dietrich22-Jun-07 12:10 
GeneralRe: How to share a class between different projects in VC++? Pin
Cyrilix22-Jun-07 12:32
Cyrilix22-Jun-07 12:32 
Adding on to what Hans said, you can also export the necessary functions that you need from another class (or the entire class itself) via __declspec(dllexport) and import them from the class where you want to use them with __declspec(dllimport), provided your compiler supports these keywords (MSVC does). One way you can do this is through the following:

//TheClass.h

#ifndef _EXPORT
#define THEAPI __declspec(dllimport)
#else
#define THEAPI __declspec(dllexport)
#endif

class THEAPI TheClass
{
   //prototype of class TheClass here
};


There are a few things you have to do:
1 - Define _EXPORT in the project that you want to export, and don't define _EXPORT in the project where you want to import the class/functions (this can be changed in VC++ project settings under preprocessors).
2 - Include TheClass.h from your main project, where you want to call the functions.
3 - Link with the .lib generated by the exported project from the project where you want to import (these .lib do not contain the full information, only how to link with the DLL).

I believe the above is known as static linking with DLLs, and you must package the DLLs with your executable on deployment. Static linking with the standard .lib will group everything in the .lib with your executable, which is why you can only distribute the executable.

One other way you can link (again with DLLs) is through the use of GetProcAddress() and LoadLibrary() to dynamically load DLLs during runtime, but for the sake of keeping it simple, you might want to just stick with Hans' suggestion or my suggestion above.
GeneralRe: How to share a class between different projects in VC++? Pin
Mark Salsbery22-Jun-07 12:50
Mark Salsbery22-Jun-07 12:50 
GeneralRe: How to share a class between different projects in VC++? Pin
Cyrilix22-Jun-07 14:00
Cyrilix22-Jun-07 14:00 
GeneralRe: How to share a class between different projects in VC++? Pin
Mark Salsbery22-Jun-07 14:06
Mark Salsbery22-Jun-07 14:06 
GeneralRe: How to share a class between different projects in VC++? Pin
Skywalker200825-Jun-07 2:50
Skywalker200825-Jun-07 2:50 
QuestionHow to load a BMP from a resource dll Pin
sstainba22-Jun-07 10:07
sstainba22-Jun-07 10:07 
AnswerRe: How to load a BMP from a resource dll Pin
Mark Salsbery22-Jun-07 10:25
Mark Salsbery22-Jun-07 10:25 
GeneralRe: How to load a BMP from a resource dll Pin
sstainba22-Jun-07 11:22
sstainba22-Jun-07 11:22 
GeneralRe: How to load a BMP from a resource dll Pin
Mark Salsbery22-Jun-07 12:26
Mark Salsbery22-Jun-07 12:26 
GeneralRe: How to load a BMP from a resource dll Pin
sstainba22-Jun-07 12:32
sstainba22-Jun-07 12:32 
GeneralRe: How to load a BMP from a resource dll Pin
Mark Salsbery22-Jun-07 12:46
Mark Salsbery22-Jun-07 12:46 
GeneralRe: How to load a BMP from a resource dll Pin
sstainba22-Jun-07 12:51
sstainba22-Jun-07 12:51 
GeneralRe: How to load a BMP from a resource dll Pin
Mark Salsbery22-Jun-07 12:59
Mark Salsbery22-Jun-07 12:59 
GeneralRe: How to load a BMP from a resource dll Pin
sstainba22-Jun-07 13:11
sstainba22-Jun-07 13:11 
GeneralRe: How to load a BMP from a resource dll Pin
Mark Salsbery22-Jun-07 13:20
Mark Salsbery22-Jun-07 13:20 
GeneralRe: How to load a BMP from a resource dll Pin
sstainba22-Jun-07 13:22
sstainba22-Jun-07 13:22 
GeneralRe: How to load a BMP from a resource dll Pin
Mark Salsbery22-Jun-07 13:31
Mark Salsbery22-Jun-07 13:31 
GeneralRe: How to load a BMP from a resource dll Pin
Mark Salsbery22-Jun-07 13:30
Mark Salsbery22-Jun-07 13:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.