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

  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
    28,412
    I copied and pasted your code, but cannot duplicate the error on the MinGW port of g++ 3.4.5.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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,895
    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 11: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,895
    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, 12:36 PM
  2. Replies: 3
    Last Post: 12-06-2008, 07: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, 01: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