Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Dev-C++ and DLL files

This thread is locked; no one can reply to it. rss feed Print
Dev-C++ and DLL files
KaBlammyman
Member #455
June 2000
avatar

Okay, I need to use some functions that are in a DLL file I made in Dev-C++. I don’t know how to link em' together in Dev-C++ as to get rid of the” undefined reference" errors.

Well, if it helps, I'm trying to re-compile the example (in Dev-C++) from this webpage:
http://www.codeproject.com/dll/ParkMouse.asp

The DLL source compiled and made a DLL. :D
The exe will not compile because of linker errors since I am trying to use the functions in the DLL >:(

How can I make Dev-C++ see the functions in the DLL so I can compile the exe?

Thanx

p.s. Google didn’t help...too many people asked this same question and didn’t get straight answers, and the ones who found the answer didn’t share it with the world (or gave a vague description that doesn’t help me)

->Insert clever quote here<-
http:my website

Hrvoje Ban
Member #4,537
April 2004
avatar

When DLL is compiled you'll have two files: <dll name>.dll and lib<dll name>.a file. Link with later.

KaBlammyman
Member #455
June 2000
avatar

tried that...and i also tried adding the .def file (--def foo.def) and it didnt work.

Any other ideas...or is this something that the developers on dev-c++ messed up on. I'm gonna send them an email. >:(

->Insert clever quote here<-
http:my website

Johan Halmén
Member #1,550
September 2001

If you link with your .a and it doesn't work, your .a file is bad.

Or you have wrong order in the .a files.

liballeg.a should be the last one. When you choose Project, Project Options, Parameters and look at the Linker window to the right, you see a list of .a files you link with. In this list liballeg.a should be the last one. Or you might have -lalleg there. It is a plain text window with line breaks. Just edit it.

In my present project, my Linker window says:
../../../../../Dev-Cpp/GnuWin32/lib/libpng.a
../../../../../Dev-Cpp/GnuWin32/lib/libz.a
../../../../../Dev-Cpp/lib/libjpgal.a
-lalleg

The funny paths I get when I use the browser behind the "Add Library or Object" button.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

KaBlammyman
Member #455
June 2000
avatar

Im not sure if I understand you correctly...but I'm not using allegro for this particular project. AS I said in the previous thread, I want to compile and run the example from this website:
http://www.codeproject.com/dll/ParkMouse.asp

I didnt modfiy the code, so I dont know how the .a file can be bad.

->Insert clever quote here<-
http:my website

Marco Radaelli
Member #3,028
December 2002
avatar

Post the full command you use to compile the program plus all the errors you get

I'm not registered at codeproject.com, so if you can attach both files to the post, I can give them a look :)

BAF
Member #2,981
December 2002
avatar

Marco Radaelli
Member #3,028
December 2002
avatar

Thank you :D

Going to give a look at that code :)

KaBlammyman
Member #455
June 2000
avatar

anybody else tried to run the code?

->Insert clever quote here<-
http:my website

Marco Radaelli
Member #3,028
December 2002
avatar

Sorry I was forgetting about this :)

I tried it, well, it does compile, make the dll and I can make the executable.
When I run it it says 'Hook Failed' but the program works. I have no idea about that.

umperio
Member #3,474
April 2003
avatar

Quote:

or is this something that the developers on dev-c++ messed up on. I'm gonna send them an email. >:(

I think before bothering Dev-Cpp developers you should first try to understand where the problem is. I've read some tutorials about dll creation and it seems to me that the code linked is not 100% standard. What I mean is none of the dll functions is exported in a header. So probably the error is just caused by the differences in how mingw (and not dev-cpp) and microsoft compiler manage dlls.
If I were in you I'd try creating a Dll.h file which contains what's written in Exe.h and try to recompile the dll, then include dll.h when compiling the exe.
I didn't try it, since I don't have mingw installed here.

Go to: