Constant linker errors when compiling a program using Dear ImGui - c++

83
Back-ends: imgui_impl_dx9.cpp + imgui_impl_win32.cpp
Operating System: Windows 10
Compiler: Visual Studio 2019
My Issue/Question:
I keep getting constant linker errors when trying to compile my program and I cannot figure out what is causing them
I have the files required and they're included in the .sln properties and in my main.cpp
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug Win32 ------
1>ConsoleApplication2.cpp
1>imgui_widgets.cpp
1>Generating Code...
1>ConsoleApplication2.obj : error LNK2019: unresolved external symbol _Direct3DCreate9#4 referenced in function "bool __cdecl CreateDeviceD3D(struct HWND__ *)" (?CreateDeviceD3D##YA_NPAUHWND__###Z)
1>imgui_impl_win32.obj : error LNK2019: unresolved external symbol _XInputGetState#8 referenced in function "void __cdecl ImGui_ImplWin32_UpdateGamepads(void)" (?ImGui_ImplWin32_UpdateGamepads##YAXXZ)
1>imgui_impl_win32.obj : error LNK2019: unresolved external symbol _XInputGetCapabilities#12 referenced in function "void __cdecl ImGui_ImplWin32_UpdateGamepads(void)" (?ImGui_ImplWin32_UpdateGamepads##YAXXZ)
1>C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64\xinput.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
1>C:\Users\Logan\source\repos\ConsoleApplication2\Debug\ConsoleApplication2.exe : fatal error LNK1120: 3 unresolved externals
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Related

Visual studio 19 GLFW external symbol error

I use the GLFW example from https://www.glfw.org/documentation.html
I get these errors
Build started...
1>------ Build started: Project: generic RPG game, Configuration: Debug x64 ------
1>main.cpp
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>main.obj : error LNK2019: unresolved external symbol __imp_glClear referenced in function main
1>C:\Users\Joseph\Desktop\foldrr\generic RPG game\x64\Debug\generic RPG game.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "generic RPG game.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I included the glfw3.lib and the headers too
I use the x64 windows precompiled binaries version 3.3.2 (latest version as of right now)
if I comment out glClear(GL_COLOR_BUFFER_BIT); function in the example code the error goes away and I'm able to compile normally and by removing the GL_COLOR_BUFFER_BIT parameter in the function i get a 'glClear': function does not take 0 arguments error
also if i comment out the function and try to render simple triangle i get a error too
1>main.obj : error LNK2019: unresolved external symbol __imp_glBegin referenced in function main
1>main.obj : error LNK2019: unresolved external symbol __imp_glVertex2f referenced in function main
I know that similar question has been asked before but I didn't find anyone with this weird behaviour

build poco c++ library on windows

I'm trying to build poco library (c++) with openssl on windows 10 (VS 2012). With the following cmd file:
#echo off
set INCLUDE=c:\openssl\include
set LIB=c:\openssl\lib
set _IsNativeEnvironment=true
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat"
buildwin 110 build all release x64 nosamples notests devenv
I get link errors:
1>------ Build started: Project: Crypto, Configuration: release_shared x64 ------
1> Datei *.dll nicht gefunden
1> Datei *.lib nicht gefunden
1> Creating library ..\lib64\PocoCrypto.lib and object ..\lib64\PocoCrypto.exp
1>ECKey.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>ECKeyImpl.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>RSAKeyImpl.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>PKCS12Container.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>EVPPKey.obj : error LNK2019: unresolved external symbol EVP_PKEY_type referenced in function "private: void __cdecl Poco::Crypto::EVPPKey::newECKey(char const *)" (?newECKey#EVPPKey#Crypto#Poco##AEAAXPEBD#Z)
...
(Datei *.dll nicht gefunden == file *.dll not found).
If I remove the Crypto in file "components" (Is it OK if I want to use https?), I get the following error:
1>------ Build started: Project: NetSSL_OpenSSL, Configuration: release_shared x64 ------
1> Creating library ..\lib64\PocoNetSSL.lib and object ..\lib64\PocoNetSSL.exp
1>Context.obj : error LNK2019: unresolved external symbol BIO_new_file referenced in function "private: void __cdecl Poco::Net::Context::initDH(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?initDH#Context#Net#Poco##AEAAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
...
I installed openssl from "Shining Light" (win64). I also tried to use openssl which is built from source (https://github.com/pocoproject/openssl). But I get the same errors.
Can someone help me ?!
Thank you!
Xinyu
OK, If I delete all object files: folder obj64, including obj64 in testsuite, then every thing is ok.

building cgal sln cannot be completed

I have a problem while compiling CGAL
I followed the steps here :
http://www.cse.msu.edu/~ytong/CGAL_installation.ppt
but when I reach at building CGAL .sln step
it show the following errors:
here
output:
1>------ Build started: Project: CGAL, Configuration: Debug Win32 ------
1> Building Custom Rule C:/dev/CGAL-4.9.1/src/CGAL/CMakeLists.txt
1> CMake does not need to re-run because C:\dev\CGAL-4.9.1\build\src\CGAL\CMakeFiles\generate.stamp is up-to-date.
1> all_files.cpp
1> Creating library C:/dev/CGAL-4.9.1/build/lib/Debug/CGAL-vc120-mt-gd-4.9.1.lib and object C:/dev/CGAL-4.9.1/build/lib/Debug/CGAL-vc120-mt-gd-4.9.1.exp
1>all_files.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::system_category(void)" (__imp_?system_category#system#boost##YAABVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat#system#boost##YAXXZ)
1>all_files.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (__imp_?generic_category#system#boost##YAABVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat#system#boost##YAXXZ)
1>C:\dev\CGAL-4.9.1\build\bin\Debug\CGAL-vc120-mt-gd-4.9.1.dll : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
We are currently at CGAL 4.12 so please upgrade and follow official installation instructions.

"unresolved external symbol" error in Visual Studio 2013

I am trying to use the libnoise library, which is a c++ library for perlin noise generation, in Visual Studio 2013. Tutorial 3 links to an addon utility called noiseutils, which consists of a .cpp and a .h, which I place here:
I have the project settings pointed towards the include folder (whose contents are in the image below), and my code looks like this.
#include "stdafx.h"
#include <noise/noise.h>
#include "noiseutils.h"
int _tmain(int argc, _TCHAR* argv[])
{
noise::module::Perlin myModule;
utils::NoiseMap heightMap;
utils::NoiseMapBuilderPlane heightMapBuilder;
heightMapBuilder.SetSourceModule(myModule);
heightMapBuilder.SetDestNoiseMap(heightMap);
heightMapBuilder.SetDestSize(256, 256);
heightMapBuilder.SetBounds(2.0, 6.0, 1.0, 5.0);
heightMapBuilder.Build();
utils::RendererImage renderer;
utils::Image image;
renderer.SetSourceNoiseMap(heightMap);
renderer.SetDestImage(image);
renderer.Render();
utils::WriterBMP writer;
writer.SetSourceImage(image);
writer.SetDestFilename("tutorial.bmp");
writer.WriteDestFile();
return 0;
}
All of that code is given in the third tutorial provided on their website. Visual Studio has no complaints that it cannot find any of the classes or functions specified in all of this code. However, when I try to build the project...
1>------ Build started: Project: libnoisetest, Configuration: Debug Win32 -- ----
1> libnoisetest.cpp
1>b:\visual studio\extra libraries\libnoise\include\noiseutils.h(1217): warning C4244: 'initializing' : conversion from 'const double' to 'float', possible loss of data
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: __thiscall noise::utils::GradientColor::~GradientColor(void)" (??1GradientColor#utils#noise##QAE#XZ) referenced in function "public: __thiscall noise::utils::RendererImage::~RendererImage(void)" (??1RendererImage#utils#noise##QAE#XZ)
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: __thiscall noise::utils::NoiseMap::NoiseMap(void)" (??0NoiseMap#utils#noise##QAE#XZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: __thiscall noise::utils::NoiseMap::~NoiseMap(void)" (??1NoiseMap#utils#noise##QAE#XZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: __thiscall noise::utils::Image::Image(void)" (??0Image#utils#noise##QAE#XZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: __thiscall noise::utils::Image::~Image(void)" (??1Image#utils#noise##QAE#XZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: void __thiscall noise::utils::WriterBMP::WriteDestFile(void)" (?WriteDestFile#WriterBMP#utils#noise##QAEXXZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: __thiscall noise::utils::NoiseMapBuilderPlane::NoiseMapBuilderPlane(void)" (??0NoiseMapBuilderPlane#utils#noise##QAE#XZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall noise::utils::NoiseMapBuilderPlane::Build(void)" (?Build#NoiseMapBuilderPlane#utils#noise##UAEXXZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: __thiscall noise::utils::RendererImage::RendererImage(void)" (??0RendererImage#utils#noise##QAE#XZ) referenced in function _wmain
1>libnoisetest.obj : error LNK2019: unresolved external symbol "public: void __thiscall noise::utils::RendererImage::Render(void)" (?Render#RendererImage#utils#noise##QAEXXZ) referenced in function _wmain
1>B:\Visual Studio\_Projects\libnoisetest\Debug\libnoisetest.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
In short, Visual Studio can't find any of the stuff in "noiseutils" while it's actually building. What am I doing wrong here?
UPDATE:
After copying noiseutils.cpp to my source folder as suggested by Praetorian, I get this set of warnings, and a single error:
1>------ Build started: Project: libnoisetest, Configuration: Debug Win32 ------
1> noiseutils.cpp
1>b:\visual studio\extra libraries\libnoise\include\noiseutils.cpp(24): warning C4627: '#include <fstream>': skipped when looking for precompiled header use
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>b:\visual studio\extra libraries\libnoise\include\noiseutils.cpp(26): warning C4627: '#include <noise/interp.h>': skipped when looking for precompiled header use
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>b:\visual studio\extra libraries\libnoise\include\noiseutils.cpp(27): warning C4627: '#include <noise/mathconsts.h>': skipped when looking for precompiled header use
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>b:\visual studio\extra libraries\libnoise\include\noiseutils.cpp(29): warning C4627: '#include "noiseutils.h"': skipped when looking for precompiled header use
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>b:\visual studio\extra libraries\libnoise\include\noiseutils.cpp(1303): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I looked up this problem and discovered that I can simply disable using precompiled headers for noiseutils.cpp since it doesn't need access to stdafx. With that, problem solved.
Out of curiosity though, what is stdafx and what role does it play in a Visual Studio project? Would I need to disable precompiled headers for any source code that I add to my project so that it ignores stdafx?
Right click -> Proprieties -> C++ -> Additional Include Directories and add your headers location
Right click -> Add -> Existing Item -> Add your files
If you want
Right click -> Add -> New Filter and you put the files there

Linking between projects

I have a solution with 2 projects in it:
The first one is called Engine and it has 3 classes: Backbuffer and Vector2 and CTimer. It is of type Console Application DLL, links winmm.lib, has all members in namespace "Engine" and if I build it (only this project) it compiles.
The other one, Game, links dependency for project Engine, is of type Win32 project, has additional include directories $(SolutionDir)\Engine\, has "Link Library Dependencies" set to true. And it does not compiles.
Both projects are compiled with "/MD" flag.
I don't know for sure if the problem is caused by VS12. Tried lots of solutions to similar errors but with no results for me.
The problem seems to be it doesn't compile the .CPP files. Thought if I compile only the "Engine" project, it compiles perfectly.
Errors:
1>------ Rebuild All started: Project: Engine, Configuration: Release Win32 ------
1> BackBuffer.cpp
1> CTimer.cpp
1> Vector2.cpp
1> Generating code
1> Finished generating code
1> Engine.vcxproj -> G:\Ubisoft\HumansVsZombies\Release\Engine.dll
2>------ Rebuild All started: Project: Game, Configuration: Release Win32 ------
2> CGameApp.cpp
2> CGameObject.cpp
2> Main.cpp
2>CGameApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall Engine::BackBuffer::reset(void)" (?reset#BackBuffer#Engine##QAEXXZ)
2>CGameApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall Engine::BackBuffer::present(void)" (?present#BackBuffer#Engine##QAEXXZ)
2>CGameApp.obj : error LNK2001: unresolved external symbol "public: __thiscall Engine::BackBuffer::~BackBuffer(void)" (??1BackBuffer#Engine##QAE#XZ)
....
2>G:\Ubisoft\HumansVsZombies\Release\Game.exe : fatal error LNK1120: 12 unresolved externals
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
Thank you !