delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/04/16/10:00:51

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
To: cygwin AT cygwin DOT com
Subject: Re: how to compile programs using (n)curses
References: <18571 DOT 986757346 AT www27 DOT gmx DOT net> <3AD7D24F DOT 44F64F82 AT ece DOT gatech DOT edu>
From: Felix Natter <f DOT natter AT ndh DOT net>
Date: 16 Apr 2001 14:04:57 +0200
In-Reply-To: <3AD7D24F.44F64F82@ece.gatech.edu>
Message-ID: <87vgo5f3ti.fsf@mybaby.home.felix>
Lines: 80
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.0.100
MIME-Version: 1.0

"Charles S. Wilson" <cwilson AT ece DOT gatech DOT edu> writes:

> Felix Natter wrote:
> > 
> > hi,
> > 
> > when I try to compile a simple (n)curses program using cygwin,
> > I get lots of "undefined reference"-messages, one for each ncurses function,
> > but with a "impl_" prepended (i.e. impl_waddch).
> 
> You probably mean "_imp_" is prepended.  The problem is a mismatch
> between your compilation command and your link command.  Apparently, you
> did this:
> 
> (compile): gcc -c foo.c -o foo.o
> and one of the following:
> (link   ): gcc -static -o foo.exe foo.o -lncurses
> (link   ): gcc -o foo.exe foo.o /usr/lib/libncurses.a
> 
> That is, you compiled with the default flags, which set things up for
> dll linking, but then explicitly linked to the static library (by
> specifying -static, or listing the static lib on the command line
> directly).
> 
> If you want static linking, then you must compile all your object files
> with the -DNCURSES_STATIC flag:
> (compile): gcc -DNCURSES_STATIC -c foo.c -o foo.o
> then link as above.
> 
> If you want dynamic linking, then compile normally (no _STATIC flags)
> but link as follows:
> (link   ): gcc -o foo.exe foo.o -lncurses (no -static flag, or)
> (link   ): gcc -o foo.exe foo.o /usr/lib/libncurses.dll.a
> 
> You will probably find /usr/doc/Cygwin/ncurses-5.2.README of interest,
> as well as the cygwin-announce messages referenced in that README.

I read this, thanks.
But I compiled as you suggest. In fact, the problem also occurs if I
compile and link in one step:
I saved the following as test_curses.c:
#include <curses.h>

int main(int argc, char** argv)
{
	initscr();
	wclear(stdscr);
	waddstr(stdscr, "hello world");
	wrefresh(stdscr);
	getch();
	endwin();
}

gcc -static -DNCURSES_STATIC -o test_curses.exe test_curses
=> undefined reference to endwin ...
gcc -o test_curses.exe test_curses.c
=> undefined reference to _imp__endwin ...

I looks like I have a broken installation. In fact, I installed very
"unconventionally": I downloaded setup.exe, and ran it using wine on
a linux-system (I had to because my windows95-partition is not currently
connected to the internet). After some time, my internet-connection
broke down. I copied the latest/-directory to my win95-partition,
and downloaded the remaining packages. Then I started win95 and run
setup.exe with the option "install from local directory".
here are the packages I installed:

ash	  bison  crypt	  file	     gcc    gzip       make	  tar
autoconf  byacc  cygwin   fileutils  gdb    inetutils  ncurses	  vim
automake  bzip2  dejagnu  findutils  gperf  less       sed	  w32api
bash	  clear  diff	  flex	     grep   login      setup.exe
binutils  cpio	 expect   gawk	     groff  m4	       sh-utils

BTW: in my case, setup.exe downloaded the src-package for each package 
selected. how can you disable this ?

thanks,

-- 
Felix Natter

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019