Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL problem

Status
Not open for further replies.

PlainOldPhil

Programmer
Oct 22, 2005
4
CA
Hi all,

I wrote a library under linux in GCC and now I'm trying to use it in Borland C++ Builder. I used MinGW to compile it into a Windows DLL, and then used implib to generate a borland lib file for it. The DLL is linking to the program just fine, and it's calling the function in the DLL without any problems, but as soon as that function calls an internal function of the DLL the program crashes. Let me give an example to be a little more clear. In Borland, I use:

extern "C" __declspec(dllimport)void libShare(int argc, char** argv);

to prototype the function out of my dll. I can call libShare just fine, but as soon as libShare calls an internal function of the dll, it crashes with the error: "access violation at 0x011933d4: read of address 0xfeeeefeeee. Process stopped blah blah blah."

Now here's the crazy part. When I run it out of just a console app in Borland, everything works exactly how it's supposed to :mad:. Any ideas at all on this? (PS.. I know this post was long, I'm sorry).

PPS... just thought of this, I used some stdio stuff in the program like printf etc... Could this make a difference?

Thanks in advance,
Phil
 
if you still have the source code for the linux lib, my suggestion to you is to recompile for windows. Many of the system calls access different areas of memory between the two OS'. It should be a straight recompile for BCB.

The simplest solution is the best!
 
Hey Prattaratt,

Thanks for the response. I wasn't able to recompile under BCB because the code depended on too many GCC features. I found the problem though. It's because when I was prototyping the library I used "exit" in my main function. When I recompiled it into a dll, I forgot to drop the exit. That's all it was, *sigh*. Hours of debugging for one line of code.

Regards,
Phil
 
Let me tell you a story similar to that. When I was first learning assembler (In DOS), I was writing a program that was supposed to output a string to the crt; Your standard hello world. But every time I tried to run the program, it would reboot the system. After three days of debugging and pulling my hair out, it turned out that my radix was defaulted to base ten instead of hexadecimal; Because I did not put an H identifying my interrupt as 21H(DOS system services interrupt) as intended, I was calling instead the switch to protected mode interrupt for the 286 processor INT 15H. Taught me a lesson in paying attention to detail.

The simplest solution is the best!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top