Solved

Getting Error when compiling c++ DLL

Posted on 2006-07-19
4
386 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 169
mixing C++ & C# in Vis Studio 2013 7 141
Arduino EDI - Programming language 3 80
c++, dynamic object by json 1 24
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…
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…
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 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.

895 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

16 Experts available now in Live!

Get 1:1 Help Now