Solved

Linking self-made library using MFC stuff

Posted on 2000-05-18
13
247 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Should CArray be used for a list of pointers in C++? 19 89
sum67 challenge 35 89
mapBully challenge 6 89
Sed question 2 48
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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…

705 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

12 Experts available now in Live!

Get 1:1 Help Now