Discussion:
compile ncurses "hello world" to run independent of cygwin?
Daniel Goldman
2015-11-02 03:04:37 UTC
Permalink
I have a Windows 7 / 64 bit PC.

I just installed 32 bit cygwin to d:\cygin\. Installed everything.
https://cygwin.com/faq.html#faq.setup.everything

I started up the Cygwin Terminal.

$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft
Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common
Files/Microsoft Shared/Windows
Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program
Files (x86)/Intel/OpenCL SDK/3.0/bin/x86:/cygdrive/c/Program Files
(x86)/Intel/OpenCL SDK/3.0/bin/x64:/cygdrive/d/Program Files
(x86)/Putty:/cygdrive/c/Program Files (x86)/Windows
Live/Shared:/cygdrive/d/msys64/usr/bin:/usr/lib/lapack:/usr/openwin/bin

$ cat ncurses-1.c
// http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html

#include <curses.h>

int main()
{
initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */

return 0;
}

$ gcc ncurses-1.c -lncurses

$ ./a.exe # runs perfectly under cygwin

$ i686-pc-mingw32-gcc -I /usr/include ncurses-1.c -L /lib -lncurses

$ ./a.exe
Segmentation fault

Switching to a windows 7 command window (dos window), and running a.exe,
I get an error message:

"the program can't start because cygncursesw-10.dll is missing..."

What am I doing wrong? How do I use cygwin to compile the test ncurses
program so it can run in a dos terminal, independent of cygwin? I looked
around the docs and archives and could not figure out.

Thanks,
Daniel

--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Darik Horn
2015-11-02 04:09:51 UTC
Permalink
Post by Daniel Goldman
What am I doing wrong? How do I use cygwin to compile the test ncurses
program so it can run in a dos terminal, independent of cygwin? I looked
around the docs and archives and could not figure out.
Was libncurses built for the MinGW target on the Cygwin host?

Keep in mind that this job is a cross compile, so ncurses and every
other dependency must be built for the MinGW runtime. The mingw-* and
mingw64-* packages for Cygwin are just the toolchain plus some
essentials; there is no mingw-libncurses-devel package in
distribution.

Unless there is a specific reason to cross through Cygwin, it could be
easier to use the native MinGW environment directly:

* http://www.mingw.org/wiki/Getting_Started

And link against the ncurses redistributable:

* http://invisible-mirror.net/ncurses/ncurses.html

--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
cyg Simple
2015-11-02 12:48:20 UTC
Permalink
Post by Darik Horn
Unless there is a specific reason to cross through Cygwin, it could be
* http://www.mingw.org/wiki/Getting_Started
Poppycock! There is no reason that the user couldn't use Cygwin as the
one and only system to build native binaries.
Post by Darik Horn
* http://invisible-mirror.net/ncurses/ncurses.html
Building your own native library with a known set of compilers and
options may be better than depending on someone's build where you don't
know for certain the system, options and compiler used.
--
cyg Simple

--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Greg Freemyer
2015-11-02 15:14:14 UTC
Permalink
Post by cyg Simple
Post by Darik Horn
Unless there is a specific reason to cross through Cygwin, it could be
* http://www.mingw.org/wiki/Getting_Started
Poppycock! There is no reason that the user couldn't use Cygwin as the
one and only system to build native binaries.
I'm relatively new to this mailing list. Apologies if this is well
covered ground....

The last time I checked (a few years ago), my understanding was the
cygwin dll's were licensed such that any programs using them had to be
GPL (or equivalent).

Is that wrong?

If so, anyone wanting to write a commercial tool has to avoid the
cygwin's core dll's.

Does using mingw do so?

Thanks
Greg

--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Darik Horn
2015-11-02 15:34:31 UTC
Permalink
Post by Greg Freemyer
The last time I checked (a few years ago), my understanding was the
cygwin dll's were licensed such that any programs using them had to be
GPL (or equivalent).
Is that wrong?
No, that is still the case:

* https://cygwin.com/licensing.html
Post by Greg Freemyer
If so, anyone wanting to write a commercial tool has to avoid the
cygwin's core dll's.
Or buy a license.
Post by Greg Freemyer
Does using mingw do so?
No, it is easier to avoid GPL obligations by using the MinGW runtime:

* http://www.mingw.org/license

--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Corinna Vinschen
2015-11-02 15:49:25 UTC
Permalink
Post by Greg Freemyer
Post by cyg Simple
Post by Darik Horn
Unless there is a specific reason to cross through Cygwin, it could be
* http://www.mingw.org/wiki/Getting_Started
Poppycock! There is no reason that the user couldn't use Cygwin as the
one and only system to build native binaries.
I'm relatively new to this mailing list. Apologies if this is well
covered ground....
The last time I checked (a few years ago), my understanding was the
cygwin dll's were licensed such that any programs using them had to be
GPL (or equivalent).
Yes, when linking against the Cygwin DLL there are GPL issues.

But that wasn't what "cyg Simple" was referring to. The Cygwin distro
comes with a Mingw-w64 cross compiler and libs. When you use those to
create Mingw binaries, you are not linking against the Cygwin DLL.

So, as "cyg Simple" wrote, there's no reason that you can't use the
Cygwin distro as environment to build non-Cygwin binaries.

There's also the fact that the aforementioned mingw.org project is
rather behind. The Mingw-w64 fork (which is used by Cygwin as well,
incidentally) is more up to speed in terms of WIndows lib and header
file support.


Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
cyg Simple
2015-11-02 12:42:36 UTC
Permalink
Post by Daniel Goldman
$ gcc ncurses-1.c -lncurses
$ ./a.exe # runs perfectly under cygwin
A Cygwin build using the Cygwin runtime should work.
Post by Daniel Goldman
$ i686-pc-mingw32-gcc -I /usr/include ncurses-1.c -L /lib -lncurses
$ ./a.exe
Segmentation fault
A MinGW build using the Cygwin runtime should *never* work.
Post by Daniel Goldman
What am I doing wrong? How do I use cygwin to compile the test ncurses
program so it can run in a dos terminal, independent of cygwin? I looked
around the docs and archives and could not figure out.
You need to specify include and lib paths that contain MinGW libraries.
Don't use the Cygwin native paths of /usr/include and /lib. This means
that you need a ncurses library that is built with MinGW.
--
cyg Simple

--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Loading...