Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. unresolved external problems (again...sigh)

unresolved external problems (again...sigh)

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan Chambers
    wrote on last edited by
    #1

    Hi all, I have another b*****d problem with unresolved externals, this one is very strange. OK, I have the following code: #include fstream.h (in arrow brackets) bool blah::blah(LPSTR filename) { ifstream fin(filename); return true; } This generates the following error: nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _endthreadex nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _beginthreadex blah...2 unresolved externals. I've had a look around the website but can't find the answer. I get an error when including the msvcrt.lib or some other lib that was mentioned on the site. WTF is going on? I'd be greatful if someone could save my PC's from destruction, cos thats what they're heading for! Many Thanks, Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

    O E S 3 Replies Last reply
    0
    • A Alan Chambers

      Hi all, I have another b*****d problem with unresolved externals, this one is very strange. OK, I have the following code: #include fstream.h (in arrow brackets) bool blah::blah(LPSTR filename) { ifstream fin(filename); return true; } This generates the following error: nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _endthreadex nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _beginthreadex blah...2 unresolved externals. I've had a look around the website but can't find the answer. I get an error when including the msvcrt.lib or some other lib that was mentioned on the site. WTF is going on? I'd be greatful if someone could save my PC's from destruction, cos thats what they're heading for! Many Thanks, Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

      O Offline
      O Offline
      Orbital
      wrote on last edited by
      #2

      "Linking code compiled with /MT with the library LIBC.LIB causes LNK2001 on _beginthread, _beginthreadex, _endthread, and _endthreadex" - MSDN Bye, Orbital^ ...the night is long ... but not long enought to do some real coding ...

      A 1 Reply Last reply
      0
      • A Alan Chambers

        Hi all, I have another b*****d problem with unresolved externals, this one is very strange. OK, I have the following code: #include fstream.h (in arrow brackets) bool blah::blah(LPSTR filename) { ifstream fin(filename); return true; } This generates the following error: nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _endthreadex nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _beginthreadex blah...2 unresolved externals. I've had a look around the website but can't find the answer. I get an error when including the msvcrt.lib or some other lib that was mentioned on the site. WTF is going on? I'd be greatful if someone could save my PC's from destruction, cos thats what they're heading for! Many Thanks, Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

        E Offline
        E Offline
        Erik Funkenbusch
        wrote on last edited by
        #3

        First, when you post code you click the little checkbox at the bottom that says "Display this message as-is (no HTML)" to get your brackets to appear (though your signature will now look weird). Alternatively, you can simply use the HTML equivelents "& lt;" and "& gt;" (without spaces) for less than and greater than. Second, you probably don't want to be using fstream.h, these are the old deprecrated iostream libraries. The new libraries are simply: #include // Note: no .h Third, some functions have dependancy on the multithreaded library, and as such require a multithreaded version of it. You're linking with the single threaded version. Change that in your project settings on the C++ tab. -- Where are we going? And why am I in this handbasket?

        A 1 Reply Last reply
        0
        • A Alan Chambers

          Hi all, I have another b*****d problem with unresolved externals, this one is very strange. OK, I have the following code: #include fstream.h (in arrow brackets) bool blah::blah(LPSTR filename) { ifstream fin(filename); return true; } This generates the following error: nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _endthreadex nafxcwd.lib(thrdcore.obj): error LNK2001: unresolved external symbol _beginthreadex blah...2 unresolved externals. I've had a look around the website but can't find the answer. I get an error when including the msvcrt.lib or some other lib that was mentioned on the site. WTF is going on? I'd be greatful if someone could save my PC's from destruction, cos thats what they're heading for! Many Thanks, Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

          S Offline
          S Offline
          SamirSood
          wrote on last edited by
          #4

          Actually There is some probelm with your Project settings . Just Change the project settings as follows. Go to Project->Settings->C/C++. Then Chose Category as Code Generation then select the use run-time library as multithreaded DLL . Hope Your Probelm will be solved. Samir Sood

          A 1 Reply Last reply
          0
          • O Orbital

            "Linking code compiled with /MT with the library LIBC.LIB causes LNK2001 on _beginthread, _beginthreadex, _endthread, and _endthreadex" - MSDN Bye, Orbital^ ...the night is long ... but not long enought to do some real coding ...

            A Offline
            A Offline
            Alan Chambers
            wrote on last edited by
            #5

            Thanks for the response. I did notice the line you pointed out in MSDN, but I haven't included LIBC.lib in my build nor with \MT option. Its strange but I've noticed that when I create a simple win32 application if I add the code given in my first question straight away, it works!!!! chuck it in my win32 simple app that I built up and it fails!!! why? I've checked the include libraries in Project > Settings > Link and they are exactly the same. I scoured the project options for \MT and can't find it (found \ML though). I haven't changed a sodding thing except to add the appropriate files (dxguid.lib and ddraw.lib) for my DirectX SDK. Apart from that I haven't touched it. Could it be the order I'm #including stuff? What is the missing link :) . Many Thanks, Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

            1 Reply Last reply
            0
            • S SamirSood

              Actually There is some probelm with your Project settings . Just Change the project settings as follows. Go to Project->Settings->C/C++. Then Chose Category as Code Generation then select the use run-time library as multithreaded DLL . Hope Your Probelm will be solved. Samir Sood

              A Offline
              A Offline
              Alan Chambers
              wrote on last edited by
              #6

              Thankyou, thankyou, thankyou. It worked at last! I did hit one further snag, a warning came up about MSVCRT.lib conflicting with some other lib every time I compiled, so I took out the _MBCS part of the Settings > C++ > Preprocessor definitions and it removed the error and everything compiled. I'm not sure if this is the best way to go about it though, what do you reckon? Also how come it works when you enter this code in a simple win32 app just after creation? I didn't have to change the code generation stuff at all then? seems a bit strange to me. Anyway, I thankyou for the time and effort you spent replying to my problem, much appreciated. Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

              1 Reply Last reply
              0
              • E Erik Funkenbusch

                First, when you post code you click the little checkbox at the bottom that says "Display this message as-is (no HTML)" to get your brackets to appear (though your signature will now look weird). Alternatively, you can simply use the HTML equivelents "& lt;" and "& gt;" (without spaces) for less than and greater than. Second, you probably don't want to be using fstream.h, these are the old deprecrated iostream libraries. The new libraries are simply: #include // Note: no .h Third, some functions have dependancy on the multithreaded library, and as such require a multithreaded version of it. You're linking with the single threaded version. Change that in your project settings on the C++ tab. -- Where are we going? And why am I in this handbasket?

                A Offline
                A Offline
                Alan Chambers
                wrote on last edited by
                #7

                Thankyou, thankyou and more thankyou's. Absolutely correct. Would you mind reading my reply above, cos i hit one further snag which i'm not sure I've handled "properly" according to convention. Anyway, thanks for your time replying to my problem, I am extremely pleased to have got over this horrible link error. I must admit I find it strange because if you put that code in straight from scratch on a simple win32 project it works! without having to change the code generation to multi threaded? Oh btw, thanks for you advice on the < fstream > < fstream.h > issue :), I was going to use fstream but I think out of boredom and complete frustration I was trying anything to get the bugger to work :). Many Thanks for you time and help Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups