Error LNK2019 Directx10 VC++2010 - visual-c++

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.

Related

How to link Bcrypt.lib to VC++ DLL project

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.

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"

Can't build Allegro 5 solution in MSVC 2012

I am struggling for hours to build my first Allegro 5 application in Visual Studio 2012, using Windows 7 x64.
I have followed all the steps of this tutorial: http://wiki.allegro.cc/index.php?title=Windows,_Visual_Studio_2010_and_Allegro_5#Download which means that the Allegro directory is in c:/allegro/ and all the libraries are added in both the debug and release configurations.
I also changed my subsystem to Windows, so now it says "Windows (/SUBSYSTEM:WINDOWS)"
1>------ Build started: Project: AllegroTesting, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol __imp__al_install_system referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_rest referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_map_rgb referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_create_display referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_destroy_display referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_flip_display referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_clear_to_color referenced in function _main
1>c:\users\skypower\documents\visual studio 2012\Projects\AllegroTesting\Debug\AllegroTesting.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
For anyone wondering, the issue was resolved for skypower in this thread on the allegro.cc forums: Problem installing allegro 5 on vs 2012
It boiled down to specifying the wrong linker input libraries when following the Visual Studio 2010 setup instructions on the relevant Allegro.cc wiki page. Make sure to type the actual version of Allegro instead of typing 5.0.x (i.e. the x should be replaced with the minor version, which is currently 8, so type the version of 5.0.8).
(some extra context if you read that original thread - the x I'm referring was previously a ? in the wiki page's setup instructions)
I struggled with this problem for a long time,pulled half my hair off,and then i finally tried something. I'm using Windows 8 and VS2012 and Allegro 4.2 cause I got it right using the older version.
Link to get the 4.2 binary => http://en.sourceforge.jp/projects/sfnet_alleg/downloads/allegro-bin/4.2.0/allegro-msvc6-4.2.0.zip/
Once you unpack it, there'll be 4 files => bin,include,lib and the readme file.
Copy the include and lib files in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC
Fire up VS and create a Win32 Project,the when prompted with Application setting,check Empty project and click OK.
Insert a source file in and paste this code =>
#include <allegro.h>
int main(void) {
allegro_init();
set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
install_keyboard();
textout_ex(screen, font, "Hello World!", 1, 1, 10, -1);
textout_ex(screen, font, "Press ESCape to quit.", 1, 12, 11, -1);
while(!key[KEY_ESC]);
allegro_exit();
return 0;
}
END_OF_MAIN()
Now right click on the project in the solution explorer->properties->Linker->Input->Additional Dependencies. Click on it reveal the drop down menu->edit and in the blank space at the top enter 'alleg.lib' ->OK->OK.
Now copy the 3 dll files in the bin folder from the unpacked Allegro 4.2 folder.
Go to where you saved your project, default is my documents->visual studio 2012->projects. go into the folder with your project name->Debug folder. here you will find the .exe file for your project. paste the dll files here.
go to VS2012. press f7 to compile your program,should be no errors. press ctrl+f5 to run.
10.you get a black window saying hello and press esc to exit. That's it! :D

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.

Resources