Mail Archives: cygwin/2001/09/18/15:53:08
I've been trying to work out this example of how to
make makefiles and shared library modules that are at least slightly
portable between linux and cygwin. But, I'm having some
difficulty.
I have the following 3 code segments:
=======================================
result.cc
=======================================
#include <stdio.h>
#include <unistd.h>
#include <iostream.h>
#include "result.h"
int main () {}
int doit (int a, int b, int c)
{
cout << "doit: "
<< "a = " << a
<< "b = " << b
<< "c = " << c
<< endl;
return (a+b*c);
}
=========================================
result.h
=========================================
int doit (int, int, int);
=========================================
tester1.cc
=========================================
#include <stdio.h>
#include <unistd.h>
#include <iostream.h>
#include "result.h"
int main (int argc, char *argv[])
{
int result = doit (1, 2, 3);
cout << "result = " << result << endl;
}
And then, the following makefile:
========================================
makefile
========================================
all : result.dll tester1
result.dll: result.cc
g++ -g -o $@ -Wl,-shared $<
tester1 : result.dll tester1.cc
g++ -g -o $@ $^
clean:
rm result.dll tester1.exe
I have tried different and various flavours of things, and this
is what I have come up so far, that compiles. However, it does
not run. When I fire it up, it seems to go out to never-never
land, and i have to kill it with extreme prejudice.
(If I take out the empty main() in result.cc, then I get an unresolved
WinMain AT 16. If I try to change the .dll in makefile to .so, then I get
a bunch of other errors during the final compile/link.
The above files, and the makefile work on a linux box, if I change
the .dll in the makefile to .so.)
Any help or light others would like to shed would be extremely
appreciated.....
Thanks.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -