Solved

Getting Error when compiling c++ DLL

Posted on 2006-07-19
4
389 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
[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
  • 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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++.

705 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