Thread: Why oh why strcpy?

  1. #46
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Interestingly, I have found information that supports what john.c is talking about, because I was curious myself. I'm not on a system where linking mathlib.a matters, so I can't personally corroborate what he's saying. It appears that userxbw doesn't have a system where it matters, either. In general though, I thought it should matter what order gcc receives arguments, and didn't buy into statements that said otherwise. The ultimate test would be linking your own libraries or third party libraries.

    It would seem from the fruit of a web search that john.c is right, though. This person corroborates:

    c - gcc will not properly include math.h - Stack Overflow

    Particularly this part, which is right at the start:
    The problem is coming from the linker, ld, rather than gcc (hence the exit status message). In general ld requires objects and libraries to be specified in the order user supplier, where user is an object that uses a library function and supplier is the object which provides it.
    This speaks to the order in which arguments should be supplied, such that gcc can link your program successfully (with ld).

    For the record, the *manual* supports what john.c and others are saying:
    -llibrary
    -l library

    Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)

    It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after file foo.o but before bar.o. If bar.o refers to functions in ‘z’, those functions may not be loaded.

    The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.

    The directories searched include several standard system directories plus any that you specify with -L.

    Normally the files found this way are library files—archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l surrounds library with ‘lib’ and ‘.a’ and searches several directories.
    Using the GNU Compiler Collection (GCC): Link Options

    Can we stop with the personal attacks?
    Last edited by whiteflags; 12-11-2017 at 06:31 PM. Reason: removed annoying table formatting

  2. #47
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    Interestingly, I have found information that supports what john.c is talking about, because I was curious myself. I'm not on a system where linking mathlib.a matters, so I can't personally corroborate what he's saying. It appears that userxbw doesn't have a system where it matters, either. In general though, I thought it should matter what order gcc receives arguments, and didn't buy into statements that said otherwise. The ultimate test would be linking your own libraries or third party libraries.

    It would seem from the fruit of a web search that john.c is right, though. This person corroborates:

    c - gcc will not properly include math.h - Stack Overflow

    Particularly this part, which is right at the start:

    This speaks to the order in which arguments should be supplied, such that gcc can link your program successfully (with ld).

    For the record, the *manual* supports what john.c and others are saying:

    Using the GNU Compiler Collection (GCC): Link Options

    Can we stop with the personal attacks?
    you missed that key word ... here let me highlight it for you.
    Code:
    It makes a difference where in the command you write this option; the linker searches 
    and processes libraries and object files in the order they are specified.  
    Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after file foo.o but before bar.o.  
    If bar.o refers to functions in ‘z’, those functions may not be loaded.
    does anyone understand the usage of that word in a sentence besides me?
    pointing out someone that is slandering is not a personal attack ... pointing out the fact that someone may be suffering from OCPD, aka anal is not an attack.
    Last edited by userxbw; 12-11-2017 at 06:53 PM.

  3. #48
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    You don't seem to understand that in context, the manual is saying that not putting libraries in the right place can lead to linker errors, and that's why -l options are usually at the tail end of commands that work.

    I mean sure, when you compile trivial programs, you can get creative with the order of arguments if you want. That doesn't mean that gcc isn't programmed with some usage expectations, and you shouldn't be surprised if coming at gcc with a literal word salad doesn't work. I will also personally apologize to you (even though I have no reason to) because what john.c critiqued didn't personally apply to you. Still I think it is appropriate, since it is still C we are discussing, and people may be wondering about your usage of "-lm" and why it doesn't matter for them, or why it doesn't work for them.

  4. #49
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    You don't seem to understand that in context, the manual is saying that not putting libraries in the right place can lead to linker errors, and that's why -l options are usually at the tail end of commands that work.

    I mean sure, when you compile trivial programs, you can get creative with the order of arguments if you want. That doesn't mean that gcc isn't programmed with some usage expectations, and you shouldn't be surprised if coming at gcc with a literal word salad doesn't work. I will also personally apologize to you (even though I have no reason to) because what john.c critiqued didn't personally apply to you. Still I think it is appropriate, since it is still C we are discussing, and people may be wondering about your usage of "-lm" and why it doesn't matter for them, or why it doesn't work for them.
    oh my my can and may are not the same as will and shall. therefore that leaves room for what?

    it is like a mother that says, if you fall of that chair you will break your leg,

    the kid falls off the chair, he does not break a leg.

    mom told a lie.

    better she said, you can break your leg if you fall off that chair it . not will break your leg. always speaking to a child like that first example could lead to psychological issues.

    look how you formed your sentence as you did.
    "right place can lead to linker errors, and that's why -l options are usually at the tail end of commands that work."
    that shows you have somewhere an understanding that it is not a concert result if you place it elsewhere. because if my placing my -lm where I do would cause an error then that little code he wrote would have done just that , caused an error. but t didn't it worked. so I am not wrong. He is, and he slandered my user name in the process.
    Last edited by userxbw; 12-11-2017 at 07:10 PM.

  5. #50
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    FFS, this isn't worth arguing about. Are you battling with me because he called you an idiot about this? Is that all? Does that mean that your married to the idea that you're correct, and no one can teach you anything different?

    It worked out this time. I never EVER doubted this, in fact I said in my own post that you were on a machine where linking mathlib.a doesn't matter!

    I just hope, that with the freaking *manual* on my side, you would revise your commands when linking does matter!

    For other people, that will be beneficial. For other people, this conversation is beneficial.

  6. #51
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    FFS, this isn't worth arguing about. Are you battling with me because he called you an idiot about this? Is that all? Does that mean that your married to the idea that you're correct, and no one can teach you anything different?
    now you are assuming, it is about a truth, and he is wrong, trying to make me be like him , which he holds an apparent abnormal personalty trait, which is, it can only be the way he says it has to be, when the manual clearly states it is not,if you know how to understand the differences I pointed out, and I proved him wrong. Only shows he is the one with the issues not I.


    It worked out this time. I never EVER doubted this, in fact I said in my own post that you were on a machine where linking mathlib.a doesn't matter!
    I honestly doubt that until you prove me otherwise. and if it is true then that just makes Linux that much better to be able to still use -lm in the command line where I put it. Because again It works for the same reasons the Manual stated, MAY NOT be loaded, means it can be loaded too. Because WE'RE NOT REALLY SURE SO WILL JUST WRITE IT LIKE THAT INSTEAD OF TRYING TO GO ALL INTO IT. Just to play it safe.


    I just hope, that with the freaking *manual* on my side, you would revise your commands when linking does matter!
    I never said that! Get it right for crying out loud. I said that where I am placing the -lm in my command line works! So him trying to dictate to me that I am wrong and I HAVE TO do it is way or I am an idiot in his eyes, and everyone elses, that comment shows signs of abnormality. Because he is too ridged with this abnormal personality trait cannot phantom it any other way then what he has been told to be true. So he sees it that it HAS to be that way or no way. ridge thinking. when the docs stated what? MAY key word there.

    For other people, that will be beneficial. For other people, this conversation is beneficial.
    I already showed you why it is in the MANUAL itself where it uses the words MAY BE. and what they mean. so is it you now that are you the one that is NOT wanting to be taught? yet you are accusing me of that? why?

    maybe you posses a little bit too much pride yourself in this matter.
    Last edited by userxbw; 12-11-2017 at 07:29 PM.

  7. #52
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by userxbw View Post
    now you are assuming, it is about a truth, and he is wrong, trying to make me be like him , which he holds an apparent abnormal personalty trait, which is, it can only be the way he says it has to be, when the manual clearly states it is not,if you know how to understand the differences I pointed out, and I proved him wrong. Only shows he is the one with the issues not I.
    Why do you care?

    I honestly doubt that until you prove me otherwise.
    That's fine, a doubt is better than an assurance that you're correct in general.

    I never said that! Get it right for crying out loud. I said that where I am placing the -lm in my command line works!
    Because you don't need to link -lm at all. You probably won't need to explicitly, even when you use math functions. This doesn't mean that in general, you can put -l commands anywhere and expect them to work.
    I already showed you why it is in the MANUAL itself where it uses the words MAY BE. and what they mean. so is it you now that are you the one that is NOT wanting to be taught? yet you are accusing me of that? why?
    Because it's a technicality. I would rather not get by on technicalities like this. It just leads to annoying linker errors to fix when my assumptions are wrong.

    maybe you posses a little bit too much pride yourself in this matter.
    You have a smart mouth, doctor.

  8. #53
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    Why do you care?
    I already told you . it is a truth that he is making into a lie. Then is accusing me of being the one that is spreading falsehoods. know you not a deceiver when you see one or hear one?


    That's fine, a doubt is better than an assurance that you're correct in general.

    Because you don't need to link -lm at all.
    you are Wrong, YES I DO!

    LOOK SEE. notice the non use of -lm
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
     
     
    int main(int argc, char **argv) {
        
        if (argc != 2) {
            fprintf(stderr, "Usage: sqrt VALUE\n");
            exit(EXIT_FAILURE);
        }
        printf("%lf\n", sqrt(atof(argv[1])));
        return 0;
    }
    
    // errors
    gcc -Wall -Wextra -pedantic  -o "term2" "term2.c" (in directory: /home/userx/bin)
    /tmp/ccy45lIM.o: In function `main':
    term2.c:(.text+0x51): undefined reference to `sqrt'
    collect2: error: ld returned 1 exit status
    Compilation failed.
    it now seems you've taken on this personal vendetta against me as well.

    are you too having a hard time accepting the fact that that I am right about what I stated. MAY means what and SHALL means what?


    You probably won't need to explicitly, even when you use math functions. This doesn't mean that in general, you can put -l commands anywhere and expect them to work.
    what a ridiculous statement, even If I didn't work.. then what? duh if it don't work one way try something different. how hard is that?

    BUT it does work so why fix it if it is not broke? it works for the very same reason I pointed out in the Manual. Key words


    Because it's a technicality. I would rather not get by on technicalities like this. It just leads to annoying linker errors to fix when my assumptions are wrong.

    You have a smart mouth, doctor.
    Thank you!!!!!


    well that is you,, and I am me, and it works. I am not that ridged in my thinking or (that) insecure in my ways.

    and, actually being called a smart ass, or a smart mouth as you put it, is a complement.


    think about it. if you cannot figure that one out, I'll tell you if you really want to know why.
    Last edited by userxbw; 12-11-2017 at 07:54 PM.

  9. #54
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    it now seems you've taken on this personal vendetta against me as well.
    Why do you do this? It's not a vendetta. Even if it was, think about where you are and how much it really matters.

    are you too having a hard time accepting the fact that that I am right about what I stated. MAY means what and SHALL means what?
    Clearly it means that you will do what works for you and stop thinking there. Look, clearly, there are people for whom this topic does matter, because I don't think john.c is making up his own evidence. What about the person I linked from stack exchange? You can't simply tell me that this subject is a complete non-issue. It's just that generally, -l commands at the end is the most portable because regardless of the technicality it WILL work.

    That is all anyone is saying, you don't have to argue it.

  10. #55
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    Why do you do this? It's not a vendetta. Even if it was, think about where you are and how much it really matters.
    you're the one that stepped in and is keeping it going. think about that then re read your statement.
    Clearly it means that you will do what works for you and stop thinking there. Look, clearly, there are people for whom this topic does matter, because I don't think john.c is making up his own evidence. What about the person I linked from stack exchange? You can't simply tell me that this subject is a complete non-issue. It's just that generally, -l commands at the end is the most portable because regardless of the technicality it WILL work.

    That is all anyone is saying, you don't have to argue it.
    and what the *$*(!@*(#$*(@#$*(@#$ did I say about his matter?

    wait let me go find it again because I need to,
    it works on the home work in here so I'm not going to get all that over it thanks.
    NO WHERE IN There did I even ever state for anyone one else to do what I am doing in that/this matter. Period! go and get on the perpetrator butt for this and NOT I.

    you're barking up the wrong tree. HELLO!

    have a good sleep knowing you cannot even sniff out the rat.

    again I will side with the documentation MAY does not mean SHALL!
    Last edited by userxbw; 12-11-2017 at 08:04 PM.

  11. #56
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    again I will side with the documentation MAY does not mean SHALL!
    You're defending yourself like it says WON'T.

  12. #57
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    You're defending yourself like it says WON'T.
    go back to school . because that is what you need to do on this matter of words and their usage.

    all you're doing is keeping on trying to prove me wrong in what I stated when i am not and You picked the wrong side to defend so now it looks like you're having a really hard time with admitting to yourself that I am actually correct and you are not nor is that other one.

    again
    NO WHERE IN There did I even ever state for anyone one else to do what I am doing in that/this matter. Period! go and get on the perpetrator butt for this and NOT I.

    you're barking up the wrong tree. HELLO!

    have a good sleep knowing you cannot even sniff out the rat.

    again I will side with the documentation MAY does not mean SHALL!
    Last edited by userxbw; 12-11-2017 at 08:23 PM.

  13. #58
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Well, I mean, apart from "may not," which in no way suggests that you are always correct, there is nothing wrong with anything I've actually said so ........ you.

  14. #59
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    Well, I mean, apart from "may not," which in no way suggests that you are always correct, there is nothing wrong with anything I've actually said so ........ you.
    where do you get this idea that I am trying to suggest that I am always correct .. ( about everything) over this "may not" being the key word thing about -lm?

    why are you trying to project your self image on to me?

    I am correct in what I have stated in here about this matter of -lm that you are now trying to deflect ... and bring about more calamity over it. Is it because you're having a really hard time admitting to yourself first then to me that I am correct about this -lm thing?

    Pride is a hard pill to sallow some times.

    got a go, tomorrow is another day.
    Last edited by userxbw; 12-11-2017 at 08:59 PM.

  15. #60
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by userxbw View Post
    where do you get this idea that I am trying to suggest that I am always correct .. ( about everything) over this "may not" being the key word thing about -lm?
    It's not just about -lm... it's about linking in general. I do not appreciate you calling people liars, and OCPD over the internet on any matter. It's extremely rude and beside the point.

    why are you trying to project your self image on to me?
    I'm not.

    I am correct in what I have stated in here about this matter of -lm that you are now trying to deflect ... and bring about more calamity over it. Is it because you're having a really hard time admitting to yourself first then to me that I am correct about this -lm thing?
    You've denied plain and simple evidence to the contrary, or does the example in post#46 not matter, from stack exchange? Does the evidence john.c posted of a compile not working, not matter? The whole problem is that you're stuck on your own experience. Because you don't have to deal with this issue yourself, you don't care that other people might. So when someone tries to point out information that doesn't gel with your "it works for me" attitude, you would rather frame it as a vendetta against you, potentially discrediting the person simply trying to give a broader perspective. Personally, I don't have to worry about -lm at all, or even -lpthread, but you don't see me defending my experience in contrast to documentation, (which says it does matter) by interpreting it to the letter. How about you reread the thread again, and get a clue?

    You're right. How god damn helpful that must be.

    And I say again, because it really bothers me, you routinely casually accusing people of having mental problems is very unprofessional. To drag that in to this little spat, just to make yourself look correct... Frankly, nothing makes me disrespect you more. I hope your university revokes your degree when you get in trouble. I wish I didn't mean that, but frankly, you suck. You have no real sense of professional ethics. You suck.

    Your research sucks. Your class sucks. Your therapy sucks. Whatever you're doing with your god damn degree, it sucks. It clearly went to your otherwise empty head. And if you're doing nothing with it, you're just stupid. If you're just lying about your degree, which is possible... congratulations on a successful troll, first of all. But still you are a ........ing ass hole. And try to weasel your way out of that one with some bull crap interpretation that you will post.

    I hope a mod locks this thread so I don't have to read more psychobabble in the morning.

    I am so sick and tired of that bull crap. Just ........ing stop. You're never so right or so insulted that you need to resort to such tactics.

    Pride is a hard pill to sallow some times.

    got a go, tomorrow is another day.
    Indeed. Especially when the person telling you to swallow their pride can't do it either. But, oh, that is just an opinion that I am having. What a shame.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2010, 07:42 AM
  2. strcpy
    By bobbelPoP in forum C++ Programming
    Replies: 4
    Last Post: 07-28-2008, 08:44 PM
  3. strcpy
    By Unregistered in forum C++ Programming
    Replies: 6
    Last Post: 08-01-2002, 01:39 PM
  4. HELP!! strcpy
    By abbynormal87 in forum C++ Programming
    Replies: 3
    Last Post: 05-02-2002, 07:34 AM

Tags for this Thread