473,722 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem compiling code w\ Borland C++ Builder 5 and 6

4 New Member
My code compiles and runs fine with MS VC++ 6.0 but when I compile and run with Borland, it crashes. Under vc++ 6 I was running winXP 32, with borland I am running vista 32bit.

It compiles with 0 errors and warnings but once it executes the below code I get a crash:

//DLL declare prototypes

extern "C" __declspec(dlle xport)RdmsrEx(D WORD, DWORD * , DWORD *, DWORD);
extern "C" __declspec(dlle xport)Initializ eOls();
extern "C" __declspec(dlle xport)GetDllSta tus();

The common error:
"...raised exception class EAccessViolatio n with message 'Access violation at address 019F3893. Write of address 0025170D. Process stopped. Use Step or Run to to continue"

[php]
//prototype
void GetTemps(DWORD* , DWORD);

//function
void GetTemps(DWORD* dwTemp, DWORD dwCoreNum)
{
DWORD dwEAX, dwEDX;

RdmsrEx( 0x19C , &dwEAX , &dwEDX , dwCoreNum );

dwEAX = dwEAX & 0xFF0000;
dwEAX = dwEAX >> 16;

*dwTemp = 95 - dwEAX;
}

//call to function

InitializeOls() ;
DWORD dwTemp;
DWORD dwAffinity = 1;
GetTemps(&dwTem p,dwAffinity);
[/php]
Sep 7 '08 #1
5 5660
arnaudk
424 Contributor
This probably has to do with your use of windows libraries which are incompatible with the Borland compiler. My suggestion would be to forget about Borland altogether and get the latest VC++ for Vista. Otherwise, make sure you're using libraries that are compatible with both Borland and VC++.
Sep 8 '08 #2
RyanS2000
4 New Member
The problem I posted above doesn't seem to stem from a function call where a library even comes into play. Another issue I had was my code freezing in a simple for-loop.
Sep 9 '08 #3
TamusJRoyce
110 New Member
My C++ Builder 4 book says that C++ Builder is now nearly 100% ANSI compliant. So you are right about the code working.

There should be about the same incompatibiliti es using C++ Builder with external libraries as using the MinGW compiler (codblocks ide) with external libraries.

Are you linking the dll implicitly or explicitly?

My guess is that you are trying to implicitly link a dll in Borland C++ Builder that was built with Microsoft Visual C++. The .lib file accompanying the dll produced by msvc++ is specific to msvc++ (but don't quote me on that).

If the dll was generated outside of Borland C++ Builder, try linking explicitly by using LoadLibrary(); and GetProcAddress( ); to load the library and find the address of each function you are wishing to use...
Sep 10 '08 #4
RyanS2000
4 New Member
My guess is that you are trying to implicitly link a dll in Borland C++ Builder that was built with Microsoft Visual C++. The .lib file accompanying the dll produced by msvc++ is specific to msvc++ (but don't quote me on that).

If the dll was generated outside of Borland C++ Builder, try linking explicitly by using LoadLibrary(); and GetProcAddress( ); to load the library and find the address of each function you are wishing to use...
I did use the above method (loadlibrary\ge tprocaddress) but I was unable to get it to work because the DLL was created in vc++. There was no lib file for the dll so I did the below to get it to work:

I built a def file with impdef, used an app that fixes each function call (adds _ infront of each function). And then I used implib on the created def file to create a lib file and then imported the lib file into my project. Using the above code the functions successfully get called. The function calling is taken care of.

However, if I try to call RdmsrEx twice in a row, the 2nd call throws an error. I also get errors on other lines of code if I put a for-loop in the same code block. I've never seen anything like this before in vc++.
Sep 10 '08 #5
RyanS2000
4 New Member
I got it working. After looking it over I noticed this line didn't look right

*dwTemp = 95 - dwEAX;

I assigned "95 - dwEAX" to a temporary variable and then returned that temporary variable.
Sep 10 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2713
by: NathanAllen | last post by:
First of all to let you know I am using the following compiler: Borland C++Builder 5.5.1 with Turbo Incremental Link 5.00 When I tried to make my first GUI drawing following Lawernceville Press's book it created an error in the compliation process: Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland E:\Gui.cpp: Warning W8004 E:\borland\Include\lvp\String.cpp 106: 'len' is assigned a value that is never used in function...
15
3767
by: Chris | last post by:
I am just beginning programming again and need a bit of advice. I have both Visual C++ 6.0 Standard Edition and Borland C++ Builder 6. Of these two which do you consider the best for programming windows programs (not the DOS style program). I have had a quick look at both of these and Borland seems to have a lot more components (Buttons, Forms etc) than Microsoft Visual C++. Does Visual C++ have these components easily accesable. Chris.
9
4868
by: Christo | last post by:
hey im a student about to start a course in c++ at uni, we have been told to obtain a copy of borland c++ 5.01 (not c++ builder) this is just a program with a compiler/linker and development environment. it is simply called borland c++ 5.01 can anyone tell me where i can download either a free copy or a copy that needs registering or someething, i can only find c++ builder which is totally different from the program i have seen in...
6
2320
by: Alex | last post by:
I've a problem with following simple code (not really usefull): //--------------------------------------------------------------------------- #pragma hdrstop #include "stdio.h" #include <iostream> enum eTest1{et1_1, et1_2} e1; enum eTest2{et2_1, et2_2} e2; class ImageBase {
3
4251
by: shuusaku | last post by:
Dear all, I'm not sure this is the right place to ask for help, but I cannot find any solution anywhere else, I hope you could help me. I'm using Borland C++ Builder 6 with TeeChart v4.04 standard. I'm writing a simple application that should acquire a signal from an acquisition board, and diplay it on the screen. The signal is sampled at 1000 hz, and I'm calculating its rms every 33 msec. Every time I have a vector with ulCount (=33)...
0
1213
by: Morg | last post by:
Hi, I tried out #Develop and Borland C# Builder. I liked #Develop but it was a bit buggy and failed alot :( I really like Borland C# Builder however I cant find a way for it to auto format my code with tabs when put curly braces, etc. Is there a way to turn this feature on? It makes the code so much easier to read. I know I can just manually tab myself but it would be nice if it was automatic like #Develop is.
22
2233
by: smartwolf agassi via DotNetMonster.com | last post by:
I'm a C# language learner. I want to know which IDE is better for C# programing, Borland C#Builder or VS.net 2003? -- Message posted via http://www.dotnetmonster.com
1
1220
by: Cppbuildernoob | last post by:
I need help on this: - I supply code, specific for C++builder - You will compile into single executeable installation file, with a small bug into it. - Must use C++builder 5. - I will test compiled code, feedback trouble if any. - If test oke, we will agree on a small fee, nothing spectaculair, since the job aint that either. - I will transfer fee
4
7541
by: ZedLep | last post by:
Hello, First of all I'm a relatively inexperienced C++ programmer so this may seem a simple question to answer. I'm trying to use zlib from www.zlib.net to decompress some data. However I run into an error when I try to compile the program : E2015 Ambiguity between 'Byte' and 'System::Byte' And the offending code (within zconf.h) is :
0
9386
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8059
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6685
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5996
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4764
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3208
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2606
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2148
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.