Solved

C-compiling problem

Posted on 2000-03-06
9
220 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 learn how to clear a vector as well as how to detect empty vectors in C++.

856 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