Thread: EXTREMELY Weird problem...

  1. #16
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by bithub View Post
    He said that he couldn't do that (although I'm not sure of the cause).
    no, he set the /mt and /md switches directly from what i gathered (otherwise why even mention the switches) rather than through the IDE, which can cause problems. He needs to set them specifically through the IDE in VS2008Express

  2. #17
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by abachler View Post
    no, he set the /mt and /md switches directly from what i gathered (otherwise why even mention the switches) rather than through the IDE, which can cause problems. He needs to set them specifically through the IDE in VS2008Express
    Ah, I see. I didn't realize there was a difference.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #18
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by bithub View Post
    Ah, I see. I didn't realize there was a difference.
    There shouldn't be, but there is. Apparently sometimes the IDE doesn't expect switches to override certain behaviors, so it just blindly adds any 'special' switches to the end of the ones it generates from the project settings. the compiler must go by the first one it finds, and ignore conflicting switches.

  4. #19
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Nope, I set them through the IDE. Here's a screen shot of the errors I get when I compile with the /MT switch set in the IDE like you described:

    http://img17.imageshack.us/img17/765/errorsi.jpg

    I mentioned them because I couldn't compile with /MT and I was wondering if that was possibly a cause of the problem >< And judging by what you're saying, it is.
    Last edited by pobri19; 08-08-2009 at 12:32 AM.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  5. #20
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Those errors are because you are linking to both the static multi-threaded CRT, and the dynamic multi-threaded debug DLL. You can only link to one runtime library.
    bit∙hub [bit-huhb] n. A source and destination for information.

  6. #21
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Quote Originally Posted by bithub View Post
    Those errors are because you are linking to both the static multi-threaded CRT, and the dynamic multi-threaded debug DLL. You can only link to one runtime library.
    Uh, forgive my ignorance but where am I linking to the dynamic MT debug DLL? :P I cannot see it any where.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  7. #22
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by pobri19 View Post
    Uh, forgive my ignorance but where am I linking to the dynamic MT debug DLL? :P I cannot see it any where.
    See where it says "MSVCRTD.lib" in the file column? MSVCRTD.lib is the static linkage which will link to MSVCRTD.dll during runtime.
    bit∙hub [bit-huhb] n. A source and destination for information.

  8. #23
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Quote Originally Posted by bithub View Post
    See where it says "MSVCRTD.lib" in the file column? MSVCRTD.lib is the static linkage which will link to MSVCRTD.dll during runtime.
    Yeah I see that, but what I'm saying is I'm not explicitly linking to MSVCRTD.dll or MSVCRTD.lib in my linker/compile options anywhere (unless it did that by default, in that case I cannot see where). Is there some type of compiler report I can generate to show you the settings ahah.... Are you trying to say I shouldn't be using /MT? Or is there some other option I should change. I'm sorry, I'm not good with compiler settings and optimization >< Thanks.
    Last edited by pobri19; 08-08-2009 at 02:25 AM.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  9. #24
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by pobri19 View Post
    Yeah I see that, but what I'm saying is I'm not explicitly linking to MSVCRTD.dll or MSVCRTD.lib in my linker/compile options anywhere (unless it did that by default, in that case I cannot see where). Is there some type of compiler report I can generate to show you the settings ahah.... Are you trying to say I shouldn't be using /MT? Or is there some other option I should change. I'm sorry, I'm not good with compiler settings and optimization >< Thanks.

    every application links with the runtime by default. You don't have to explicitly link it. You have to explicitly remove the linkage, or in this case change it to the static library, rather than the DLL. Don't use command line switched explicitly unless you are very sure of exactly how they effect things and require them for some feature that cant be done through the IDE. In this case, as I stated, you can set the runtime linkage type in the project settings. You need to -

    1. Remove your manual entry of /MT or /MD
    2. right click on the project name in the solution browser (the window on the left by default), not the solution name, then select Properties
    3. go to Configuration Properties
    4. go to C++
    5. Code Generation
    6. on the Runtime Library attribute, click and select Multi-threaded or Debug Multithreaded depending on whether this is the release or debug build respectively
    7. DO NOT select any of the settings that have the letters DLL in them.

    now clean the project and rebuild.
    Last edited by abachler; 08-08-2009 at 03:32 AM.

  10. #25
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Quote Originally Posted by abachler View Post
    every application links with the runtime by default. You don't have to explicitly link it. You have to explicitly remove the linkage, or in this case change it to the static library, rather than the DLL. Don't use command line switched explicitly unless you are very sure of exactly how they effect things and require them for some feature that cant be done through the IDE. In this case, as I stated, you can set the runtime linkage type in the project settings. You need to -

    1. Remove your manual entry of /MT or /MD
    2. right click on the project name in the solution browser (the window on the left by default), not the solution name, then select Properties
    3. go to Configuration Properties
    4. go to C++
    5. Code Generation
    6. on the Runtime Library attribute, click and select Multi-threaded or Debug Multithreaded depending on whether this is the release or debug build respectively
    7. DO NOT select any of the settings that have the letters DLL in them.

    now clean the project and rebuild.
    That's EXACTLY what I did, now it doesn't compile and I get the errors in the above linked screen shot. I never manually had /MT or /MD by the way, it was set as /MD in the Runtime Library setting, but then soon as I change it to /MT like you suggest (I'm not using MTd because it's a Release version - but that one errors too in case you're interested) I get all those errors. And yeah I cleaned the project too, had no effect.

    Edit: Here's a screen shot...

    http://img512.imageshack.us/img512/1821/hee.jpg
    Last edited by pobri19; 08-08-2009 at 03:53 AM.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  11. #26
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    from the screenshot i can tell that you are linking other libraries, that is why you are getting the errors that such and such symbol is already defined.

    Go under Linker->Input and remove the offending libraries from the additional dependencies box.

  12. #27
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Yeah I am, but if I remove those my program won't compile because I'm using them. I have:

    shlwapi.lib
    ws2_32.lib
    C:\libssh2-0.18\win32\libssh2.lib

    shlwapi is required for some header and functions, ws2_32 for socket stuff and libssh2.lib for libssh2.

    I have a compiled libssh2.dll, can I use that and dynamically link to it and place it in my programs folder?
    Last edited by pobri19; 08-08-2009 at 06:53 AM.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  13. #28
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    No, you are still trying to link both the MT and the MT Debug libraries, as you will notice form the screenshot. Post a screenshot of the Linker->Command Line page. Time like this I realyl wish the moderator would enable us to attach zip and rar files (hint hint) .
    Last edited by abachler; 08-08-2009 at 09:22 AM.

  14. #29
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Here you go mate: http://img11.imageshack.us/img11/9710/hehezn.jpg

    I figured you'd want higher resolution otherwise I would have uploaded to board
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  15. #30
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    you are linking the debug version of ssh2, try linking the release version instead.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird Problem With Pointer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2007, 07:50 PM
  2. very weird problem (pointers I think)
    By hannibar in forum C Programming
    Replies: 2
    Last Post: 10-11-2005, 06:45 AM
  3. Replies: 6
    Last Post: 05-12-2005, 03:39 AM
  4. Weird mouse problem in XP
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 06-16-2004, 11:47 AM
  5. Weird class problem!
    By aker_y3k in forum C++ Programming
    Replies: 2
    Last Post: 09-25-2002, 06:12 AM