delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/25/16:13:42

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Niklas Odenteg" <niod AT home DOT se>
To: <cygwin AT cygwin DOT com>
Subject: RE: linking problems using gcc
Date: Thu, 25 Nov 2004 22:13:13 +0100
Message-ID: <000f01c4d333$93049380$0602a8c0@malenkov>
MIME-Version: 1.0
In-Reply-To: <Pine.GSO.4.61.0411251122350.14489@slinky.cs.nyu.edu>

Hi Igor!

Thanks for trying to help. I'll solve it. The stupid platform (windows
or cygwin?) uses random and srandom instead of rand and srand!
Everything in order to confuse the enemy right ;-)

I solved it with these small statements below. Little messy, but it
works.

#ifndef MSDOS
#include <unistd.h>
#else
#include <io.h>
#define RAND
#endif
....
#ifdef RAND
#define random rand
#define srandom(s) srand(s)
#endif
...
#ifdef _LIBC
	extern int srandom();
	extern int random();
	extern unsigned long time();
#endif


Best

  /N


-----Original Message-----
From: Igor Pechtchanski [mailto:pechtcha AT cs DOT nyu DOT edu] 
Sent: den 25 november 2004 17:25
To: Niklas Odenteg
Cc: cygwin AT cygwin DOT com
Subject: Re: linking problems using gcc

On Thu, 25 Nov 2004, Niklas Odenteg wrote:

> Hi!
>
> This may be a newbee Q, but I'll try anyway ;-)
>
> I trying to link a small C/C++ program and I got linking error on
time(),
> rand() and srand(). These should be part of libc right? So way are
they
> missing? Has cygwin some special libc implementation or something???
>
> Confused programmer needs some help.

Please post a small simple program that demonstrates the error, the
exact
command line you used to compile it, and the exact error you get from
gcc.

At a guess, you are missing some #includes, so the functions aren't
declared as 'extern "C"', and are name-mangled, so the linker doesn't
find
them.

> Tanks!

:-O  Where?

> /Niklas

HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT


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

- Raw text -


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