I'm trying to do my first step with CNG (Cryptography Next Generation) in VC++ 2015 (Windows 10 x64). Here's the code:
#include "stdafx.h"
#include <windows.h>
int main()
{
NTSTATUS status;
ULONG cbBufSize = 0;
PCRYPT_PROVIDERS pBuf = NULL;
status = BCryptEnumRegisteredProviders(&cbBufSize, &pBuf);
return 0;
}
Building the project (for x86), I got an error message:
Error LNK2019 unresolved external symbol
_BCryptEnumRegisteredProviders#8 referenced in function _main
I then tried to install "CNG Software Development Kit" and configured the project following this instruction: http://www.codeproject.com/Articles/18713/Simple-way-to-crypt-a-file-with-CNG
but project building gave the same error message.
Please help!
PS: I did the same thing in (Win7 x86, VS 2008) and it worked without any error.
Related
Let me start off by stating that I am not a programmer. I am a Mech Eng that has to use code from various other engineers and assemble them into an executable. The main code is fortran and is compiled using Intel Fortran via Visual Studio 2008 (yes, very old version). One of the supporting codes is c++. Normally, I compile the c++ code using the built in Visual c++ compiler into a static lib then link the static lib into the main fortran code. The latest update of the c++ code will not compile in the 2008 Visual c++ because it needs the /permissive option. So, I have tried to get the c++ code compile into a static lib using g++. I get unresolved external symbol errors when doing this. The c++ code I use it very complex so I decided to make a simple example to see if I could get that to work. I am getting similar errors but since it is so simple I can post it here.I am sure someone on this forum can fix it in a few min. Here is the example c++ code:
#include <fstream>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
//------------------------------------------------------------------------
extern "C"
{
void add_2_nums(double *x,double *y,double *z);
}
extern "C" void add_2_nums(double *x,double *y,double *z)
{
*z = *x + *y;
return;
}
I compiled it using both g++/ar and mingw32-g++/mingw32-gcc-ar. Here is an example command:
mingw32-g++ -s -Iincludem -Iincludev -c -O2 -DNDEBUG add_2_nums.cpp
mingw32-gcc-ar r add_2_nums.lib add_2_nums.o
Some of the compiler options I used was from this forum in trying to resolve the errors and may not be appropriate.
Here is the simple fortran code:
program gcc_fun
implicit none
! Variables
real*8 x,y,z
x = 3.d0
y = 17.d0
call add_2_nums(x,y,z)
! Body of gcc_fun
print *, 'Z = ', z
end program gcc_fun
I use the C,Reference compile option and the rest default inside the Visual Studio environment. Here are the errors I get:
Error 1 error LNK2019: unresolved external symbol __ZNSt8ios_base4InitD1Ev referenced in function ___tcf_0 add_2_num.lib(static_lib_test.o)
Error 2 error LNK2019: unresolved external symbol __ZNSt8ios_base4InitC1Ev referenced in function __GLOBAL__sub_I_add_2_nums add_2_num.lib(static_lib_test.o)
Error 3 fatal error LNK1120: 2 unresolved externals Debug\gcc_fun.exe
I'm trying to compile the following code in clang 3.8.0 for windows (pre-built)
int main()
{
__readfsdword(0x30);
__readgsqword(0x60);
return 0;
}
and I'm getting the following link error
error LNK2019: unresolved external symbol __readgsqword referenced in
function main
any idea why the call to __readfsdword compiles and links fine but the call to __readgsqword does not?
I'm using the -m64 compilation flag to build a 64bit binary, and __x86_64__ preprocessor flag which should enable the use of __readgsqword according to \lib\Headers\Intrin.h
I get the same error on both x86 and x64 versions of clang.
any help will be appriciated
I don't know if you solved your problem, but I will post an answer for future readers.
Just #include <intrin.h> in your project. No need to copy Clang's Intrin.h. Windows SDK provides that header.
So all I'm trying to do is move from a different IDE to Microsoft Visual Studio 2013. I've done a lot of research to try to fix it but I've tried it all. Here's the code that I'm trying to get working so that everything else can work as well:
#include <SDL.h>
int main(int argc, char* args[])
{
SDL_Init(SDL_INIT_VIDEO);
// game code eventually goes here
SDL_Quit();
return 0;
}
Here's the errors that I get when I try to run "Local Windows Debugger"
1>------ Build started: Project: SDLGame, Configuration: Debug Win32 ------
1> Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _SDL_main
1>Source.obj : error LNK2001: unresolved external symbol __RTC_InitBase
1>Source.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\Users\Austin\Documents\Visual Studio 2013\Projects\SDLGame\Debug\SDLGame.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here are some pictures of what I've changed to try to fix my issues.
If you go here, you can see 4 pictures. I don't have enough reputation to include them into a hyperlink or whatever. imgur.com/f52YKld,f82dIbc,kUIad56,1DqpiJP#0
I even tried using x64 libraries just in case and it still didn't work.
please see the following tutorial regarding how to correctly configure SDL in Visual Studio
http://zamma.co.uk/setup-sdl2-in-visual-studio/
It looks like you are half way there and that you are just missing the linker configuration for the libraries.
Alright so I already followed the tutorial regarding correctly configuring SDL in Visual Studio BEFORE I posted this. However I've fixed my problem by installing VS Express with window desktop instead of the community one. Isn't REALLY an answer but it worked for me.
I just started this simple Quantlib date class in VC++ Express 2010:
#include <iostream>
#include <sstream>
#include "ql/time/date.hpp"
int main(int, char* [])
{
QuantLib::Date d(1, QuantLib::January, 2010);
std::cout<<da<<std::endl;
}
When I compiled it, this is one of the errors:
1>ql_inout.obj : error LNK2019: unresolved external symbol "public: __thiscall QuantLib::Date::Date(int,enum QuantLib::Month,int)" (??0Date#QuantLib##QAE#HW4Month#1#H#Z) referenced in function _main
It must be something I didn't setup correctly in 2010 project. I have compiled the library in Debug mode successfully.
Not all headers include the pragma that tells the linker to add QuantLib. If you don't want to include the full headers—which is advisable, as they would increase a lot your compilation time—you can add
#include <ql/auto_link.hpp>
to the included headers.
(You could also add the library explicitly to the linker options, but that is a lot more work since you have to specify different library names depending on the configuration. auto_link.hpp does this for you.)
I'm using Visual Studio 2010 on a 64-bit Windows 7 machine. I've pulled v8 source from SVN, built it with no problems (wich arch=x64), but I still can't compile my project that tries to use v8.
Here is a sample code that produces that same error :
#include <v8.h>
int main(int argc, char *argv[])
{
v8::Handle<v8::Context> context = v8::Context::New();
return 0;
}
The linker error I get is :
v8test.obj : error LNK2019: unresolved external symbol "public: static class v8::Persistent<class v8::Context> __cdecl v8::Context::New(class v8::ExtensionConfiguration *,class v8::Handle<class v8::ObjectTemplate>,class v8::Handle<class v8::Value>)" (?New#Context#v8##SA?AV?$Persistent#VContext#v8###2#PAVExtensionConfiguration#2#V?$Handle#VObjectTemplate#v8###2#V?$Handle#VValue#v8###2##Z) referenced in function _main
I built v8 as a static lib, tried both debug and release build, I get the same error.
In addition to v8_base.lib you need to also include v8_snapshot.lib, ws2_32.lib, and winmm.lib.
The sample on the V8 Getting Started Page can be compiled in a Console Application with following dependencies listed under Project Properties->Configuration Properties->Linker->Input->Additional Dependencies:
v8_base.lib;v8_snapshot.lib;ws2_32.lib;winmm.lib;(AdditionalDependencies)