Solved

Getting Error when compiling c++ DLL

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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VS2015 compilation and missing DLLs 9 181
C++ Language error 28 280
FMX TCameraComponent Problem 2 93
learn programming 8 70
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

733 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