Thread: MFC: Multi-threaded DLL Errors & Related Syntax :: C++

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    MFC: Multi-threaded DLL Errors & Related Syntax :: C++

    Hi.

    I am studying MFC from Jeff Promise's book. I had problems compiling the first sample MFC program from Prosis because I need to set the project from "single-threaded" to "multi-threaded."

    First, "multi-threaded" works, but the execute is huge, maybe five-folds from my biggest win32 console program with many more lines of code. The size of "multi-threaded" un debug mode was 1.5mb. There are less than 100 lines of code. I tried to set "multi-threaded" to "multi-threaded DLL," but then Visual C++ would not compile the source . It responded with a bunch of errors. Do I need to install anything before using the multi-threaded DLL mode?

    How does MFC works as far as software release? Let say I give the MFC program to a friend. Will the friend be able to run it? Is MFC/C++ similar to Java and VB where the program comes require specific system DLL?

    Lastly, Promise's book is exceptional because it touches everything about MFC. I found some MFC syntax that are not like C++ (or maybe it is just my inexperience). For example, some derived functions return "BOOL" and "TRUE." I know C++'s "bool" and "true." I replaced "TRUE" with "true," and that worked okay. However, Visual C++ came up with errors when I replaced "BOOL" with "bool." Are syntax like th ones above MFC specific and are required?

    Kuphryn

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    >I tried to set "multi-threaded" to "multi-threaded DLL," but
    >then Visual C++ would not compile the source .

    Well, if you don't compile a DLL, then don't set it to DLL.

    >How does MFC works as far as software release ?

    If you link the MFC statically, you can distribute the .exe without any more DLLs. Just copy the .exe.

    >Are syntax like th ones above MFC specific and are required?

    They are specific to the windows libraries of Microsoft.

    If you write your own functions, you can use what you want.
    However, if you override MFC methods, you have to use they way they did it
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. Thanks.

    You were the first person that mentioned compiling a DLL. I did not know I have to compile one. How do you compile one to go with the program?

    Lastly, here are the errors Visual C++ came up with when I tried to compile MFC with mode "multi-threaded DLL" install of static multi-threaded.

    multi-threaded DLL (DEBUG): Here are the errors when I tried to compile.
    ----------
    -----
    Hello error LNK2001: unresolved external symbol ___argc
    -----
    Hello error LNK2001: unresolved external symbol ___argv
    -----
    Hello error LNK2001: unresolved external symbol __mbctype
    -----
    Hello error LNK2019: unresolved external symbol __mbctype referenced in function "public: void __thiscall CEditView::ReadFromArchive(class CArchive &,unsigned int)" (?ReadFromArchive@CEditView@@QAEXAAVCArchive@@I@Z)
    -----
    Hello error LNK2019: unresolved external symbol __mbctype referenced in function "void __stdcall AfxFormatStrings(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > > &,unsigned int,char const * const *,int)" (?AfxFormatStrings@@YGXAAV?$CStringT@DV?$StrTraitM FC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@IPBQBDH@Z)
    -----
    Hello fatal error LNK1120: 3 unresolved externals
    -----
    ----------

    multi-threaded DLL: Here are the errors when I tried to compile.

    ----------
    -----
    Hello error LNK2001: unresolved external symbol ___argc
    -----
    Hello error LNK2001: unresolved external symbol ___argv
    -----
    Hello error LNK2001: unresolved external symbol __mbctype
    -----
    Hello error LNK2019: unresolved external symbol __mbctype referenced in function "public: void __thiscall CEditView::ReadFromArchive(class CArchive &,unsigned int)" (?ReadFromArchive@CEditView@@QAEXAAVCArchive@@I@Z)
    -----
    Hello error LNK2019: unresolved external symbol __mbctype referenced in function "void __stdcall AfxFormatStrings(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > > &,unsigned int,char const * const *,int)" (?AfxFormatStrings@@YGXAAV?$CStringT@DV?$StrTraitM FC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@IPBQBDH@Z)
    -----
    Hello fatal error LNK1120: 3 unresolved externals
    -----
    Hello warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    -----
    ----------

    I would like to compile MFC using multi-threaded DLL, thus making the program smaller.

    Thanks,
    Kuphryn

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. I figured out the problem. The problem was there were mismatch settings in the project. The probject was default to Applicantion(exe) and Standard Windows Libraries. I had to set the project to use "Shared MFC DLL" instead of Standard Windows Libraries.

    The executed size shrinks from 1.5mb to 100k in debug mode.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM
  3. Expression/Declaration Syntax Errors
    By fuh in forum C++ Programming
    Replies: 2
    Last Post: 01-15-2003, 06:49 PM
  4. DLL version MFC app
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 07-30-2002, 07:22 PM
  5. MFC Errors :: C++
    By kuphryn in forum C++ Programming
    Replies: 3
    Last Post: 02-11-2002, 09:46 AM