public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* simple question
@ 2000-08-08 10:46 RPathiyal
  2000-08-08 18:18 ` Alexandre Oliva
  0 siblings, 1 reply; 26+ messages in thread
From: RPathiyal @ 2000-08-08 10:46 UTC (permalink / raw)
  To: help-gcc

hi,

i'm new to GCC and its capabilities.  i recently configured, built and installed GCC 2.95.2 for a redhat linux 6.1 machine with no problems.  i created a simple hello.c file to test the compiler.  

#inlucde <stdio.h>
int main ()
{   printf("\nHello World\n");
    return 0;
}

i then typed gcc hello.c at the linux prompt and the computer paused for a second and then another linux prompt came up.  my question is, does this mean that the file compiled properly?  also, is there any way for me to see the output (eg. see "Hello World" printed to the screen)?  or does the GCC only compile files and not run them?  or do i need to add an option to the gcc command in order to get an output?  please help me.  i dont know the material very well enough to understand the documentation all that well.  also, please email any responses to me at this address (RPathiyal@aol.com) as i am not on the mailing list.  Thanks in advance for any help.

sanjay pathiyal


^ permalink raw reply	[flat|nested] 26+ messages in thread
* simple question
@ 2002-11-27 10:11 cowen
  0 siblings, 0 replies; 26+ messages in thread
From: cowen @ 2002-11-27 10:11 UTC (permalink / raw)
  To: gcc-help

Hello all.

This is perhaps a stupid newbie question. I'm implementing gammln, one of 
the numerical recipes
(available from 
http://www.ulib.org/webRoot/Books/Numerical_Recipes/bookcpdf.html, chapter 6).

gammln (or lnGamma as I've named it) computes the natural log of the gamma 
function, which
should allow one to compute interesting things, like factorials.

Here's the code:

***************** utils.h **************************************

#ifndef UTILS_H
#define UTILS_H

double lnGamma ( double xx );

#endif // UTILS_H


**************** utils.c **************************************

#include <math.h>

double lnGamma ( double xx )
{
         int j;
         double x,y,tmp,ser;
         static double cof[6] = {
                 76.18009172947146,
                 -86.50532032941677,
                 24.01409824083091,
                 -1.231739572450155,
                 0.1208650973866179e-2,
                 -0.5395239384953e-5
         };

         y = x = xx;
         tmp  = x + 5.5;
         tmp -= ( x + 0.5 ) * log( tmp );
         ser = 1.000000000190015;

         for ( j = 0; j <= 5; j++ )
                 ser += cof[j]/++y;

         return -tmp + log( 2.5066282746310005 * ser/x );
}

**************************** test.c 
*******************************************

#include <stdio.h>
#include <math.h>
#include "utils.h"

int main ()
{
     int i;
     for ( i = 1; i <= 20; i++ ) {
         printf( "%3d!: %.0f\n", i, exp( lnGamma(  i + 1.0 ) ) );
     }
     return 0;
}

*************************************************************************************

Here's the output:

   1!: 1
   2!: 2
   3!: 6
   4!: 24
   5!: 120
   6!: 720
   7!: 5040
   8!: 40320
   9!: 362880
  10!: 3628800
  11!: 39916800
  12!: 479001600
  13!: 6227020800
  14!: 87178291200
  15!: 1307674368006
  16!: 20922789888126
  17!: 355687428098601
  18!: 6402373705783494
  19!: 121645100410059440
  20!: 2432902008204834800

**********************************************************

This is obviously wrong. (15! is evidence enough.)

The algorithm, however, is correct -- I lifted it
directly from the numerical recipe, and I'm fairly confident that
the authors have not made an error. I've built and run the example
on different platforms. The result is always the same.


Here is a primitive Makefile:


all: utils.o test.o test.exe

%.o: %.c
         gcc -c -g -Wall -o $@ $^

test.exe:
         gcc -o $@ -g -Wall utils.o test.o



Any suggestions would be most helpful.

Thanks in advance,
Charles.





^ permalink raw reply	[flat|nested] 26+ messages in thread
* simple question
@ 2004-04-15 21:43 Ramin NIkaeen
  2004-04-15 21:47 ` Gabriel Dos Reis
                   ` (3 more replies)
  0 siblings, 4 replies; 26+ messages in thread
From: Ramin NIkaeen @ 2004-04-15 21:43 UTC (permalink / raw)
  To: gcc-help; +Cc: gcc



Valued Colleagues,

I have built and installed gcc-3.3 on RedHat linux 7.2 but I am having 
problems with the compiler. For several days I have been trying to
figure out the cause of the problem but I have not had much success.

Below is a small sample program and the compiler error that I get.

If someone can give me any pointers as to the cause of the problem,
I will be very thankful.

best regards

ramin


--------------------------------------------------------------------------------------------
TEST PROGRAM
--------------------------------------------------------------------------------------------
jupiter.goldline.net:/home/rnikaeen/test>more c.cpp

#include <iostream>
#include <string>
using namespace std;

int main()
{
    cerr << "Enter your name ";

    return 0;
}

--------------------------------------------------------------------------------------------
COMPILER OUTPUT
--------------------------------------------------------------------------------------------
jupiter.goldline.net:/home/rnikaeen/test>gcc c.cpp
/tmp/cc5AisQc.o: In function `main':
/tmp/cc5AisQc.o(.text+0x1b): undefined reference to `std::cerr'
/tmp/cc5AisQc.o(.text+0x20): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc5AisQc.o: In function `__static_initialization_and_destruction_0(int, int)':
/tmp/cc5AisQc.o(.text+0x49): undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/cc5AisQc.o(.text+0x64): undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/cc5AisQc.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

