Solved

Linking self-made library using MFC stuff

Posted on 2000-05-18
13
248 Views
Last Modified: 2013-11-25
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 ?
0
Comment
Question by:Claus
  • 4
  • 3
  • 2
  • +3
13 Comments
 
LVL 2

Expert Comment

by:jstolan
ID: 2822853
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 2823045
> 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
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2823210
> 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
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2823256
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 2823981
> I think Attilla (WTL) has

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

..B ekiM
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2824064
Interesting .. I know about WTL (in latest SDK) .. how is Atilla different?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2824739

> 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
 
LVL 1

Accepted Solution

by:
kkarunakar earned 100 total points
ID: 2829588
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 2854571
Do you need more information, Claus?

..B ekiM
0
 

Author Comment

by:Claus
ID: 2857340
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 2865978
No.  If the library uses MFC, link it to MFC.  That's that.

..B ekiM
0
 

Author Comment

by:Claus
ID: 2866591
Answer accepted
0
 
LVL 1

Expert Comment

by:kkarunakar
ID: 2866646
Thanks for accepting answer..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bigDiff challenge 17 85
Unix Command -- Challenging  question 7 87
mapAB Challlenge 35 128
wordmultiple challenge 12 121
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now