Solved

Getting Error when compiling c++ DLL

Posted on 2006-07-19
4
385 Views
Last Modified: 2010-08-05
Here is my error.....

error LNK2019: unresolved external symbol __imp__connectToSS@32 referenced in function _wmain      cpp_test.obj      


I'm getting this error when I try to add a c++ console project so I can test my dll.  If I compile as a stand alone project, it compiles fine.

Here is my header file...

#ifndef _CPS_SS_H
#define _CPS_SS_H
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the CPS_SS_WRAPPER_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// CPS_SS_WRAPPER_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef CPS_SS_WRAPPER_EXPORTS
#define CPS_SS_WRAPPER_API __declspec(dllexport)
#else
#define CPS_SS_WRAPPER_API __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C"{
#endif

// This class is exported from the CPS_SS_Wrapper.dll
class CPS_SS_WRAPPER_API CCPS_SS_Wrapper {
public:
      CCPS_SS_Wrapper(void);
      // TODO: add your methods here.
};

//extern CPS_SS_WRAPPER_API int nCPS_SS_Wrapper;

//CPS_SS_WRAPPER_API int fnCPS_SS_Wrapper(void);

CPS_SS_WRAPPER_API void _stdcall connectToSS(
      char * logDir,
      char * cpsVersion,
      char * serverURL,
      char * userName,
      char * userPWD,
      char * categoryName,
      char * appName,
      char * msg);

CPS_SS_WRAPPER_API void _stdcall etTSYSProdCode(
            const char * myProdCode, char * msg);

#ifdef __cplusplus
}
#endif

#endif
0
Comment
Question by:jpmc_cmsops
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 17138663
That naming convention is caused by the '_stdcall' specifier. BTW, are you sure you are linking with your DLL's import library? You'll need to add that one to your console project in order for the the linker to resolve the extern symbols.
0
 

Author Comment

by:jpmc_cmsops
ID: 17138692
I'm going to use this DLL to call from a VB Program.....

So I should remove the _stdcall......

then I need to set my Library directory to that of my DLL..?
0
 
LVL 86

Expert Comment

by:jkr
ID: 17138787
Well, in a VB program, you won't need the import lib, but the name should be exported differently using a Module Definition (.def) file - see http://msdn2.microsoft.com/en-us/library/dt232c9t.aspx ("Calling DLL Functions from Visual Basic Applications") and http://support.microsoft.com/kb/106553/EN-US/ ("How To Write C DLLs and Call Them from Visual Basic")

Anyway, in order to test your DLL from a C/C++ console application, you have to link with the import library or dynamically load the DLL using 'LoadLibrary()' and 'GetProcAddress()'. Are you linking with the import lib?
0
 

Author Comment

by:jpmc_cmsops
ID: 17138917
I remove the_stdCall and let my Library Directory to that of the .lib file and entered the name of my Library file..

I got it to compile and It tested out OK....

I have another question posted in regards to byval and byref variables and how to declare them.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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++.

757 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