--------------------------------------------------------------------------------------------
gcc VERSION
--------------------------------------------------------------------------------------------
jupiter.goldline.net:/home/rnikaeen/test>which gcc 
/usr/local/bin/gcc


jupiter.goldline.net:/home/rnikaeen/test>gcc -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ./configure 
Thread model: posix
gcc version 3.3

--------------------------------------------------------------------------------------------
RedHat Linux VERSION
--------------------------------------------------------------------------------------------
jupiter.goldline.net:/usr/local/publicVoiceXML/speech_tools-1.2.3>uname -v
#1 Thu May 29 08:32:50 EDT 2003
jupiter.goldline.net:/usr/local/publicVoiceXML/speech_tools-1.2.3>uname -a
Linux jupiter.goldline.net 2.4.20-18.7 #1 Thu May 29 08:32:50 EDT 2003 i686 unknown
jupiter.goldline.net:/usr/local/publicVoiceXML/speech_tools-1.2.3>

^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: simple question
@ 2004-04-16 16:40 lrtaylor
  0 siblings, 0 replies; 26+ messages in thread
From: lrtaylor @ 2004-04-16 16:40 UTC (permalink / raw)
  To: hbena76, gcc-help; +Cc: Rnikaeen

Using gcc for linking c++ programs will not always work, even if you add the C++ library to the link line.  For example, exception handling may not work correctly, because things need to be linked slightly differently to properly handle exception handling on certain platforms.

Use g++.

Cheers,
Lyle

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On Behalf Of Houda Benabderrazik
Sent: Friday, April 16, 2004 3:07 AM
To: gcc-help@gcc.gnu.org
Cc: Ramin NIkaeen
Subject: Re: simple question


gcc  -lstdc++ c.cpp
will work.

 --- Ramin NIkaeen <Rnikaeen@goldline.net> a écrit : >

