public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Compile test ncurses program to run independent of cygwin?
@ 2015-11-05  7:51 Daniel Goldman
  2015-11-05 17:35 ` Andrey Repin
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Goldman @ 2015-11-05  7:51 UTC (permalink / raw)
  To: cygwin

Rephrasing a previous post, I appreciate the responses, but the question 
was not exactly answered (or I didn't get it).

I want to use cygwin to compile a test ncurses program so it runs in a 
dos terminal, independent of cygwin. Windows 7 / 64 bit PC. Installed 32 
bit cygwin, everything, to d:\cygwin\. Ran cygwin mintty terminal:

------------------------------------------------------------

$ cat ncurses.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;
  }

------------------------------------------------------------

# Compiles and runs perfectly under cygwin, no surprise.
$ gcc ncurses.c -lncurses
$ ./a.exe # runs perfectly

# Found /usr/x86_64-pc-cygwin/sys-root/usr/lib/libncurses.a
# Will this let me compile for dos window? Apparently not.
$ i686-pc-mingw32-gcc -I /usr/x86_64-pc-cygwin/sys-root/usr/include/ 
ncurses.c -L /usr/x86_64-pc-cygwin/sys-root/usr/lib/ -lncurses
... undefined reference to `initscr'
... more "undefined reference" error messages

------------------------------------------------------------

My questions:

1) Did I make a compile-line syntax error? Is there a variation of the 
i686-pc-mingw32-gcc command line so I can use cygwin to compile 
ncurses.c to run in dos window, independent of cygwin?

2) If not, to compile ncurses.c to run in dos window, independent of 
cygwin, do I have to set up the ncurses library myself?

I tried to get an answer from the docs, it seems unclear.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile test ncurses program to run independent of cygwin?
  2015-11-05  7:51 Compile test ncurses program to run independent of cygwin? Daniel Goldman
@ 2015-11-05 17:35 ` Andrey Repin
  2015-11-05 17:48   ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Repin @ 2015-11-05 17:35 UTC (permalink / raw)
  To: Daniel Goldman, cygwin

Greetings, Daniel Goldman!

> # Found /usr/x86_64-pc-cygwin/sys-root/usr/lib/libncurses.a
> # Will this let me compile for dos window? Apparently not.
> $ i686-pc-mingw32-gcc -I /usr/x86_64-pc-cygwin/sys-root/usr/include/ 
> ncurses.c -L /usr/x86_64-pc-cygwin/sys-root/usr/lib/ -lncurses
> ... undefined reference to `initscr'
> ... more "undefined reference" error messages

> ------------------------------------------------------------

> My questions:

> 1) Did I make a compile-line syntax error? Is there a variation of the 
> i686-pc-mingw32-gcc command line so I can use cygwin to compile 
> ncurses.c to run in dos window, independent of cygwin?

I'm no expert, but my first answer would be "yes".
You shouldn't use cross-compilers directly, rather, use appropriate GCC
switches to specify host and target subsystems.

> 2) If not, to compile ncurses.c to run in dos window, independent of 
> cygwin, do I have to set up the ncurses library myself?

> I tried to get an answer from the docs, it seems unclear.


-- 
With best regards,
Andrey Repin
Thursday, November 5, 2015 20:29:01

Sorry for my terrible english...


--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile test ncurses program to run independent of cygwin?
  2015-11-05 17:35 ` Andrey Repin
@ 2015-11-05 17:48   ` Corinna Vinschen
  2015-11-05 18:29     ` Yaakov Selkowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2015-11-05 17:48 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]

On Nov  5 20:30, Andrey Repin wrote:
> Greetings, Daniel Goldman!
> 
> > # Found /usr/x86_64-pc-cygwin/sys-root/usr/lib/libncurses.a
> > # Will this let me compile for dos window? Apparently not.
> > $ i686-pc-mingw32-gcc \
      ^^^^                        
      So you're building for 32 bit mingw

> > -I /usr/x86_64-pc-cygwin/sys-root/usr/include/ 
            ^^^^^^^^^^^^^^^^
	    Pointing the compiler to header files for a Cygwin build,
	    which is a *different* target (i686 vs. x86_64 *and* mingw
	    vs. cygwin)...

> > ncurses.c -L /usr/x86_64-pc-cygwin/sys-root/usr/lib/ -lncurses
                      ^^^^^^^^^^^^^^^^
		      same here

> > ... undefined reference to `initscr'
> > ... more "undefined reference" error messages

...and that's logical result.  Along the same lines you could try to
link powerpc-linux ncurses against arm-freebsd binary.  That just won't
work.

What you need is a i686-mingw ncurses.  Have a look around on the net or
try to build your own.  However, it will probably not work correctly in
a Cygwin pseudo tty due to lack of the Cygwin compat layer implementing
them.

> > ------------------------------------------------------------
> 
> > My questions:
> 
> > 1) Did I make a compile-line syntax error? Is there a variation of the 
> > i686-pc-mingw32-gcc command line so I can use cygwin to compile 
> > ncurses.c to run in dos window, independent of cygwin?
> 
> I'm no expert, but my first answer would be "yes".
> You shouldn't use cross-compilers directly, rather, use appropriate GCC
> switches to specify host and target subsystems.

Nope, use cross compilers.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compile test ncurses program to run independent of cygwin?
  2015-11-05 17:48   ` Corinna Vinschen
@ 2015-11-05 18:29     ` Yaakov Selkowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Yaakov Selkowitz @ 2015-11-05 18:29 UTC (permalink / raw)
  To: cygwin

On Thu, 2015-11-05 at 18:48 +0100, Corinna Vinschen wrote:
> What you need is a i686-mingw ncurses.  Have a look around on the net or
> try to build your own.

There are for both i686- and x86_64-w64-mingw32 in Ports.

> However, it will probably not work correctly in a Cygwin pseudo tty due 
> to lack of the Cygwin compat layer implementing them.

It most definitely does not work correctly in mintty, but it works quite
well in a cmd window.

--
Yaakov



--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-05 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-05  7:51 Compile test ncurses program to run independent of cygwin? Daniel Goldman
2015-11-05 17:35 ` Andrey Repin
2015-11-05 17:48   ` Corinna Vinschen
2015-11-05 18:29     ` Yaakov Selkowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).