unrecognized option '--hash-style=both'?

This is a discussion on unrecognized option '--hash-style=both'? within the C++ Programming forums, part of the General Programming Boards category; A simple code compiled in linux: Code: #include <stdio.h> #include <stdlib.h> int main () { int i; char szInput [256]; ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    unrecognized option '--hash-style=both'?

    A simple code compiled in linux:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main ()
    {
        int i;
        char szInput [256];
        printf ("Enter a number: ");
        fgets ( szInput, 256, stdin );
        i = atoi (szInput);
        printf ("The value entered is %d. The double is %d.\n",i,i*2);
        return 0;
    }
    I used "gcc test.cpp -o test" and got the weird errors:

    /usr/bin/ld: unrecognized option '--hash-style=both'
    /usr/bin/ld: use the --help option for usage information
    collect2: ld returned 1 exit status

    Anything wrong?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    theres nothing wrong with the code. for convention, C files should have extension .c, not .cpp which is usually for c++ code.

    it looks like somethings wrong with your development environment.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    Thanks. But what kind of problem could the environment be?
    I tried g++ still the same error.

    Quote Originally Posted by nadroj View Post
    theres nothing wrong with the code. for convention, C files should have extension .c, not .cpp which is usually for c++ code.

    it looks like somethings wrong with your development environment.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    I copied and pasted your code, but cannot duplicate the error on the MinGW port of g++ 3.4.5.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    not sure what kind of problem with your development environment it is. search around for the ld error you got--this is a linux problem. also did you check the --help option? did you install/remove/upgrade any critical software recently (and/or improperly, ie not through a package manager)?

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quite simply, your compiler calls the linker with an option the linker does not recognize. This probably means that your binutils are considerably older than your gcc. Try upgrading the binutils package.

    Also, run
    Code:
    ld -v
    gcc -v
    My system gives 2.18 for ld (the latest) and 4.1.2 for gcc (latest is the 4.2 series).

    Edit: From what I can tell, hash-style was added in 2.17.
    Last edited by CornedBee; 01-19-2008 at 10:14 AM.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    Thanks.
    My id is GNU ld version 2.16
    gcc is 4.1.2

    Quote Originally Posted by CornedBee View Post
    Quite simply, your compiler calls the linker with an option the linker does not recognize. This probably means that your binutils are considerably older than your gcc. Try upgrading the binutils package.

    Also, run
    Code:
    ld -v
    gcc -v
    My system gives 2.18 for ld (the latest) and 4.1.2 for gcc (latest is the 4.2 series).

    Edit: From what I can tell, hash-style was added in 2.17.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I suggest you upgrade your binutils.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    Thanks. I did and now It works.
    Quote Originally Posted by CornedBee View Post
    I suggest you upgrade your binutils.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with unaligned intrinsics
    By The Wazaa in forum C++ Programming
    Replies: 4
    Last Post: 02-18-2009, 11:36 AM
  2. Replies: 3
    Last Post: 12-06-2008, 06:54 PM
  3. Group Project Help/Volunteer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 04-24-2007, 11:36 PM
  4. GCC errors: unrecognized option '--as-needed'
    By axr0284 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 12-09-2004, 12:16 PM
  5. Not sure on hash table memory allocations
    By Thumper333 in forum C Programming
    Replies: 3
    Last Post: 09-27-2004, 09:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21