This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: How to add 4K of scratch space at the bottom of the stack using C instead of C++?
- From: "Yu-Cheng Chou" <cycchou at ucdavis dot edu>
- To: cygwin at cygwin dot com
- Date: Mon, 11 Jul 2005 16:14:42 -0700 (PDT)
- Subject: Re: How to add 4K of scratch space at the bottom of the stack using C instead of C++?
> > I have module.dll that was created by using command line "gcc -shared
> > -o module.dll module.c" in cygwin.
> > When I run "msvc-cygload -v -cygwin module.dll" in cygwin, error
> > messages listed below occurred.
> Why are you using cygload to load something that isn't cygwin1.dll?
Hi, Max:
Originally, I got two files, main.c and module.c
// main.c
#include <stdio.h>
#include <windows.h>
int main(){
void *handle;
int (*fp)();
char *modname = "./module.dll";
handle = LoadLibrary(modname);
if (handle == NULL) {
fprintf(stderr, "Can't load %s in LoadLibrary()\n", modname);
exit(1);
}
fp = (int (*)())GetProcAddress((HMODULE)handle, "foo");
if (fp== NULL) {
fprintf(stderr, "ERROR: GetProcAddress()\n");
exit(1);
}
fp();
FreeLibrary((HMODULE)handle);
}
// module.c
#include <stdio.h>
#include <windows.h>
int foo(int arg){
printf("foo() called\n");
return (arg * 2);
}
I used "cl -c main.c" and "cl /o main.exe main.obj" to create main.exe.
I used "gcc -shared -o module.dll module.c" to create module.dll.
module.dll will be invoked in main.exe. However, when I run main.exe, the
program just hung there.
So, my question is in an executable program that was created by MSVC, how
to dynamically load a library (module.dll) that was created by cygwin's
gcc?
Some users suggested that I load cygwin1.dll before module.dll because
module.dll might be related to cygwin1.dll.
module.dll will only be created by cygwin's gcc, but I'm not sure if I did
it in the correct way using "gcc -shared -o module.dll module.c".
I have been working on this for a while, but still can't figure out how to
make it work.
Could you help me with this?
Thanks
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/