Solved

How to create and Use a Common Function Lib

Posted on 2004-08-05
5
225 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

758 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

19 Experts available now in Live!

Get 1:1 Help Now