Re: [igraph] Cygwin -> Windows compilation - again.
From:
Mark McClure
Subject:
Re: [igraph] Cygwin -> Windows compilation - again.
Date:
Tue, 10 Mar 2009 13:27:15 -0400
> > I tried moving around the order of the > > command line arguments. Amazingly it worked; the program > > compiles and runs fine from Cygwin. > :-o Just for the record, can you please post the order of > the arguments that worked in the end?
Sure - see below. At this point, I am able to compile a program that calls the igraph library and runs from the Windows command line, assuming that cygwin is installed and that the Windows PATH environment variable is set to point to the proper dynamic libraries. I've not been able to link them statically and I can't get a program to run on a Windows box without Cygwin installed.
Here's what I've got so far; the file first_igraph.c is exactly the first example that appears in the igraph tutorial: http://cneurocvs.rmki.kfki.hu/igraph/doc/html/ch03s01.html
First, compile the program from the Cygwin unix-like prompt. The order of the command line arguments appears to be important. This didn't work when the source file was listed last. Also, the -mno-cygwin flag is essentially superfluous. While I have used this flag succesfully in a couple of other programs, the igraph library ultimately calls Cygwin DLLs. At any rate, here is the command: $ gcc -mno-cygwin first_igraph.c -I/usr/local/include/igraph -L/usr/local/lib -ligraph -o first_igraph
Now, fire up the Windows command prompt by typing 'cmd' into the 'Run...' option of the start menu. Then change directories to the location of the new executable. Here's mine: > cd C:\cygwin\home
We can try to execute the program by typing 'first_igraph'. I get the following message: 'This application has failed to start because cygigraph-0.dll was not found. ...'
Now, cygigraph-0.dll is in the /usr/local/lib library, so we add this to our path using Windows notation: > path = %PATH%;C:\cygwin\usr\local\lib
Re-executing 'first_igraph', I now get the error message: 'This application has failed to start because cygwin1.dll was not found. ...'
This is exactly the library that -mno-cygwin is meant to link to statically. Again, I've done this succesfully with other programs so, presumably, this is coming from cygigraph-0.dll.
Finally, let's add the path to cygwin1.dll: > path = %PATH%;C:\cygwin\bin
Now, 'first_igraph' will run properly.
Of course, this still leaves me with my essential problem. How can I create a binary that is distributable to users who don't have Cygwin? I have tried to link statically just a bit by leaving off -ligraph and including full paths to DLLs as if they were source files, but without success so far.