gcc help please

Kick Back and Relax in the Cheers! Forum. Thoughts on life or want advice or thoughts from other pca members. Or just plain "chill". Originator of da Babe threads.
Post Reply
User avatar
tyler_durden
Senior Member
Posts: 319
Joined: Sat Dec 02, 2000 2:20 am
Location: AGGIELAND: College Station, Texas

gcc help please

Post by tyler_durden »

i am working on a school project for my operating sytems class. i dont have alot of expierence working with gcc. Our project is to write a shell in unix. our prof gave us a file that will parse the input, we then have to run the commands. everything works fine on the solaris machines at school. when i go to make the file i get the following error. how can i force the compilation?

make mysh
gcc -o mysh mysh.o parse.o
collect2: ld terminated with signal 11 [Segmentation fault]
mysh.o: In function `main':
mysh.o(.text+0x28): the `gets' function is dangerous and should not be used.
make: *** [mysh] Error 1

is there something i can run to overide that check.
"Life is short, Factoring is long"
-G. R. Blakley

"I'm like the Pythagorean Theorum, I cant be solved"
--Shaquille O'Neal
User avatar
poop
Golden Member
Posts: 1042
Joined: Fri Mar 23, 2001 12:40 pm
Location: Lexington, KY
Contact:

Post by poop »

Well, techincally, you should try to use fgets since gets is a security hazard. ;)

It doesn't look like gcc is failing, it is the linker (ld). The linker will essentially take mutliple binary files as input and link them together with common symbol tables and such so they make a nice, monolithic executable file. gcc actually calls ld to link the files you specify. It uses a set of default arguments.

Thus, you need to send a command to gcc in order for gcc to tell ld to ignore the warning. I don't know the command line switch that you need, but I will search.

Try man ld and see what your system says about forcing a link. It will most likely be in the 'Options' heading, and will be proceeded with a '-b'. So, if you want the option noquiet, you type: gcc -bnoquiet -o >output< >input list<

Try "-bnoerrmsg" though I am not sure it will work. This option disables error messages from the linker.
- p o o p
User avatar
tyler_durden
Senior Member
Posts: 319
Joined: Sat Dec 02, 2000 2:20 am
Location: AGGIELAND: College Station, Texas

Post by tyler_durden »

i fixed the problem witht he gets, just replaced it with fgets. but i am still gettting the

collect2: ld terminated with signal 11 [Segmentation fault]


any ideas?
"Life is short, Factoring is long"
-G. R. Blakley

"I'm like the Pythagorean Theorum, I cant be solved"
--Shaquille O'Neal
User avatar
poop
Golden Member
Posts: 1042
Joined: Fri Mar 23, 2001 12:40 pm
Location: Lexington, KY
Contact:

Post by poop »

hrm... if you want, e-mail me your makefile and I will take a look at it.

I might be able to figure out what is going on.
- p o o p
User avatar
tyler_durden
Senior Member
Posts: 319
Joined: Sat Dec 02, 2000 2:20 am
Location: AGGIELAND: College Station, Texas

Post by tyler_durden »

i figured out the problem, our prof gave us the make file, it compiles the our file, and the file he gave us into .o files (object files) then it links those into a single output. the linker keeps throwing an error. i just compiled the code using gcc. theys seem to compile, tbey arn't running right, even though they work fine on the schools spark machines using gcc. so i don't know what it is.
"Life is short, Factoring is long"
-G. R. Blakley

"I'm like the Pythagorean Theorum, I cant be solved"
--Shaquille O'Neal
User avatar
poop
Golden Member
Posts: 1042
Joined: Fri Mar 23, 2001 12:40 pm
Location: Lexington, KY
Contact:

Post by poop »

So he gave you the source and pre-made output files? What kind of machine are you trying to compile on? You mention it works fine on a Sun Sparc (Solaris, I assume). If you are trying to use DJGPP, then I can see where you might have some probs. But as long as you are using properly configured GNU tools on a properly configured *nix system, I don't know why the code will work on one machine adn not another.

I also assume you are using POSIX commands and stdio for most of your stuff... Hrm... C is one of those things that is nearly impossible to help someone with without being there. Sorry I cannot help too much.
- p o o p
Post Reply