Solved

C-compiling problem

Posted on 2000-03-06
9
222 Views
Last Modified: 2010-04-02
I'm trying to compile this:
http://packetstorm.securify.com/0003-exploits/sXe.c
(no i'm not a bad as... just trying to check out my own network)
And get this:

sXe.c:63: initializer element is not constant


row 64 looks like this:
FILE * stream  = stderr;

How can i fix that....
0
Comment
Question by:pucko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 2588970
This is only a warning. However, changing the line to read

FILE * stream  = ( const FILE*) stderr;

should do it...
0
 
LVL 1

Author Comment

by:pucko
ID: 2589355
It's not only a warning because I dont get any file to run when i do a gcc file.c -o file

And the changes you said just give me a warning. I still have the error I had before...

Now I get:
sXe.c:63: warning: initialization discards qualifiers from pointer target type
sXe.c:63: initializer element is not constant
0
 
LVL 3

Expert Comment

by:msmits
ID: 2589484
I can compile the code without any errors with gcc 2.7.2.1 on FreeBSD. There seems to be something wrong with your header files.
Can you tell which OS and which version of gcc you are using?
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 1

Author Comment

by:pucko
ID: 2589499
I'm using gcc 2.95 (tried gcc 2.7.2.3 but it did not work either
0
 
LVL 1

Author Comment

by:pucko
ID: 2589502
and the header files is from glibc2.1
0
 

Expert Comment

by:042
ID: 2601276
You should look for the declaration/assignement of "stderr" in your header files and post it here, it could help...

For now you can try this:

remove the assignement in the declaration,
replace FILE * stream = stderr;
with FILE * stream;

and move the assignement to the begining of the main

int main (int argc, char * * argv)
{
  FILE * fptr;
  u_int pos = 0;
  u_char type = 0;
  u_char code = 0;
  u_long victim = ERR;
  u_char * ptr = *argv;
  u_char * fname = NULL;

  stream = stderr; /* line to add */

  ++argv; --argc;

0
 
LVL 1

Author Comment

by:pucko
ID: 2601610
That gives me:

[root:/home/pucko/download]$ gcc sXe -o sxe
sXe: In function `_init':
sXe(.init+0x0): multiple definition of `_init'
/usr/lib/crti.o(.init+0x0): first defined here
sXe: In function `_start':
sXe(.text+0x0): multiple definition of `_start'
/usr/lib/crt1.o(.text+0x0): first defined here
sXe: In function `_fini':
sXe(.fini+0x0): multiple definition of `_fini'
/usr/lib/crti.o(.fini+0x0): first defined here
sXe(*ABS*+0x804a3a0): multiple definition of `_GLOBAL_OFFSET_TABLE_'
/usr/lib/crti.o(.got.plt+0x0): first defined here
sXe: In function `__data_start':
sXe(.data+0x0): multiple definition of `__data_start'
/usr/lib/crt1.o(.data+0x0): first defined here
/usr/lib/crti.o(.dynamic+0x0): multiple definition of `_DYNAMIC'
collect2: ld returned 1 exit status

I don't know which header file to post.
stdio.h ?
Shall I post the whole file here?
(its 631 lines)      

Or is this enough?

/* Standard streams.  */
extern FILE *stdin;            /* Standard input stream.  */
extern FILE *stdout;            /* Standard output stream.  */
extern FILE *stderr;            /* Standard error output stream.  */
/* C89/C99 say they're macros.  Make them happy.  */
#define stdin stdin
#define stdout stdout
#define stderr st
0
 

Accepted Solution

by:
042 earned 50 total points
ID: 2611659
Well no need to post any header now,
because it works (yes it does)...
well compilation works ;)
"ld returned 1 exit status"
ld is the linker.

You can check that way:
1) compile: gcc -c sXe
this should generate an sXe.o and everything should be ok (for now).
If this is the case compilation worked.
2) link: gcc sXe.o -o sxe
You should now get the multiple definition error messages.
(or maybe the link will work that way)

Now I'm not sure what's going on, please try this and let me know if i'm right for now.


0
 
LVL 1

Author Comment

by:pucko
ID: 2613448
hmmm it works now... thnks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question