LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-30-2004, 10:45 PM   #1
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Rep: Reputation: 0
g++ Compiling Question


I am compiling a program on my linux system that I want to run on another linux system. When I run the program on the other system, it says it can't find the shared library libstdc++.so.5. That sounds like some basic stuff to me, but it ain't there.

Is there anyway to make g++ build a standalone execuatable that won't require shared libraries? Or some other way to make it work on another linux system?

BTW, I do not have root access to the other system.

Thanks-
Erik

Last edited by ErikJohnson; 03-30-2004 at 10:47 PM.
 
Old 03-31-2004, 01:44 AM   #2
adz
Senior Member
 
Registered: Jun 2003
Location: Sydney
Distribution: Debian, FreeBSD
Posts: 1,713

Rep: Reputation: 53
You'll have to compile it statically. Look at the "-static" option.
 
Old 03-31-2004, 12:35 PM   #3
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks for the help.

I notice when using the -static option, that the executable file size is exactly the same as it was before. It's like the -static option did nothing. Also, I get the same error.

Am I missing something?

Erik
 
Old 03-31-2004, 03:56 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Chances are that the source you're trying to
compile is looking for something older/newer
than what you actually have installed ...

You could try making a symlink from the
actually present library to .5 ...

[edit]
Ooops, stuff that, you don't have root
access, my bad
[/edit]


Cheers,
Tink
 
Old 03-31-2004, 04:33 PM   #5
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Original Poster
Rep: Reputation: 0
Would it be possible, if I move the required libraries into the runtime directory, to somehow have it find the libraries there, instead of looking for them in the standard spot?

Erik
 
Old 03-31-2004, 05:04 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Sure ... all you'd need is set-up a variable
export LD_LIBRARY_PATH="<where your version lives>"


Cheers,
Tink
 
Old 03-31-2004, 05:25 PM   #7
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Original Poster
Rep: Reputation: 0
Ok... well I exported that, and it seems to be working, however

It already wants more libraries that libstdc++.so.5 depends on, and I fear I will end up in a recursive dependency nightmare! Any idea how many dependent libraries, in total, libstdc++.so.5 requires? If it's more than a couple, I think I would like to pursue the --static route to solving my problem.

Do you have any suggestions why I the -static has no effect?

Thanks for your help-
Erik
 
Old 03-31-2004, 05:50 PM   #8
adz
Senior Member
 
Registered: Jun 2003
Location: Sydney
Distribution: Debian, FreeBSD
Posts: 1,713

Rep: Reputation: 53
Try something like:
Code:
g++ dummy.cpp -o dummy /usr/lib/library1.a /usr/lib/library2.a -static
 
Old 03-31-2004, 06:37 PM   #9
ErikJohnson
LQ Newbie
 
Registered: Mar 2004
Posts: 12

Original Poster
Rep: Reputation: 0
Well, I'm using the -c option for everything in my Makefile, so there shouldn't be any linking taking place anyway, right?

When I remove the -c options, and use -static, it bugs me for this:

cannot find -lstdc++

When I use both -c and -static, nothing is different than if I were to just use -c. And I don't think it makes sense (but I could be wrong) to use the -o option because I am doing lots of stuff in the Makefile:


Code:
# Makefile for snparser

CC     = g++
CFLAGS = -Wall -g 

LEX    = flex
LEXLIB = -lfl
YACC   = bison -ydv

OBJ    = main.o message.o ast.o unparse.o y.tab.o lex.yy.o

snparser: $(OBJ)
	$(CC)  $(OBJ)  -o snparser   $(LEXLIB) ; \
	cp snparser ../finished_text;	


main.o: main.cc ast.h symbol.h scanner.h
	$(CC) -c $(CFLAGS)   main.cc
ast.o: ast.cc ast.h symbol.h
	$(CC) -c $(CFLAGS)   ast.cc
unparse.o: unparse.cc ast.h symbol.h helpers.cc
	$(CC) -c $(CFLAGS)   unparse.cc
message.o: message.cc message.h
	$(CC) -c $(CFLAGS)   message.cc


y.tab.o: y.tab.c
	$(CC) -c $(CFLAGS)   y.tab.c
y.tab.h: y.tab.c
	touch y.tab.h
y.tab.c: grammar.yacc ast.h symbol.h scanner.h
	$(YACC)         grammar.yacc

lex.yy.o: lex.yy.c ast.h symbol.h scanner.h message.h y.tab.h
	$(CC) -c $(CFLAGS)   lex.yy.c  -DYY_NO_UNPUT
lex.yy.c: tokens.lex y.tab.h
	$(LEX) tokens.lex


clean:
	/bin/rm -f *.o lex.yy.c y.tab.*
erase:
	/bin/rm -f *.o lex.yy.c y.tab.*  u1

Maybe I'm in too deep!

Erik
 
Old 04-01-2004, 07:48 AM   #10
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276

Rep: Reputation: 31
Hi Erik,

just some hint:
>It already wants more libraries that libstdc++.so.5 depends on, and I fear
>I will end up in a recursive dependency nightmare! Any idea how many
>dependent libraries, in total, libstdc++.so.5 requires?
At the console, type ldd <nameofbinary>; this will dump the dependencies
of the file.

HTH
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling c++ question bluknight43 Programming 3 02-17-2005 06:12 AM
compiling 2.6.8.1 question noxious Slackware 11 09-29-2004 04:34 PM
compiling question phil81 Linux - Software 5 06-02-2004 08:46 AM
Compiling Question fotoguy Linux - Software 0 05-24-2003 04:41 AM
Compiling Question Bigun Linux - Software 2 01-03-2003 03:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration