comp.lang.ada
 help / color / mirror / Atom feed
From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk)
Subject: Re: linking with C++
Date: 1998/04/21
Date: 1998-04-21T00:00:00+00:00	[thread overview]
Message-ID: <Ers9F1.7n@jvdsys.nextjk.stuyts.nl> (raw)
In-Reply-To: 6hglkj$dlh$1@nyheter.chalmers.se


Martin Klang (md4mars@mdstud.chalmers.se) wrote:

: lately i've been trying out ADA, and even though it's not by a long way as
: esthetically pleasing as C++, i must confess it's a pretty useful little
: language.

You just brightened up my day :-)

: i cannot link to C++ with gnatlink.

Well, actually your code says:

: //file cstuff.c
: #include <stdio.h>
: void c_test()
: {
:   printf("jah!");
: }

which is not C++ but C code. So instead of:

:    pragma Import(CPP,C_Test,"c_test");

use pragma Import(C, C_Test, "c_test); and build with

gcc -c cstuff.c
gnatmake test -largs cstuff.o

BTW remember that gcc is just a driver program, and the '.c'
extension will make it use the C, not the C++ compiler. The
same goes for g++.

BTW2 remember that there might already be a program called
'test' in your path.

To try out linking to C++ use a 

// file cppstuff.cc
#include <iostream.h>
void cppstuff()
{
   cout << "jah!" << endl;
}

with the CPP import. And do not forget to link in libstdc++.

Jerry.

-- 
-- Jerry van Dijk  | email: jdijk@acm.org
-- Leiden, Holland | member Team-Ada




  parent reply	other threads:[~1998-04-21  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-20  0:00 linking with C++ Martin Klang
1998-04-21  0:00 ` Robert Dewar
1998-04-21  0:00 ` Justin Braach
1998-04-21  0:00 ` Jerry van Dijk [this message]
1998-04-21  0:00 ` Robert Dewar
1998-04-23  0:00   ` [GNAT] Extending a C++ class Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox