Solved

C-compiling problem

Posted on 2000-03-06
9
219 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
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual c++ and text files 7 68
C language IDE – Compilers installation 14 71
Dialogbox API leak? 18 96
trigs fail! I thought I knew how to do trignometry 3 67
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

803 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