Solved

How to create and Use a Common Function Lib

Posted on 2004-08-05
5
226 Views
Last Modified: 2010-04-01
How do I access a function libaray in C++

I am creating  a MFC  DLL and LIB file of common functions I use across many projects

In VC6 using "C" I would do the following

I add the  project as a dependencie
extern "C" __declspec( dllexport ) int SetLayers (void);
__declspec( dllimport ) int SetLayers (void);

How should I do this using VS2003.net in C++ with a  MFC project
0
Comment
Question by:MCofer
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:millsoft
ID: 11731202
You can do it the same way in VS2003.
0
 
LVL 5

Expert Comment

by:millsoft
ID: 11731204
If you've tried it and had problems please paste the code.
0
 

Author Comment

by:MCofer
ID: 11731454
Yes, the dllexport /dllimport works. But Insted of using old stype "C" methods I am wanting to Know if there is a BETTER way to do  the same in C++
maybe using typelibs?
0
 
LVL 5

Accepted Solution

by:
millsoft earned 250 total points
ID: 11731494
If you simply don't put "extern C", then the compiler/linker will treat the functions as C++ functions, and everything will work OK, including function overloading, etc.  You can even dllexport an entire class.

One caveat though: the DLL will only be accessible to a client program compiled by the same compiler/linker source that created the DLL.  This is because the internal function naming (mangling) is defined by the compiler authors (microsoft, whoever)... there is no standard.

The alternative for more general accessibility of your interface is to create COM  objects.

Brad
0
 

Author Comment

by:MCofer
ID: 11731727
Thanks
Too Easy

Can you point me at more Info on creating a COM OBJ LIB

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
Handle Exceptions during instantiation 28 411
SNMP error No Such Object available on this agent at this OID 3 182
Dialogbox API leak? 18 80
max float value 3 23
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

919 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

14 Experts available now in Live!

Get 1:1 Help Now