[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie to g++

From: Paul Pluzhnikov
Subject: Re: newbie to g++
Date: Sat, 03 Nov 2007 14:14:10 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

"" <> writes:

> hi i am using g++ on windows and trying to learn c,c++..
> i was trying to  make and use user defined libraries and wrote
> tom.h
> ---------
> void mylibfn(void);
> tom.c
> --------
> void mylibfn(){

Preferred way to say the same thing:

  void mylibfn(void)

[Yes, placement of the '{' matters under certain conditions.]

> printf("my libfn called!\n");
> }
> then i made tom.o by
> g++ -c tom.c
> and using ar qv  libfruit.a tom.o  i created libfruit.a

So far everything is all right ...
Note that mylibfn() has 'C++' linkage, and is not callable from
straight-'C' code.

> i wish to call the mylibfn() from another test.c like
> test.c
> --------

This is missing '#include "tom.h"'

> int main(){
> mylibfn();
> }
> how do i compile test.c using g++ ,giving the libfruit.a as argument ?

g++ test.c -L... -lfruit

> for the cc compiler it is something like
> cc  test.c -lfruit -L/home/sharedlib .. but i am bit confused by g++
> options..

g++ generally takes the same options. There are a lot of additional
options, but you don't need them for "basic" stuff.

In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]