Board index » Visual Studio » Help! About MFC linking setting:-(

Help! About MFC linking setting:-(

Visual Studio277
There is a workspace including two MFC projects.

One of the MFC projects creates EXE, the other one creates DLL. And the EXE

project

depends the DLL one. The exe project and the dll project both use MFC in a

static library.

But when the dll project is created as a MFC extention DLL(using shared MFC

DLL),

the program can not be complied.

I tried to set the EXE project to use MFC in a shared DLL and the DLL

project to use MFC

in a static library. And the projects was complied successfully and the

program can run in

the OS without MFC dlls.

Why? How?

Thanks.


-
 

Re:Help! About MFC linking setting:-(

IIRC, you cannot have static linked MFC extension DLL. This is by design. What are you

trying to achieve and why do you want to statically link to MFC? This could lead to

problems if you have multiple modules all statically linked to their own MFC library. In

an MFC extension dll, you can shared resources etc. If you dont have any strong

requirements of being an extension dll, perhaps you want a Regular DLL.



--

Ajay Kalra [MVP - VC++]

ajaykalra@yahoo.com





"Bill Gates" <billgates@microsoft.com>wrote in message

| There is a workspace including two MFC projects.

| One of the MFC projects creates EXE, the other one creates DLL. And the EXE

| project

| depends the DLL one. The exe project and the dll project both use MFC in a

| static library.

| But when the dll project is created as a MFC extention DLL(using shared MFC

| DLL),

| the program can not be complied.

| I tried to set the EXE project to use MFC in a shared DLL and the DLL

| project to use MFC

| in a static library. And the projects was complied successfully and the

| program can run in

| the OS without MFC dlls.

| Why? How?

| Thanks.

|

|



-

Re:Help! About MFC linking setting:-(

Thanks, it's a history problem why I used a extention MFC DLL. I should

select the regular DLL.

But I'm still puzzled. Why can the program run well when the exe project use

MFC in a shared DLL and the

DLL project use MFC in a static library(There is not any MFC dll in the OS)?

Some other programs such

as BCG are created as extention MFC DLL too. What purposes are they designed

like that for?





-

Re:Help! About MFC linking setting:-(

If you have two versions of MFC in memory(the way you have described), you will run into

problems when you try to access any data that is static to the library. In addition,

depending upon what you are doing, your objects would be created in two separte MFC

modules.This may or may not be a big deal depending upon what you are doing in MFC.



I have been using MFC for over 10 years now, and I have never had the need to link MFC

statically. Its specially fatal if your MFC app is extensible and other apps written on

top of your app link to MFC statically.



--

Ajay Kalra [MVP - VC++]

ajaykalra@yahoo.com





"Bill Gates" <billgates@microsoft.com>wrote in message

| Thanks, it's a history problem why I used a extention MFC DLL. I should

| select the regular DLL.

| But I'm still puzzled. Why can the program run well when the exe project use

| MFC in a shared DLL and the

| DLL project use MFC in a static library(There is not any MFC dll in the OS)?

| Some other programs such

| as BCG are created as extention MFC DLL too. What purposes are they designed

| like that for?

|

|



-