How to link Bcrypt.lib to VC++ DLL project - visual-c++

Trying to compile a VC++ DLL I get some error messages related to Visual Studio cannot resolve external symbols, errors LNK2001, LNK1120.
In my case the symbol it cannot be resolved is: __imp__BCryptGenRandom#16
and the error message is:
error LNK2001: unresolved external symbol __imp__BCryptGenRandom#16
I have googled and found that it is said to link BCrypt.lib so I have linked it at "properties->linker->input->additional dependency"
Also at ""properties->linker->all options->additional library directoris" I have added below one where BCrypt.lib is for x86:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86
And finally at "properties->linker->General->Use library dependencies inputs" I have set "Yes".
But none of these methods work.

Related

How to make JsonCPP works in MFC c++ project

I was able to create a test WinApp using JsonCPP (https://github.com/open-source-parsers/jsoncpp) to parse a json file.
However, when I implemented similar in an MFC C++ project with C/C++ -> Precompiled Headers option set to Use Precompiled Header(/Yu) in VS2008, it fails with this error:
c:\users\user1\documents\visual studio 2008\projects\jsonutility\jsonutility\jsonTest.cpp(371) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
If I add '#include "stdafx.h"' to my JsonTest.cpp, I will get this error:
JsonTest.obj : error LNK2019: unresolved external symbol "public: class Json::Value & __thiscall Json::Value::operator[](char const *)" (??AValue#Json##QAEAAV01#PBD#Z) referenced in function "public: void __thiscall JsonTest::readConfig(char const *)" (?readConfig#JsonTest##QAEXPBD#Z)
I have tried for almost 2 days now but no success.
I had added the following in my Additional Include Directories:
C:\Users\User1\Documents\Visual Studio 2008\Projects\JsonUtility\ReadingJson\dist
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include
C:\usr\jsoncpp-master\include
I seems like you didn't include the JSONCPPs *.cpp file into your project (they have to be compiled and linked). If the library gets compiled to a static library, you have to tell the linker what to link.

LNK2019 unresolved symbol compiling LuaJava with Visual Studio 2012

I am working with visual studio 2012 to compile LuaJava. The problem I am having is when I call the linker. The line that calls the linker in the makefile is:
link /dll /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64"
/LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64"
/out:luajava-1.1.dll src\c\luajava.obj
"C:\Program Files (x86)\Lua\5.1\lib\lua5.1.lib" /VERBOSE
This seems to almost be linking everything successfully, until it gets to the Lua library.
The linker outputs the following when I try to make the project:
...//linking of other libraries
Finished searching libraries
Unused libraries:
C:\Program Files (x86)\Lua\5.1\lib\lua5.1.lib
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\OLDNAMES.lib
luajava.obj : error LNK2019: unresolved external symbol lua_close referenced in function Java_org_keplerproject_luajava_LuaState__1close
luajava.obj : error LNK2019: unresolved external symbol lua_newthread referenced in function Java_org_keplerproject_luajava_LuaState__1newthread
luajava.obj : error LNK2019: unresolved external symbol lua_gettop referenced in function Java_org_keplerproject_luajava_LuaState__1getTop
...//lots of these errors
luajava-1.1.dll : fatal error LNK1120: 88 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\x86_amd64\link.EXE"' : return code '0x460'
Stop.
I'm confused as to why it says that the Lua library is unused, and then complains when it can't find the Lua library functions.
You can not link a 32 bit library to your 64 bit application. After some searces I do not believe LuaJava has a x64 download so to use this you must change your application to 32 bit.
Edit:
A second method would be to recomile LuaJava as a 64 bit dll. Here is a very recent post about that: LuaJava compile error "Unresolved external symbol"

Error LNK2019 Directx10 VC++2010

I am trying to learn about DirectX 2010, after setting up the Libraries
how i installed the Libraries:-
VC++ 2010-View-other windows-Property manager
i opened the Microsoft.Cpp.Win32.user
VC++ Directories :-
Include Directories: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
Library Directories: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
here is the Error list i get:-
Error 1 error LNK2019: unresolved external symbol _D3DX10CreateEffectFromFileW#48 referenced in function "long __cdecl InitDevice(void)" (?InitDevice##YAJXZ) c:\Users\ahmed_saad\documents\visual studio 2010\Projects\CodeName_Yarab\CodeName_Yarab\Main.obj CodeName_Yarab
Error 2 error LNK2019: unresolved external symbol _D3D10CreateDeviceAndSwapChain#32 referenced in function "long __cdecl InitDevice(void)" (?InitDevice##YAJXZ) c:\Users\ahmed_saad\documents\visual studio 2010\Projects\CodeName_Yarab\CodeName_Yarab\Main.obj CodeName_Yarab
Error 3 error LNK1120: 2 unresolved externals c:\users\ahmed_saad\documents\visual studio 2010\Projects\CodeName_Yarab\Debug\CodeName_Yarab.exe 1 1 CodeName_Yarab
i am using Windows 8 pro x64
It might be that you'll need to link to a .lib-file, because DX ist not among the usual libraries.
Look for a .lib file and add it to your Linker properties.

Linker Error: Precombiled Library VC++ 6.0 with VC++ 8.0 Program

I am trying to recompile some code I have for a new system. It involves a precompiled static library that I do not have the source code for (just the header), and this library was built with VC++ 6.0 or older with the older runtime libraries. On my old system, which had VC++ 6.0, my program was built and ran fine, but I have recently upgraded things and I no longer have access to VC++ 6.0, only Express 2008 (9.0 w/ SP).
When I build the solution, it compiles but has the following linker error:
1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall
std::_Lockit::~_Lockit(void)" (??1_Lockit#std##QAE#XZ) already defined
in NOREC.lib(track.obj) 1>LIBCMT.lib(stdexcpt.obj) : error LNK2005:
"public: __thiscall std::bad_cast::bad_cast(char const *)"
(??0bad_cast#std##QAE#PBD#Z) already defined in NOREC.lib(track.obj)
1>LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall
std::bad_cast::bad_cast(class std::bad_cast const &)"
(??0bad_cast#std##QAE#ABV01##Z) already defined in
NOREC.lib(track.obj) 1>LIBCMT.lib(stdexcpt.obj) : error LNK2005:
"public: virtual __thiscall std::bad_cast::~bad_cast(void)"
(??1bad_cast#std##UAE#XZ) already defined in NOREC.lib(track.obj)
1>LINK : fatal error LNK1104: cannot open file 'libcp.lib'
Any ideas how to overcome this issue would be very welcome.
From the last link error, libcp.lib cannot be found. This library has been removed as of VS 2005. Use /MT for the multithreaded version.
http://msdn.microsoft.com/en-us/library/abx4dbyh%28v=vs.80%29.aspx
The multithreaded version is libcpmt.lib which you will get automatically with the /MT flag. I see in the first error you are using libcpmtd.lib which is the debug version of the same. I'm not sure how you are getting that if you are not using /MTd. (or if you are, how libcp.lib is referenced since you should be using one or the other, not both)
The linker is telling you that some symbols are defined more than once. The brute force to convice the linker to produce your target image is to use the /FORCE:MULTIPLE as explained here. I used to use this switch a few times.
LINK : fatal error LNK1104: cannot open file 'libcp.lib'
This is a bug in the linker. Just create an empty file named libcp.lib in the LIBPATH.
libcp.lib you can find in installed MS Visual Studio 6.0 in
c:\Program Files\Microsoft Visual Studio\VC98\Lib\
directory.
Just copy it to your MSVS 2005/2008/2010 lib directory
(i.e. c:\Program Files\Microsoft Visual Studio 8\VC\lib\)
And everything will compiled just fine.

v8 release mode linker error with winsock

This subject became a side subject after I accepted an answer for my last question, so I will put it here as a separate topic for neatness, and I believe this will make it more useful for others.
I am working on MS visual studio 2005.
I am building a project using v8 in release mode, and am receiving a linker error that is related to winsock even though the winsock libraries are already in my additional dependencies.
My additional dependencies list is the same for both release and debug mode. It works perfectly in debug mode, and I am getting the linker errors only in release mode.
here is my additional dependencies string:
Ws2_32.lib wininet.lib rasapi32.lib iphlpapi.lib Psapi.lib winmm.lib wsock32.lib msvcrt.lib $(SolutionDir)\external_libs\debug\v8.lib $(SolutionDir)external_libs\release\v8_base.lib $(SolutionDir)external_libs\release\v8_snapshot.lib
Thanks a lot for any possible help.
Update:
I reduced the dependencies to:
Ws2_32.lib Psapi.lib winmm.lib msvcrt.lib $(SolutionDir)\external_libs\release\v8.lib $(SolutionDir)external_libs\release\v8_base.lib
and still get unresolved externals:
1>v8_base.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __imp__freeaddrinfo#4
1>v8_base.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __imp__getaddrinfo#16
1>v8_base.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __set_abort_behavior
You have paths to both debug and release folders in your dependency list. Try replacing those with $(Configuration).

Resources