Linking between projects - c++

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 !

Related

C++ Visual Studio release build is not working (OpenCV 4.5.2)

Now, I tried to build release mode from C++ source code with OpenCV.
This source code is built on debug mode, but it is not built on release mode.
The below images are my OpenCV library setting.
Please give me your help
1>------ Build started: Project: OpenCVServer, Configuration: Release x64 ------
1>StreamServer.obj : error LNK2001: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEBV_InputArray#1##Z)
1>StreamServer.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl cv::VideoCapture::read(class cv::_OutputArray const &)" (?read#VideoCapture#cv##UEAA_NAEBV_OutputArray#2##Z)
1>C:\workspace\OpenCVStream\OpenCVServer\x64\Release\OpenCVServer.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "OpenCVServer.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The error is most probably happening because you provided OpenCV library named ...d.lib to your release linker configuration.
d suffix in library file name means that it is debug library. All .lib files are usually shipped as two files, one for release (without d) and one for debug (with d).
Try to find release .lib and place it into your linker configuration.

Constant linker errors when compiling a program using Dear ImGui

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 ==========

LInking error boost when using cgal and pcl

I am getting a boost linking error when using both PCL and cgal in a project (as well as a redefinition warning). PCL and cgal examples both run fine so the installation should be good.
My program to test looks like this:
#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include <pcl/visualization/cloud_viewer.h>
int
main()
{
std::cout << "Test "<< std::endl;
return 0;
}
The error that I get is pasted below:
1>------ Build started: Project: PC_Svr2, Configuration: Debug x64 ------
1>cloud_viewer.cpp
1>Unknown compiler version - please run the configure tests and report the results
1>C:\Program Files\PCL 1.8.1\include\pcl-1.8\pcl/visualization/boost.h(51,1): warning C4005: 'BOOST_PARAMETER_MAX_ARITY': macro redefinition
1>C:\dev\CGAL-5.0.2\include\CGAL/config.h(115): message : see previous definition of 'BOOST_PARAMETER_MAX_ARITY'
1>cloud_viewer.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##YAAEBVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat#system#boost##YAXXZ)
1>cloud_viewer.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##YAAEBVerror_category#12#XZ) referenced in function "public: __cdecl boost::thread_exception::thread_exception(int,char const *)" (??0thread_exception#boost##QEAA#HPEBD#Z)
1>C:\Users\PCL_Project\PC_svr2\build\Debug\PC_Svr2.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "PC_Svr2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
When I exclude the PCL include the program runs fine, but when I exclude the cgal include i get a very similar error:
1>------ Build started: Project: PC_Svr2, Configuration: Debug x64 ------
1>cloud_viewer.cpp
1>Unknown compiler version - please run the configure tests and report the results
1>cloud_viewer.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##YAAEBVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat#system#boost##YAXXZ)
1>cloud_viewer.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##YAAEBVerror_category#12#XZ) referenced in function "public: __cdecl boost::thread_exception::thread_exception(int,char const *)" (??0thread_exception#boost##QEAA#HPEBD#Z)
1>C:\Users\PCL_Project\PC_svr2\build\Debug\PC_Svr2.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "PC_Svr2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
I am not sure but I suspect that it might have something to do with my CMakeLists.txt, which I will also paste below:
cmake_minimum_required(VERSION 3.1...3.15)
project(PC_Svr2)
find_package(CGAL QUIET)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (PC_Svr2 cloud_viewer.cpp)
target_link_libraries(PC_Svr2 CGAL::CGAL ${PCL_LIBRARIES})
Does anyone know what the problem might be?
I seem to have found the answer. It seems to have been a problem with boost and making the boost library static solved the problem. (I found this question about the same problem: C++ using two incompatible libraries together, what are the options?)
So to fix it check the Advanced option in the CMake GUI and then under CGAL check CGAL_Boost_USE_STATIC_LIBS.
You are misisng boost in your CMakeLists.txt. Your test runs fine without PCL because CGAL's header does not need boost, and I guess PCL's does.
You need to add
find_package(Boost COMPONENTS system) and
target_link_libraries(PC_Svr2 CGAL::CGAL ${PCL_LIBRARIES} Boost::system).
It should be ok after that.
If not, check what components you need and change your configuration file accordingly.
Note that most of the time, a linking error means a problem with target_link_libraries(), either it is missing, or the values given to it are wrong.

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.

My simple introduction program to SDL does not build. Why am I getting these linker errors?

So, I'm trying to use SDL for the first time and so far it has been a complete mess! I'm trying to get this to run, but everything that I have tried has failed. I have been following all the correct guides but it still will not run!
I am using Visual Studio Ultimate 2010.
This is all the code that I am trying to run:
#include "SDL.h"
#include <iostream>
int main(int argc, char* args[]) {
// Start SDL
SDL_Init(SDL_INIT_EVERYTHING);
std::cout << "SDL has been initialized!\n";
// Quit SDL
SDL_Quit();
std::cout << "SDL has quit!" << std::endl;
return 0x0;
}
The errors that the compiler yaks back are driving me nuts! Here they are:
1>------ Build started: Project: SDL_TEST, Configuration: Debug Win32 ------
1>Build started 7/6/2013 1:21:45 PM.
1>InitializeBuildStatus:
1> Touching "Debug\SDL_TEST.unsuccessfulbuild".
1>ClCompile:
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main
1>main.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
1>MSVCRT.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Tux\documents\visual studio 2010\Projects\SDL_TEST\Debug\SDL_TEST.exe : fatal error LNK1120: 3 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.59
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Compilation fails because you are not linking with the correct libraries. You have linked with the 64bit libraries but you are trying to build a Win32 binary:
1>------ Build started: Project: SDL_TEST, Configuration: Debug Win32 ------
Linking with the 32bit libraries or switching to a Win64 binary should resolve your problem.