Linking self-made library using MFC stuff

I have made my own library that uses MFC stuff like CString and CTimeSpan.  I want to link this library to some other application.  I have an include file that describes the interfaces that the application can use in the library.  Must this other application be MFC enabled, or can I use the library with a non-MFC program?  If MFC is not enabled, CString and CTimeSpan is not recognized.  Is there some MFC include file that I can use so that it recognizes CString and CTimeSpan ?
ClausAsked:
Who is Participating?
 
kkarunakarConnect With a Mentor Commented:
Hi there..
I think it is not necessary to be calling program a MFC application.
U have just add the library file name in
in project on settings menu on link tab in Object\library module.
and u have set the directory path from tools menu selection option and select directory tab and add lib file entry.
U library should be statistically linked and working perfect.
Hope it will help u.
Let me know ur opinion.
Regards Keshav
0
 
jstolanCommented:
The calling program does not need to be MFC enabled, but of course you need to make sure the MFC functions are either statically linked into the app, or the appropriate MFC DLLs are available.

CStrings can be passed back as regular strings using the LPCTSTR operator, and CTimeSpan can be passed back as a binary.  Your program will have to know how to extract the appropriate fields from the CTimeSpan binary.

I don't think you can include "just enough" MFC to use CString and CTimeSpan directly.
0
 
mikeblasCommented:
> The calling program does not need to be MFC enabled,

No.  If the calling app isn't using MFC, then there's nothing in the calling app to properly initialize MFC. When the code in the statically linked routines starts using MFC, it might not work.

What you're suggesting can be made to work, but it's unreliable, unsupported, and not recommeded.

..B ekiM
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
ShaunWildeCommented:
> Is there some MFC include file

as mike say this is unsuported but not unusual

I think Attilla (WTL) has an CString equivalent http://www.sellsbrothers.com/attila/

which you could probably rip

if the objevt is only based on CObject - it is usally quite easy to rip it out of MFC and make you own versions (but record where you did this - so other people know)
0
 
ShaunWildeCommented:
have a look in http://www.codeguru.com/string/index.shtml

for some non MFC string classes

of course you could learn STL and use std::string - veryuseful to have around in non-MFC projects such as ATL/WTL
0
 
mikeblasCommented:
> I think Attilla (WTL) has

Atilla is not WTL. They're very different efforts--you shouldn't confuse them.

..B ekiM
0
 
RONSLOWCommented:
Interesting .. I know about WTL (in latest SDK) .. how is Atilla different?
0
 
ShaunWildeCommented:

> Atilla is not WTL.
oops forgot the (or WTL) :(

>They're very different efforts--you shouldn't confuse them.

I know but since WTL has since been pulled (or so I was informed) - and I believe Chris Sells is trying to get permission to use the WTL source (messages on the Attilla mail list) then I suspect that they will become one.

> how is Atilla different?

Atilla was started as a template library for windowing (Atilla - the name got my vote when it was proposed on the ATL mail list) - since then it was discovered that microsoft was working on WTL and It was asked that they release it so that two competing class libraries could probably merge i.e. the Atilla would become an extension to the WTL ( I don't think that has happened as yet - but I think it should )

there is plenty of info at the chris sells site aand links from that

If WTL (or Atilla) does make it big it could be a challenge to MFC especially for new people who don't want a big chunky app when they can create 1 which doesn't use MFC but is still as useful.
- this is quite a way off but then MFC wasn't much when it started (OWL seemed much better in them days) and look at it now. If WTL gets them same support as MFC or if the Visual Studio code opens up for people to create thier own wizards for WTL (you could probably use the ATL one) as well as classwizard integration then I don't think there would be much stopping it (except Microsoft).
0
 
mikeblasCommented:
Do you need more information, Claus?

..B ekiM
0
 
ClausAuthor Commented:
No - sorry for not getting back.  I got it figured out, I think.  I now have my library that requires MFC, and need to wrap it in Java and use it in a Java application.  Is there anything special I should take care of here, or is it sufficient just to link the MFC library along with it ?
0
 
mikeblasCommented:
No.  If the library uses MFC, link it to MFC.  That's that.

..B ekiM
0
 
ClausAuthor Commented:
Answer accepted
0
 
kkarunakarCommented:
Thanks for accepting answer..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.