Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Linking self-made library using MFC stuff

Posted on 2000-05-18
13
250 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wait notify demo infinite loop 3 124
Please explain "Promise Pattern" and how it's used 2 57
Capture logon name 13 87
reboot server with scheduled time and week base 4 35
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

828 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