Solved

How to create and Use a Common Function Lib

Posted on 2004-08-05
5
229 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
[X]
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
  • 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

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

735 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