15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Can't get OCX to statically link MFC libs

Chris W. Rea UL -- cwrea@interlog.com
Tuesday, November 12, 1996


Environment: Windows NT 4.0WS (SP1), Visual C++ 4.2b (Enterprise Edition)


I want to create an OCX that statically links in both MFC and the C runtime
library. However, I can't coerce VC++ into doing this for me, no matter what
I try. Here's what I tried to do.

I cooked up a totally vanilla OCX with the Control Wizard (just walking through
and clicking "next" and then "finish", with no changes made to the defaults.)
I made absolutely no changes to the code generated by the wizard.

Under Build/Settings for the Win32 Release project, under the General tab,
I switched to "Use MFC in a Static Library", and similarly, under the C/C++
tab, in the Code Generation section, I changed it to "Multithreaded" instead
of "Multithreaded DLL."

Then I tried to build the project.

The linker gives 115 unresolved external errors, including the following
ones, for example.

[...]
STATIC.obj : error LNK2001: unresolved external symbol "int __stdcall AfxOleRegisterTypeLib(struct HINSTANCE__ *,struct _GUID const &,char const *,char const *)"(?AfxOleRegisterTypeLib@@YGHPAUHINSTANCE__@@ABU_GUID@@PBD2@Z)
STATIC.obj : error LNK2001: unresolved external symbol "int __stdcall AfxOleUnregisterTypeLib(struct _GUID const &,unsigned short,unsigned short,unsigned long)"(?AfxOleUnregisterTypeLib@@YGHABU_GUID@@GGK@Z)
STATICCtl.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_EVENTMAP const  COleControl::eventMap"(?eventMap@COleControl@@1UAFX_EVENTMAP@@B)
STATICCtl.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const  COleControl::messageMap"(?messageMap@COleControl@@1UAFX_MSGMAP@@B)
STATICCtl.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const  COleControl::classCOleControl"(?classCOleControl@COleControl@@2UCRuntimeClass@@B)
STATICCtl.obj : error LNK2001: unresolved external symbol "int __stdcall AfxOleRegisterControlClass(struct HINSTANCE__ *,struct _GUID const &,char const *,unsigned int,unsigned int,int,unsigned long,struct _GUID const &,unsigned short,unsigned short)"(?AfxOleRegisterControlClass@@YGHPAUHINSTANCE__@@ABU_GUID@@PBDIIHK1GG@Z)
STATICCtl.obj : error LNK2001: unresolved external symbol "int __stdcall AfxOleUnregisterClass(struct _GUID const &,char const *)"(?AfxOleUnregisterClass@@YGHABU_GUID@@PBD@Z)
[...]


What am I doing wrong? How can I get Control Wizard .OCX projects to statically
link both the MFC and runtime libraries? Is this possible?

Regards to all,


 [ CHRIS W. REA, B.Sc.  U. of T. CompSci/Math 9T6 ]
 [ work: cwrea@glrd.com  play: cwrea@interlog.com ]





Scott Colestock -- Scoles@msn.com
Thursday, November 14, 1996

[Mini-digest: 3 responses]

I believe you will find that the OLE Control support is not present in the MFC 
static libraries at all - it is #ifdef'd out for that build.  Controls must 
dynamically link to MFC.  This is consistent with OCXs' design point of being 
lightweight - you wouldn't want to pull in several megabyte-sized controls 
when instantiating a dialog, for instance.  (But I have run into the same pain 
when a large existing build environment is set up exclusively for static 
linking.)

- Scott Colestock

-------------------
Environment: Windows NT 4.0WS (SP1), Visual C++ 4.2b (Enterprise Edition)


I want to create an OCX that statically links in both MFC and the C runtime
library. However, I can't coerce VC++ into doing this for me, no matter what
I try. Here's what I tried to do.

I cooked up a totally vanilla OCX with the Control Wizard (just walking 
through
and clicking "next" and then "finish", with no changes made to the defaults.)
I made absolutely no changes to the code generated by the wizard.

Under Build/Settings for the Win32 Release project, under the General tab,
I switched to "Use MFC in a Static Library", and similarly, under the C/C++
tab, in the Code Generation section, I changed it to "Multithreaded" instead
of "Multithreaded DLL."

Then I tried to build the project.

The linker gives 115 unresolved external errors, including the following
ones, for example.

[...]
STATIC.obj : error LNK2001: unresolved external symbol "int __stdcall 
AfxOleRegisterTypeLib(struct HINSTANCE__ *,struct _GUID const &,char const 
*,char const *)"(?AfxOleRegisterTypeLib@@YGHPAUHINSTANCE__@@ABU_GUID@@PBD2@Z)
STATIC.obj : error LNK2001: unresolved external symbol "int __stdcall 
AfxOleUnregisterTypeLib(struct _GUID const &,unsigned short,unsigned 
short,unsigned long)"(?AfxOleUnregisterTypeLib@@YGHABU_GUID@@GGK@Z)
STATICCtl.obj : error LNK2001: unresolved external symbol "protected: static 
struct AFX_EVENTMAP const  
COleControl::eventMap"(?eventMap@COleControl@@1UAFX_EVENTMAP@@B)
STATICCtl.obj : error LNK2001: unresolved external symbol "protected: static 
struct AFX_MSGMAP const  
COleControl::messageMap"(?messageMap@COleControl@@1UAFX_MSGMAP@@B)
STATICCtl.obj : error LNK2001: unresolved external symbol "public: static 
struct CRuntimeClass const  
COleControl::classCOleControl"(?classCOleControl@COleControl@@2UCRuntimeClass@
@B)
STATICCtl.obj : error LNK2001: unresolved external symbol "int __stdcall 
AfxOleRegisterControlClass(struct HINSTANCE__ *,struct _GUID const &,char 
const *,unsigned int,unsigned int,int,unsigned long,struct _GUID const 
&,unsigned short,unsigned 
short)"(?AfxOleRegisterControlClass@@YGHPAUHINSTANCE__@@ABU_GUID@@PBDIIHK1GG@Z
)
STATICCtl.obj : error LNK2001: unresolved external symbol "int __stdcall 
AfxOleUnregisterClass(struct _GUID const &,char const 
*)"(?AfxOleUnregisterClass@@YGHABU_GUID@@PBD@Z)
[...]


What am I doing wrong? How can I get Control Wizard .OCX projects to 
statically
link both the MFC and runtime libraries? Is this possible?

Regards to all,


 [ CHRIS W. REA, B.Sc.  U. of T. CompSci/Math 9T6 ]
 [ work: cwrea@glrd.com  play: cwrea@interlog.com ]



-----From: Peter.Walker@ubs.com

     I saw this question on an Active-x thread, and the answer is you 
     can't. THe MFC team inisist you dynamically link to the MFC as not all 
     the source is built into the static libs. You could probably build 
     your own lib from the source though..
     
-----From: Mike Blaszczak 

At 12:10 11/12/96 -0500, Chris W. Rea [UL] wrote:

>Environment: Windows NT 4.0WS (SP1), Visual C++ 4.2b (Enterprise Edition)

>I want to create an OCX that statically links in both MFC and the C runtime
>library.

You can't, period.  I mean, you could, if you wanted to start rebuilding and
modifying lots of MFC for yourself.  Your control will have a huuuge instance
size, and it will be funny to watch it load.

.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |