How to build using Visual Studio 2003?

Project:jpjvm
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi all,

Thanks for sharing this very interesting project. It works great when using the prebuilt .DLL file, but I would like to make some tweaks and build it using Visual Studio 2003 - however, I keep running into errors even when I just try to build the provided code.

Run-Time Check Failure #0 - The value of the ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

I'm good with Progress and Java, but C/C++ is not my forte. Thanks in advance for your feedback!

Jan Schenkel.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
john's picture

Re: How to build using Visual Studio 2003?

Hi Jan,
I'm glad you are interested in jpjvm.
I don't have access to Visual Studio 2003, unfortunately. I used to do builds with it with the "Personal" edition of that, but I had severely hacked Visual Studio with compiler and SDK updates and such. I don't remember ever seeing the error you are describing.

I just tried a build with Visual C++ 2008 "Express Edition" (which I installed after installing the MS Windows SDK), and did a compile. I had to tweak one parameter declaration, but other than that, it compiled without the error you listed.

I tried your error in Google. I didn't see anything that looked familiar to me. (It's been a couple of years since I last compiled this.) I did find this link though:
http://support.microsoft.com/kb/831537
Hopefully that is a help...?


Re: How to build using Visual Studio 2003?

Hi John,

Thanks for helping me with this.

As I'm not particularly tied to using Visual Studio 2003, I downloaded VC++ Express.
Apart from some strcopy warnings, the error I see now is:

error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast 
        or function-style cast

At first I tried simply casting vmlib to an LPCWSTR, using

    handle = LoadLibrary((LPCWSTR) vmlib);

but it didn't like that approach very much - it compiled, but the handle kept coming back as NULL so it didn't want to load the JVM library.

Looking around on the web, I dropped the cast again and could make it compile by adding this bit of code, as per instructions from http://www.codeguru.com/forum/showthread.php?t=231165 :

	// Load the library
	int lenA = lstrlenA(vmlib);
	int lenW;
	BSTR unicodestr;
	lenW = ::MultiByteToWideChar(CP_ACP, 0, vmlib, lenA, 0, 0);
	if (lenW > 0)
	{
		// Check whether conversion was successful
		unicodestr = ::SysAllocStringLen(0, lenW);
		::MultiByteToWideChar(CP_ACP, 0, vmlib, lenA, unicodestr, lenW);
	}
	else
	{
		// handle the error
		return outCharErr("Could not convert the path to the JVM library");
	}
	handle = LoadLibrary(unicodestr);
	// when done, free the BSTR
	::SysFreeString(unicodestr);

However, when I used the 'Debug' build DLL from Progress, it showed the same error as before:

Run-Time Check Failure #0 - The value of the ESP was not properly saved across a function call.
This is usually a result of calling a function declared with one calling convention with a 
function pointer declared with a different calling convention.

If I use the 'Release' build DLL then Progress simply crashes.

As you may have guessed, I am not a C/C++ guy. I'm fine with 4GL/ABL and Java, but C++ continues to baffle me.

Do you by any chance have a working 'Solution' folder that I could download and take apart?
Thanks in advance for any help you can provide!

Jan Schenkel.


jurjen's picture

Perhaps you should not

Perhaps you should not compile for a Widestring enabled target but for the more traditional single-byte character strings or Ansistring?


Re: Perhaps you should not

Hi Jurjen,

That did the trick, indeed - once I found where that setting could be altered in the IDE ;-)

If anybody else is wondering: right-click on the Project (not the Solution) ; go to Configuration properties > General ; in the right-hand list, change Project Defaultys > Character Set to 'Not set'
Oh, and it's best to start from an empty project.

That got the original code working, and then I snipped away what I didn't need and modified what I wanted different. And now it all comes together - great stuff!

Thanks for all your help,

Jan Schenkel.