Solved

C-compiling problem

Posted on 2000-03-06
9
217 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:pucko
Comment Utility
I'm using gcc 2.95 (tried gcc 2.7.2.3 but it did not work either
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Author Comment

by:pucko
Comment Utility
and the header files is from glibc2.1
0
 

Expert Comment

by:042
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
hmmm it works now... thnks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now