[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Getting Error when compiling c++ DLL

Posted on 2006-07-19
4
Medium Priority
?
391 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 1000 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 October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

656 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