> 
> Valued Colleagues,
> 
> I have built and installed gcc-3.3 on RedHat linux
> 7.2 but I am having 
> problems with the compiler. For several days I have
> been trying to
> figure out the cause of the problem but I have not
> had much success.
> 
> Below is a small sample program and the compiler
> error that I get.
> 
> If someone can give me any pointers as to the cause
> of the problem,
> I will be very thankful.
> 
> best regards
> 
> ramin
> 
> 
>
--------------------------------------------------------------------------------------------
> TEST PROGRAM
>
--------------------------------------------------------------------------------------------
> jupiter.goldline.net:/home/rnikaeen/test>more c.cpp
> 
> #include <iostream>
> #include <string>
> using namespace std;
> 
> int main()
> {
>     cerr << "Enter your name ";
> 
>     return 0;
> }
> 
>
--------------------------------------------------------------------------------------------
> COMPILER OUTPUT
>
--------------------------------------------------------------------------------------------
> jupiter.goldline.net:/home/rnikaeen/test>gcc c.cpp
> /tmp/cc5AisQc.o: In function `main':
> /tmp/cc5AisQc.o(.text+0x1b): undefined reference to
> `std::cerr'
> /tmp/cc5AisQc.o(.text+0x20): undefined reference to
> `std::basic_ostream<char, std::char_traits<char> >&
> std::operator<< <std::char_traits<char>
> >(std::basic_ostream<char, std::char_traits<char>
> >&, char const*)'
> /tmp/cc5AisQc.o: In function
> `__static_initialization_and_destruction_0(int,
> int)':
> /tmp/cc5AisQc.o(.text+0x49): undefined reference to
> `std::ios_base::Init::Init[in-charge]()'
> /tmp/cc5AisQc.o(.text+0x64): undefined reference to
> `std::ios_base::Init::~Init [in-charge]()'
> /tmp/cc5AisQc.o(.eh_frame+0x11): undefined reference
> to `__gxx_personality_v0'
> collect2: ld returned 1 exit status
> 
>
--------------------------------------------------------------------------------------------
> gcc VERSION
>
--------------------------------------------------------------------------------------------
> jupiter.goldline.net:/home/rnikaeen/test>which gcc 
> /usr/local/bin/gcc
> 
> 
> jupiter.goldline.net:/home/rnikaeen/test>gcc -v
> Reading specs from
> /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
> Configured with: ./configure 
> Thread model: posix
> gcc version 3.3
> 
>
--------------------------------------------------------------------------------------------
> RedHat Linux VERSION
>
--------------------------------------------------------------------------------------------
>
jupiter.goldline.net:/usr/local/publicVoiceXML/speech_tools-1.2.3>uname
> -v
> #1 Thu May 29 08:32:50 EDT 2003
>
jupiter.goldline.net:/usr/local/publicVoiceXML/speech_tools-1.2.3>uname
> -a
> Linux jupiter.goldline.net 2.4.20-18.7 #1 Thu May 29
> 08:32:50 EDT 2003 i686 unknown
>
jupiter.goldline.net:/usr/local/publicVoiceXML/speech_tools-1.2.3> 


	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

^ permalink raw reply	[flat|nested] 26+ messages in thread
* simple question
@ 2004-04-16 19:19 Ramin NIkaeen
  0 siblings, 0 replies; 26+ messages in thread
From: Ramin NIkaeen @ 2004-04-16 19:19 UTC (permalink / raw)
  To: gcc-help


Colleaugues,

To test the sanity of a certain static library (libFestival.a), 
I am trying compiling a simple program and linking it to the library.
I get the /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
error. Can someone tell me what is wrong?!

thanks a lot

ramin
-----------------------------------------------------------------
SOURCE CODE
-----------------------------------------------------------------
/*
-I/usr/local/publicVoiceXML/festival-1.4.3.old/src/include
-L/usr/local/publicVoiceXML/festival-1.4.3.old/src/lib
-lFestival
*/

void festival_initialize(int load_init_files,int heap_size);

int main()
{
        festival_initialize(1,2);

        return 0;
}


-----------------------------------------------------------------
COMPILATION
-----------------------------------------------------------------
g++ -L/usr/local/publicVoiceXML/festival-1.4.3.old/src/lib -lFestival
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
jupiter.goldline.net:/home/rnikaeen/test/festival>


^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: simple question
@ 2004-04-16 19:26 lrtaylor
  0 siblings, 0 replies; 26+ messages in thread
From: lrtaylor @ 2004-04-16 19:26 UTC (permalink / raw)
  To: Rnikaeen, gcc-help

You forgot to include the source file on your command line...

Cheers,
Lyle

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Ramin NIkaeen
Sent: Friday, April 16, 2004 1:17 PM
To: gcc-help@gcc.gnu.org
Subject: simple question


Colleaugues,

To test the sanity of a certain static library (libFestival.a), 
I am trying compiling a simple program and linking it to the library.
I get the /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
error. Can someone tell me what is wrong?!

thanks a lot

ramin
-----------------------------------------------------------------
SOURCE CODE
-----------------------------------------------------------------
/*
-I/usr/local/publicVoiceXML/festival-1.4.3.old/src/include
-L/usr/local/publicVoiceXML/festival-1.4.3.old/src/lib
-lFestival
*/

void festival_initialize(int load_init_files,int heap_size);

int main()
{
        festival_initialize(1,2);

        return 0;
}


-----------------------------------------------------------------
COMPILATION
-----------------------------------------------------------------
g++ -L/usr/local/publicVoiceXML/festival-1.4.3.old/src/lib -lFestival
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
jupiter.goldline.net:/home/rnikaeen/test/festival>


^ permalink raw reply	[flat|nested] 26+ messages in thread
* Simple question
@ 2012-08-22 13:58 Byron Blue
  2012-08-22 14:03 ` Ángel González
                   ` (4 more replies)
  0 siblings, 5 replies; 26+ messages in thread
From: Byron Blue @ 2012-08-22 13:58 UTC (permalink / raw)
  To: gcc-help

We are considering moving our operating system to the Linux environment.
Our product is a commercial OMNI sonar system used throughout the world in 
the commercial fishing industry. The software itself and upgrades are free 
of charge to the user.
Of course, my choice for the compiler would be GCC.
I should initially point out that I am unfamiliar with both Linux and 
therefore GCC.

This is the question:
  GCC uses the GNU license scheme. This operating system would be embedding 
in our industrial computers and I do not (of course) want the source code 
for our operating system to be open source - available to our competitors. 
The GNU site is not quite clear in this area and being new I would not want 
to "break the rules". Could I ask you for a bit of clarification on this 
issue?
Thank you for your time and efforts,

Byron Blue
Software Engineering
MAQ Sonar 

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

end of thread, other threads:[~2012-08-25 21:23 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-08 10:46 simple question RPathiyal
2000-08-08 18:18 ` Alexandre Oliva
2002-11-27 10:11 cowen
2004-04-15 21:43 Ramin NIkaeen
2004-04-15 21:47 ` Gabriel Dos Reis
2004-04-15 21:47 ` Andreas Tobler
2004-04-15 21:48 ` Paolo Carlini
2004-04-16  9:06 ` Houda Benabderrazik
2004-04-16 16:40 lrtaylor
2004-04-16 19:19 Ramin NIkaeen
2004-04-16 19:26 lrtaylor
2012-08-22 13:58 Simple question Byron Blue
2012-08-22 14:03 ` Ángel González
2012-08-22 14:35 ` Ian Lance Taylor
2012-08-22 15:21 ` David Brown
2012-08-22 16:39 ` Bob Plantz
2012-08-25 15:57 ` Florian Weimer
2012-08-25 16:05   ` Georg-Johann Lay
2012-08-25 17:30   ` Ian Lance Taylor
2012-08-25 17:55     ` Bob Plantz
2012-08-25 18:20     ` Georg-Johann Lay
2012-08-25 20:37       ` Ian Lance Taylor
2012-08-25 21:01         ` Georg-Johann Lay
2012-08-25 21:23           ` Ian Lance Taylor
2012-08-26  9:13             ` Ángel González
2012-08-26  9:55               ` Jonathan Wakely

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