Functions are not exported from Visual C++

Posted on 2001-08-23
Last Modified: 2013-12-14
I am compiling a MSVC++ API DLL (win32) project, and cannot seem to "find" my exported functions in the DLL. (Using Quickview - there are no exports.  When linking to DLL - it says function not found)

I have tried using the __declspec ( dllexport ) prefix on the function prototypes (as per documentation) and also using the DEF file with an EXPORTS section.

Now - one funny thing I am doing is:  My functions are in "C" files only.  I am using the extern wrapper for the prtototypes.
extern "C"


This allows me to call the functions from a C++ file.
Could this be messing up my export?  Do I have to provide C++ stubs for my C functions?

(In Borland C++ 5.02 this DLL compiles, exports and runs perfectly - have to port this to Microsoft unfortunately)

Thanks in advance
Question by:gmleeman
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

Expert Comment

ID: 6420884

Accepted Solution

BeyondWu earned 250 total points
ID: 6420899
1. Do you use "C:\Program Files\Microsoft Visual Studio\Common\Tools\DEPENDS.EXE" to check it.
VC will add "_" prefix begin the function's name.So you should check it.

2. You can add a DEF file to get the pure function name.
DESCRIPTION 'fsdafsadfsaf'


3. Of couse, you should add extern "C", or the exported name will in C++ style. maybe _Xxxx@4 ro ?Xxxx@8
@4, @8 is the stack size which the function need, is the total of all parameter's size.

Expert Comment

ID: 6421096
#if !defined(_YOURDLL__INCLUDED_)

#ifdef __cplusplus
extern "C" {

__declspec( dllexport ) int YourCoolExport();

#ifdef __cplusplus


#include "your_dll.h"

int YourCoolExport()
   return 0;

.def file is not necessity
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 6421184
Can you show your code?

Expert Comment

ID: 6424331
A def file is useful if you wish to keep the export numbers fixed - this is useful if you have a library and wish to upgrade it in the future and keep compatibility with programs compiled against older DLLs - this is the techniques that the MFC dlls use
LVL 49

Expert Comment

ID: 6425732
>>When linking to DLL - it says function not found)

One does not link to a DLL (exception: runtime linking via LoadLibrary/GetProcAddress).  Have you put the .LIB file in the list of files for the linker to use?  Alternative, place...

  #pragma comment(lib,"mylib.lib")

into a source file that calls your exported fn.

That does not explain why QuickView can't see the exports (unless it is an old 16-bit version of QuickView)

Also, dump the EXPORT section of the DEF file.  It just confuses the issue.  The__declspec( dllexport ) places all of the needed info into the LIB file.

-- Dan

Expert Comment

ID: 6426276
see the BeyondWu response :  "depends" will show you the right thing !

because with visual c++ in release mode, Quickview hide exported functions !

Author Comment

ID: 6427577
Tx BeyondWu and others

Your answer is completely correct (except you omitted the declspec thingy) . I managed to get it working as an API DLL by using:
-extern "C" around prototypes
-__declspec(_dllexport) as a prefix to the function defn.
-a DEF file with the EXPORTS section, etc.

Also - the other response is right. One still cannot view the exported functions in QuickView. (Although they are exported in pure API form). However, The Dependency viewer in MSVC++ does show the exported functions properly.
Thanks for your help

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

691 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