error when compiling a project in VS 2010 C ++

15,059

Your unresolved externals are a consequence of compiling with the /GS (Buffer Security Check) compiler flag, but not linking against the CRT (/NODEFAULTLIB). If /GS is not specified it defaults to being enabled. You can try to disable Buffer Security Checks by specifying /GS-.

Alternatively you can attempt to add the pieces of code you need. __security_cookie is declared in <process.h> and defined in <gs_cookie.c> as part of the CRT source that ships with Visual Studio. Since you also explicitly specified WinMain as the entry point and don't rely on the CRT to perform the required initialization you will have to call __security_init_cookie yourself. There may be more to get this to compile, but this should serve as a starting point.

Share:
15,059
aleksander haugas
Author by

aleksander haugas

Updated on June 04, 2022

Comments

  • aleksander haugas
    aleksander haugas almost 2 years

    I'm trying to compile a project that I created, a software management program, in VS 2010. In VS6 and VS2005, it compiles perfectly.

    1 - visual studio 6 2 - Visual Studio 2005 3 - Visual Studio 2010

    The original version has some bugs that I would like fix later, but first of all I need it to compile.

    With VS 6 and VS 2005 it compiles perfectly.

    I added the library #pragma comment(lib, "bufferoverflowU.lib") corresponding to each file that needs it (.cpp)

    However, it did not solve anything with bufferoverflowU.lib

    errors are:

    1>------ Operación Volver a generar todo iniciada: proyecto: Gestion_v1, configuración: Release Win32 ------
    1> StdAfx.cpp
    1> WDoS.cpp
    1> Helpers.cpp
    1> Gestion.cpp
    1> WWW.cpp
    1>WWW.cpp(141): warning C4018: '<' : no coinciden signed/unsigned
    1>WWW.cpp(136): warning C4101: 'dwTmp' : variable local sin referencia
    1>WWW.cpp(481): warning C4244: '=' : conversion from 'DWORD' to 'char'; possible loss of data
    1>WWW.cpp(482): warning C4244: '=' : conversion from 'DWORD' to 'char'; possible loss of data
    1> Generando código...
    1>LINK : warning LNK4108: /ALIGN specified without /DRIVER; image may not run
    1>WDoS.obj : error LNK2019: unresolved external symbol ___security_cookie referenced in function "unsigned long __stdcall WDoS_HTTP(void *)" (?WDoS_HTTP@@YGKPAX@Z)
    1>Gstion.obj : error LNK2001: unresolved external symbol ___security_cookie
    1>WWW.obj : error LNK2001: unresolved external symbol ___security_cookie
    1>WDoS.obj : error LNK2019: unresolved external symbol @__security_check_cookie@4 referenced in function "unsigned long __stdcall WDoS_HTTP(void *)" (?WDoS_HTTP@@YGKPAX@Z)
    1>Gestion.obj : error LNK2001: unresolved external symbol @__security_check_cookie@4 
    1>WWW.obj : error LNK2001: unresolved external symbol @__security_check_cookie@4
    1>.\Release/Gestion_v1.exe : fatal error LNK1120: 2 unresolved externals
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
    

    Any ideas? Thanks

  • IInspectable
    IInspectable over 11 years
    The linker errors are not related to character encoding issues.
  • aleksander haugas
    aleksander haugas over 11 years
    Has proposed the idea that does not work, I tried all the options available and get more utf-8 errors but not errors _security_cookie, thanks for the help anyway
  • aleksander haugas
    aleksander haugas over 11 years
    compiler code: /OUT:".\Release/Gestion_v1.exe" /INCREMENTAL:NO /NOLOGO "odbc32.lib" "odbccp32.lib" "ws2_32.lib" "wininet.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" /NODEFAULTLIB /MANIFEST /ManifestFile:".\Release\Gestion_v1.exe.intermediate.manifes‌​t" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /PDB:".\Release/Gestion_v1.pdb" /SUBSYSTEM:WINDOWS /PGD:"C:\Gestion - copia\Release\Gestion_v1.pgd" /TLBID:1 /ENTRY:"WinMain" /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
  • aleksander haugas
    aleksander haugas over 11 years
    Sorry, but <gs_cookie.c> not found and /GS or /GS- command not found, but <process.h> found.
  • IInspectable
    IInspectable over 11 years
    @aleksander: <gs_cookie.c> ships with Visual Studio, unless you are using the Express Edition. It is located under <VS Install Dir>\VC\crt\src. /GS is a compiler switch, not a command.
  • aleksander haugas
    aleksander haugas over 11 years
    OK, i find the gs_cookie.c file but why dont link in my Visual Studio, i used visual Studio 2010 professional (trial) and not express version, but /GS say not recognize omitted
  • aleksander haugas
    aleksander haugas over 11 years
    thanks, part of the solution works for me i found gs_cookie.c and copy/paste to my directory allways i put this lines of my code #include "gs_cookie.c" and now i get this: 1>WDoS.obj : error LNK2019: unresolved external symbol @__security_check_cookie@4 referenced in function "unsigned long __stdcall WDoS_HTTP(void *)" (?WDoS_HTTP@@YGKPAX@Z) 1>Gestion.obj : error LNK2001: unresolved external symbol @__security_check_cookie@4 1>WWW.obj : error LNK2001: unresolved external symbol @__security_check_cookie@4
  • IInspectable
    IInspectable over 11 years
    @aleksander: As I said, there is more to this. It is a lot easier to just disable Buffer Security Checks altogether. The /GS and /GS- switches should be supported in your version of Visual Studio 2010. Right-click on your project and select Properties. Navigate to Configuration Properties -> C/C++ -> Code Generation. Under this item change Buffer Security Check from Yes (/GS) to No (/GS-). Alternatively you can specify /GS- under Additional Options for the Command Line (also avaliable through the configuration properties).