Solved

How to create and Use a Common Function Lib

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

803 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