Linking C++ without compiler ?

  • Follow


Hello,
I've received a weird request this morning. Someone in my group want to 
send a programmed developped here to a potential sponsor. We can't give 
them our source code, and we can't give them an executable because its 
linked with libraries we can't redistribute.

the sponsor has all the required libraries, one of which is in C++. Our 
code is also C++.

The plan would be to compile our code and make a library out of it 
(libfoo.a), then provide a small makefile that would take libfoo and 
link it with the required 3rd party libraries, and whatever required 
system library.

The trouble is, they don't have SunWorkshop over there, and our code 
(and the 3rd party library) is compiled with it.

If it was all C, we could use the linker (ld) to  link it all together, 
but for some reason it doesn't work:

ld -o a.out libfoo.a -lcommercialLib1 -lcommercialLib2  -lnsl  \
	-lsocket -lm

doesn't work, it generates a 2KB executable.

If I use the same command line, but use CC instead of ld, I get a 9MB 
executable that works.

Is there any way to make this work ?

--
Christophe Dupre
System Administrator, Scientific Computation Research Center
Rensselaer Polytechnic Institute
Troy, NY        USA
Phone: (518) 276-2578  -  Fax: (518) 276-4886

0
Reply Christophe 9/4/2003 8:43:23 PM

Christophe Dupre <duprec@scorec.rpi.edu> writes:

> The trouble is, they don't have SunWorkshop over there, and our code
> (and the 3rd party library) is compiled with it.

They could get a free trial license
-- 
Chris Morgan
   "Post posting of policy changes by the boss will result in 
    real rule revisions that are irreversible"

		- anonymous correspondent
0
Reply Chris 9/4/2003 9:02:26 PM


On Thu, 4 Sep 2003, Christophe Dupre wrote:

> Hello,
> I've received a weird request this morning. Someone in my group want to
> send a programmed developped here to a potential sponsor. We can't give
> them our source code, and we can't give them an executable because its
> linked with libraries we can't redistribute.
>
> the sponsor has all the required libraries, one of which is in C++. Our
> code is also C++.

In that case, I don't see the problem.  Just use dynamic
linking, and away you go.  Send you sponsor your binary
(plus any of your own libs), and it should work.

If I compile "Hello World" here, I can send you the resulting
binary without also giving you a copy of my libc, can't I?

-- 
Rich Teer, SCNA, SCSA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net

0
Reply Rich 9/4/2003 9:24:46 PM

Rich Teer wrote:
> On Thu, 4 Sep 2003, Christophe Dupre wrote:
> 
> 
>>Hello,
>>I've received a weird request this morning. Someone in my group want to
>>send a programmed developped here to a potential sponsor. We can't give
>>them our source code, and we can't give them an executable because its
>>linked with libraries we can't redistribute.
>>
>>the sponsor has all the required libraries, one of which is in C++. Our
>>code is also C++.
> 
> 
> In that case, I don't see the problem.  Just use dynamic
> linking, and away you go.  Send you sponsor your binary
> (plus any of your own libs), and it should work.
> 
> If I compile "Hello World" here, I can send you the resulting
> binary without also giving you a copy of my libc, can't I?
> 
If it was that simple... The C++ library is only available as a static 
library. :-(

-- 

--
Christophe Dupre
System Administrator, Scientific Computation Research Center
Rensselaer Polytechnic Institute
Troy, NY        USA
Phone: (518) 276-2578  -  Fax: (518) 276-4886

0
Reply Christophe 9/5/2003 12:53:29 PM

Christophe Dupre <duprec@scorec.rpi.edu> writes:

>If it was that simple... The C++ library is only available as a static 
>library. :-(

Surely you mean "only avaiable as a dynamic library"?
(The dynamic library ships with Solaris)

Casper
-- 
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
0
Reply Casper 9/5/2003 3:01:16 PM

On Fri, 5 Sep 2003, Christophe Dupre wrote:

> If it was that simple... The C++ library is only available as a static
> library. :-(

Ah.  Time to hassle the library vendor for a dynamic version,
then.  Why one would only want a static library is beyond me.

-- 
Rich Teer, SCNA, SCSA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net

0
Reply Rich 9/5/2003 3:58:29 PM

Christophe Dupre <duprec@scorec.rpi.edu> writes:
> ld -o a.out libfoo.a -lcommercialLib1 -lcommercialLib2  -lnsl  \
> 	-lsocket -lm
> 
> doesn't work, it generates a 2KB executable.
> 
> If I use the same command line, but use CC instead of ld, I get a 9MB 
> executable that works.

Use CC -v to see what else is linked in. Possibly you could
create an incomplete executable foo.o using ld -r instead of
creating libfoo.a (or use -z allextract).


Markus
0
Reply mgyger 9/5/2003 4:22:14 PM

"Christophe Dupre" <duprec@scorec.rpi.edu> wrote:
> > In that case, I don't see the problem.  Just use dynamic
> > linking, and away you go.  Send you sponsor your binary
> > (plus any of your own libs), and it should work.
> > 
> > If I compile "Hello World" here, I can send you the resulting
> > binary without also giving you a copy of my libc, can't I?
> > 
> If it was that simple... The C++ library is only available as a static 
> library. :-(

As far as the Solaris libraries go, the shared C++
libraries are shipped with Solaris. You might have to add
-lCrun and/or -lCstd to your link line, as 
CC -G will not automatically add these to the link line.
See the documentation on how to create shared libraries
    http://docs.sun.com/source/817-0926/Building.Libs.html



Thomas
0
Reply Thomas 9/5/2003 5:36:31 PM

7 Replies
133 Views

(page loaded in 0.109 seconds)

Similiar Articles:













7/28/2012 3:53:38 AM


Reply: