13

I am trying to get apitest compiled..

cloned and cmake -G "Visual Studio 14 2015 Win64" .. as instructed, everything ok

First problem, a lot of this, I don't get even the error list:

error LNK2019: unresolved external symbol _CrtDbgReport referenced in function _CRT_RTC_INIT

Gogled, and they say to switch

Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library

from Multi-threaded DLL to Multi-threaded Debug DLL

Ok, I try to build again, it fails again, but at least this time I get the error list..

Again my friend:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol _CrtDbgReport referenced in function _CRT_RTC_INIT   SDL2    C:\Users\GBarbieri\Documents\Visual Studio 2015\Projects\apitest\_out\thirdparty\SDL2-2.0.1\MSVCRTD.lib(_init_.obj) 1   

This answer says the project is being linked with only part of the C runtime (CRT) libary, msvcrtd.lib. I also need to link with the libraries vcruntimed.lib and ucrtd.lib.

Good, but how?

The apitest is a solution based on many projects, I guess I have to manually add something into the SDL2 one. I tried a lot of attempts, especially under Linker -> Input -> Additional Dependencies, but I never got it working

I found msvcrtd.lib under C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib although I guess the solution is trying to build its own.

I found vcruntimed.lib under the same place as msvcrtd.lib. Instead ucrtd.lib is located under C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64

Thanks in advance..

Ps: I have VS15 Community Edition

Community
  • 1
  • 1
elect
  • 6,765
  • 10
  • 53
  • 119
  • Do you actually need a debug build? If not, maybe you can just use an SDL version that does not reference `_CrtDbgReport` (not sure if they use it in debug and/or release builds)? – Rudolfs Bundulis Mar 04 '16 at 10:51
  • Let's say I need it running at least, if I can get the debug better otherwise I'll try to get the maximum as I can out of the release. SDL was included. – elect Mar 04 '16 at 13:15
  • well then check the SDL forum thread mentioned in my response:) It has a link to a precompiled SDL VS2015 version. – Rudolfs Bundulis Mar 04 '16 at 13:18
  • 1
    yeah yeah, I finally solved that problem, I inserted the two libs in the SDL project. But now I am stuck on another error.. `error C2220: warning treated as error - no 'object' file generated` – elect Mar 04 '16 at 13:22
  • You should post all warnings then or just remove the `/WX` compiler flag that tells to treat all warnings as errors. – Rudolfs Bundulis Mar 04 '16 at 13:24
  • Yeah, I found [this](http://stackoverflow.com/questions/18225636/error-c2220-warning-treated-as-error-no-object-file-generated) and did as you say, thanks Rudolfs! :) – elect Mar 04 '16 at 13:25

3 Answers3

9

in my case it was because in the runtime library option of the project I used /MD in debug instead of /MDd so it was building fine in release but not in debug

elect
  • 6,765
  • 10
  • 53
  • 119
6

If you end up here because you Googled "error LNK2001: unresolved external symbol __CrtDbgReport" here is a simple thing to check...

If you are comparing working DEBUG to non-working RELEASE project settings and copy/paste between them, it is easy to copy a preprocessor definition, "_DEBUG" into a RELEASE project by mistake. I just chased my tail for two frustrating hours after a quick and sloppy cut-n-paste... see how long it takes to find it below:

WIN32_LEAN_AND_MEAN;WIN32;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
Darrin
  • 317
  • 1
  • 4
  • 10
3

It seems to be an SDL issue. Here is a discussion on it in the SDL forum and basically there are following solutions - adding the libraries you mentioned , taking a proper VS2015 release build (there is a link in the thread) or building SDL from sources (the thread mentions that that should work too).

Rudolfs Bundulis
  • 11,636
  • 6
  • 33
  • 71
  • Can you believe I had to clone it again and now I get different errors? `LNK2001 unresolved external symbol _RTC_CheckStackVars SDL2 C:\Users\GBarbieri\Documents\Visual Studio 2015\Projects\apitest\_out\thirdparty\SDL2-2.0.1\SDL_dxjoystick.obj` – elect Apr 25 '16 at 14:12
  • See this - http://stackoverflow.com/questions/6642571/visual-studio10-error-lnk2019-unresolved-external-symbol-rtc-checkstackvars8 – Rudolfs Bundulis Apr 25 '16 at 14:27