Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
I used gcc compiler (I think the version was 4.4.3 on Ubuntu 10.04) for some time in the past for many codes written in C, that are basically the same ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2012
    Posts
    5

    Problem with gcc or something else


    I used gcc compiler (I think the version was 4.4.3 on Ubuntu 10.04) for some time in the past for many codes written in C, that are basically the same but with different constants. Everything worked just fine.
    But we got new computers at work and system administrator installed Scientific Linux release 6.2 (Carbon) with gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) x86_64-redhat-linux. The simulations are not working like they used to.

    In the code I have a variable that represents time, and it is unsigned long int. Now, when that variable reaches around 2 147 483 648 the program enters an infinite loop. And it's the case with every single code that worked completely normal.

    I'm not an expert and I'm just assuming that it has something to do with gcc.
    Any answer will be highly appreciated.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,380
    It may be one of many things. Please post your problematic code here. The differences between gcc 4.4.3 and 4.4.6 are minimal at most.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Location
    California
    Posts
    98
    hmmmm,
    Seems to me that your compiler is producing 32 bit code and that your "unsigned long" is somehow only using 31 bits.

    The number you have mentioned is almost precisely 2^31-1 which would be a "long" not an unisigned long.

    Andy

  4. #4
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    How are you declaring the variables? "int" doesn't have a defined bit length. I believe the rules are it must be longer or equal to a short and shorter than or equal to a long. Typically, on many 32 bit systems, a long or an int both are 32 bits. It's possible (legal) for a long to be 64, though.

  5. #5
    Just Joined!
    Join Date
    Feb 2010
    Posts
    26
    The problem is not with the GCC compiler. Its something that you have to do with architecture over which you are performing computing. It seems that the earlier system that you were using was a 64 bit system and now it is a 32 bit system.

    If that is the case, change the variable type from long int to long long. This will resolve your problem.

    Cheers,

  6. #6
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    Quote Originally Posted by junmuz View Post
    The problem is not with the GCC compiler. Its something that you have to do with architecture over which you are performing computing. It seems that the earlier system that you were using was a 64 bit system and now it is a 32 bit system.

    If that is the case, change the variable type from long int to long long. This will resolve your problem.

    Cheers,
    Yeah, this is what I was saying.

    You need to remember that short, int, and long, aren't specified sizes, they're 'typically' dictated by the architecture, but are only dictated relative to each other, which is why I asked how you declared it.

    Anyways, I definitely agree that's the issue.

  7. #7
    Just Joined!
    Join Date
    Aug 2012
    Posts
    5
    Thank you all for the responses.
    I won't post the code because it has more than 1000 lines, and unfortunately the problematic variable is global.
    I declared it like unsigned long int, and tried before posting a thread to declare it like long long, but it gets stuck again. Some other weird stuff happened in the mean time, so I'll have to do some more testing before I post anything concrete.
    Thanks again.

  8. #8
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    Quote Originally Posted by olivia View Post
    Thank you all for the responses.
    I won't post the code because it has more than 1000 lines, and unfortunately the problematic variable is global.
    I declared it like unsigned long int, and tried before posting a thread to declare it like long long, but it gets stuck again. Some other weird stuff happened in the mean time, so I'll have to do some more testing before I post anything concrete.
    Thanks again.
    Do you still have access to the old machine?

    If so, print the sizeof() an unsigned long long on both systems. There's no standard for what it needs to be, it's kind of variant depending on the system and what other types are.

  9. #9
    Just Joined!
    Join Date
    Aug 2012
    Posts
    5
    No I don't have. But you gave me an idea, and I remembered that I've backuped, not only results but executable files too. It turns out that they are 32bits, and my new machine generates 64bits. So I've just installed glibc-devel.i686 and compiled it with flag -m32. So problem solved . Thanks everybody .

  10. #10
    Just Joined!
    Join Date
    Aug 2012
    Posts
    5
    Just for the sake of curiosity, why is this a problem? I could understand that the opposite situation is causing problems but I don't know about this one. If anyone can explain me briefly or suggest a site with some explanation it would be great. On net I just found what you have to do to fix the problem, but no why.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •