[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to create and Use a Common Function Lib

Posted on 2004-08-05
5
Medium Priority
?
233 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 1000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

656 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