I'm trying to run a sample PCL code just to start developing PCL on Visual Studio (2017) on my Windows 10. I followed the guides here: http://dominoc925.blogspot.com/2016/07/set-up-visual-studio-to-use-all-in-one.html
As suggested in their blog post, I downloaded the all-in-one 64bit installer from here: https://github.com/PointCloudLibrary/pcl/releases/tag/pcl-1.8.1rc1
While I followed all steps, they didn't have a link to a property sheet for PCL 1.8.1 (where can I find it?)
Anyways, when I try to compile my project (no errors on editor), I get 3 link errors as below. How can I run a sample PCL code in Visual Studio? Please help.
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "void __cdecl pcl::console::print(enum pcl::console::VERBOSITY_LEVEL,char const *,...)" (?print#console#pcl##YAXW4VERBOSITY_LEVEL#12#PEBDZZ) referenced in function "public: void __cdecl pcl::detail::FieldMapper<struct pcl::PointXYZ>::operator()<struct pcl::fields::x>(void)" (??$?RUx#fields#pcl###?$FieldMapper#UPointXYZ#pcl###detail#pcl##QEAAXXZ) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __cdecl pcl::PLYReader::readHeader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PCLPointCloud2 &,class Eigen::Matrix<float,4,1,0,4,1> &,class Eigen::Quaternion<float,0> &,int &,int &,unsigned int &,int)" (?readHeader#PLYReader#pcl##UEAAHAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEAUPCLPointCloud2#2#AEAV?$Matrix#M$03$00$0A#$03$00#Eigen##AEAV?$Quaternion#M$0A##7#AEAH4AEAIH#Z) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __cdecl pcl::PLYReader::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PCLPointCloud2 &,class Eigen::Matrix<float,4,1,0,4,1> &,class Eigen::Quaternion<float,0> &,int &,int)" (?read#PLYReader#pcl##UEAAHAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEAUPCLPointCloud2#2#AEAV?$Matrix#M$03$00$0A#$03$00#Eigen##AEAV?$Quaternion#M$0A##7#AEAHH#Z) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK1120 3 unresolved externals PCLViewer c:\users\xxx\documents\visual studio 2017\Projects\PCLViewer\x64\Debug\PCLViewer.exe 1
Related
I've cloned the pbrt-v3 repository using Visual Studio 2017. I've tried to compile a project where I included the Transform.h, but I'm getting the following error from the linker:
LNK2019 unresolved external symbol "int __cdecl Imf::globalThreadCount(void)" (?globalThreadCount#Imf##YAHXZ) referenced in function "class pbrt::RGBSpectrum * __cdecl pbrt::ReadImageEXR(class std::basic_string,class std::allocator > const &,int *,int *,class pbrt::Bounds2 *,class pbrt::Bounds2 *)" (?ReadImageEXR#pbrt##YAPEAVRGBSpectrum#1#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PEAH1PEAV?$Bounds2#H#1#2#Z)
I've compiled and installed openexr using CMake for Visual Studio. I've added
libpbrt.lib
libglog_static.lib
IlmThread-2_2.lib
Half.lib
Iex-2_2.lib
IexMath-2_2.lib
Imath-2_2.lib
as additional dependencies in the project settings. I wasn't able to figure out in which library globalThreadCount is defined. So, which library am I missing?
I'm trying to use OpenCV via NuGet packages with Visual Studio 2015 and I can't seem to get everything configured. I'm not sure if I'm making a mistake somewhere or what I'm trying is not supported.
A little background, I made this tutorial a while back:
https://www.youtube.com/watch?v=7SM5OD2pZKY
https://github.com/MicrocontrollersAndMore/OpenCV_3_Windows_10_Installation_Tutorial
And I'd like to update this to use NuGets if possible. I use NuGets on the job every day so I'm familiar with the concept, but I've only previously used NuGets with .Net (Visual Basic or C#) applications.
I'm trying to make this work with plane jane C++ OpenCV, not within a .NET or UWP app.
For the record, in a separate .Net test project, I tried the EmguCV NuGet package:
With Visual Studio 2015 and everything worked as expected (for those not familiar, Emgu CV is probably the oldest/best known/most stable .Net wrapper for OpenCV)
Here are the steps I tried to get regular C++ OpenCV to work within Visual Studio 2015 using NuGets:
Start Visual Studio 2015, make an Empty Project:
Bring up the NuGet package manager:
I choose OpenCV.Win.ImgProc as that seemed to be the only OpenCV 3.x NuGet available, this also auto imported Core as expected:
Then I added a .cpp file and copied/pasted in known-good OpenCV code, the OpenCV libraries are not recognized:
I tried Build -> Clean, Build -> Build, same concern. I also tried "Solution Configurations" and "Solution Platforms" set to Debug / Release / x86 / x64, same concern.
Am I missing a step here? Do NuGets only work within a managed environment such as .Net or UWP, or can they work with regular C++ as well? I did notice the mention in the Description about UWP:
But I'm not using VideoIO, so I'm not sure that should matter.
Has anybody had any success with this? I can always go back to the "old school" way of directly referencing libraries in Project -> (project name) Properties as shown in my tutorial linked to above, but I'd like to use NuGets if possible.
----------- Edit ---------------
I had to place my response to Leo-MSFT here to allow for enough characters and screenshots. Thanks for the suggestion Leo-MSFT, but two problems with that. For one, that package is OpenCV 2.4.10, very outdated by now:
2nd, if I use that package the red underlines are gone, but I get the following linker errors when I try to build and run:
1>------ Build started: Project: Test2, Configuration: Debug x64 ------
1> test.cpp
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree#cv##YAXPEAX#Z) referenced in function "public: __cdecl cv::Mat::~Mat(void)" (??1Mat#cv##QEAA#XZ)
1>test.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QEAA#AEBVMat#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::_OutputArray::_OutputArray(class cv::Mat &)" (??0_OutputArray#cv##QEAA#AEAVMat#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QEAAXXZ) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release#Mat#cv##QEAAXXZ)
1>test.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::copySize(class cv::Mat const &)" (?copySize#Mat#cv##QEAAXAEBV12##Z) referenced in function "public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)" (??4Mat#cv##QEAAAEAV01#AEBV01##Z)
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd#cv##YAHPEAHH#Z) referenced in function "public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)" (??4Mat#cv##QEAAAEAV01#AEBV01##Z)
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string,class std::allocator > const &,int)" (?namedWindow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey#cv##YAHH#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string,class std::allocator > const &,class cv::_InputArray const &)" (?imshow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEBV_InputArray#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string,class std::allocator > const &,int)" (?imread#cv##YA?AVMat#1#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::GaussianBlur(class cv::_InputArray const &,class cv::OutputArray const &,class cv::Size,double,double,int)" (?GaussianBlur#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#V?$Size_#H#1#NNH#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::Canny(class cv::_InputArray const &,class cv::_OutputArray const &,double,double,int,bool)" (?Canny#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#NNH_N#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cvtColor(class cv::_InputArray const &,class cv::_OutputArray const &,int,int)" (?cvtColor#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#HH#Z) referenced in function main
1>C:\Users\cdahms\Documents\Test2\x64\Debug\Test2.exe : fatal error LNK1120: 13 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
After trying various options, I've settled on this package:
Which seems to work, although it's not very confidence inspiring that it is clearly labeled "not an official package" and also that it's slightly out of date (not many changes from OpenCV 3.1.0 to 3.2.0 however). I suppose I'll use this until a proper updated package is released.
The OpenCV libraries package is OpenCV3.1 rather than OpenCV.Win.ImgProc for your test OpenCV code.
Below is my test result, so you just need to install the OpenCV3.1 NuGet package instead of OpenCV.Win.ImgProc for that OpenCV code.
Note that: OpenCV3.1 is not an official package.
i've downloaded and builded Boost 1.55 from source. I'm trying to use Boost-log. In basic case (http://boost-log.sourceforge.net/libs/log/doc/html)/log/tutorial.html#log.tutorial.trivial it's working fine without any problems, but when i try to use some more advanced features(like this - http://boost-log.sourceforge.net/libs/log/example/doc/tutorial_fmt_stream.cpp ) i'm getting this error:
main.obj : error LNK2019: unresolved external symbol "void __cdecl
boost::filesystem::path_traits::convert(char const *,char const
*,class std::basic_string,class std::allocator>
&,class std::codecvt const &)" (?convert#path_traits#filesystem#boost##YAXPBD0AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std##ABV?$codecvt#GDH#5##Z)
referenced in function "void __cdecl
boost::filesystem::path_traits::dispatch,class std::allocator > >(class
std::basic_string,class
std::allocator > const &,class std::basic_string,class
std::allocator > &,class std::codecvt const &)"
(??$dispatch#V?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std###path_traits#filesystem#boost##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##4#ABV?$codecvt#GDH#4##Z)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl
boost::log::v2s_mt_nt5::aux::code_convert(unsigned short const
*,unsigned int,class std::basic_string,class std::allocator > &,class
std::locale const &)"
(?code_convert#aux#v2s_mt_nt5#log#boost##YAXPBGIAAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABVlocale#6##Z)
referenced in function "private: void __thiscall
boost::log::v2s_mt_nt5::basic_formatting_ostream,class std::allocator>
::aligned_write(unsigned short const *,__int64)" (??$aligned_write#G#?$basic_formatting_ostream#DU?$char_traits#D#std##V?$allocator#D#2##v2s_mt_nt5#log#boost##AAEXPBG_J#Z)
1>main.obj : error LNK2019: unresolved external symbol "public: static
class std::codecvt const & __cdecl
boost::filesystem::path::codecvt(void)"
(?codecvt#path#filesystem#boost##SAABV?$codecvt#GDH#std##XZ)
referenced in function "public: __thiscall
boost::filesystem::path::path(char const (&)[14],void
*)" (??$?0$$BY0O#$$CBD#path#filesystem#boost##QAE#AAY0O#$$CBDPAX#Z)
So basically it can't find functions convert(...), code_convert(...) and codecvt(...) in .lib files.
I've already tried to add all release libraries (.lib files made while building boost) to "additional libraries" and generally i think that visual studio find all libraries, but can't find those functions in libraries. Any ideas how can i fix this?
I've build Boost 1.55 from source using visual studio 2010 (msvc10.0), 32 bit, release and debug. I'm working on windows 7 x64.
I had the same problem and I could fix it by changing one of the Project properties on VisualStudio 2010.
Go to:
Property Pages -> ConfigurationProperties -> C/C++ -> Language -> Treat WChar_t As Built in Type:
And set the property to:
Yes (/Zc:wchar_t)
I hope it will be helpful for you too :)
Take care,
I have a dll programmed in C++, and a exe programmed in Visual C++.
I have the functions in dll declared as:
string __declspec( dllexport ) ConfigureHAT(T_STRING pathFile);
And in the exe project I include all the headers files and the dll file.
I call the function in dll:
string ret = ConfigureHAT("file.txt");
And when the executable project is compiled, it fails with the next errors:
1>HATdllTester.obj : error LNK2028: unresolved token (0A000317) "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
referenced in function "private: void __clrcall
HATdllTester::mainWindow::buttonConfigure_Click(class System::Object
^,class System::EventArgs ^)"
(?buttonConfigure_Click#mainWindow#HATdllTester##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>AssemblyInfo.obj : error LNK2028: unresolved token (0A000316) "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
referenced in function "private: void __clrcall
HATdllTester::mainWindow::buttonConfigure_Click(class System::Object
^,class System::EventArgs ^)"
(?buttonConfigure_Click#mainWindow#HATdllTester##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>AssemblyInfo.obj : error LNK2019: unresolved external symbol "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
referenced in function "private: void __clrcall
HATdllTester::mainWindow::buttonConfigure_Click(class System::Object
^,class System::EventArgs ^)"
(?buttonConfigure_Click#mainWindow#HATdllTester##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>HATdllTester.obj : error LNK2001: unresolved external symbol "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
Can anybody help me?
I read a lot of similar messages with the same error, but no one solves my problem.
Thanks.
EDIT
Finally, I solve the problem including the .lib file generated in the dll project into Project Properties -> Linker -> Input -> Additional Dependencies.
I'd try changing Visual Studio project configuration. Under General > Common Language Runtime Support set /clr instead of /clr:pure.
This helped me when I changed CLR MyProjectCLR.vcxproj project file and added a link to C MyProjectC.vcxproj project
<ItemGroup>
<ProjectReference Include=".\MyProjectC.csproj">
<Project>{f6ead438-e6cf-4df6-b2f4-d33d533c5343}</Project>
</ProjectReference>
</ItemGroup>
As far as I understand it, I can simply place catch.hpp into my project directory, add it to the project, and then start writing tests. I'm running into a few, or 11 to be exact, linker errors once I try using some of the macros outlined in the tutorial.
#include "catch.hpp"
unsigned int Factorial( unsigned int number ) {
return number <= 1 ? number : Factorial(number-1)*number;
}
TEST_CASE( "Factorials are computed", "[factorial]" ) {
REQUIRE( Factorial(1) == 1 );
REQUIRE( Factorial(2) == 2 );
REQUIRE( Factorial(3) == 6 );
REQUIRE( Factorial(10) == 3628800 );
}
I'm able to create a single file out of the first example and compile it with g++, but when I just paste the same code into my VS2010 project and then try to run it, I run into the linker errors. Unfortunately I'm not familiar enough with C++ at this point to decode the errors myself, and after taking a look at the single file here, I was unable to discern the issue.
Error 1 error LNK2019: unresolved external symbol "public: __thiscall Catch::AutoReg::AutoReg(void (__cdecl*)(void),struct Catch::SourceLineInfo const &,struct Catch::NameAndDesc const &)" (??0AutoReg#Catch##QAE#P6AXXZABUSourceLineInfo#1#ABUNameAndDesc#1##Z) referenced in function "void __cdecl `anonymous namespace'::`dynamic initializer for 'autoRegistrar27''(void)" (??__EautoRegistrar27#?A0x3911e331##YAXXZ) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 2 error LNK2019: unresolved external symbol "public: __thiscall Catch::ExpressionResultBuilder::ExpressionResultBuilder(enum Catch::ResultWas::OfType)" (??0ExpressionResultBuilder#Catch##QAE#W4OfType#ResultWas#1##Z) referenced in function __catch$?____C_A_T_C_H____T_E_S_T____27##YAXXZ$0 C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 3 error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Catch::translateActiveException(void)" (?translateActiveException#Catch##YA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ) referenced in function __catch$?____C_A_T_C_H____T_E_S_T____27##YAXXZ$0 C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 4 error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionResultBuilder::endExpression(enum Catch::ResultDisposition::Flags)" (?endExpression#ExpressionResultBuilder#Catch##QAEAAV12#W4Flags#ResultDisposition#2##Z) referenced in function "void __cdecl ____C_A_T_C_H____T_E_S_T____27(void)" (?____C_A_T_C_H____T_E_S_T____27##YAXXZ) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 5 error LNK2019: unresolved external symbol "public: __thiscall Catch::AssertionInfo::AssertionInfo(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct Catch::SourceLineInfo const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum Catch::ResultDisposition::Flags)" (??0AssertionInfo#Catch##QAE#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABUSourceLineInfo#1#0W4Flags#ResultDisposition#1##Z) referenced in function "void __cdecl ____C_A_T_C_H____T_E_S_T____27(void)" (?____C_A_T_C_H____T_E_S_T____27##YAXXZ) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 6 error LNK2019: unresolved external symbol "struct Catch::IContext & __cdecl Catch::getCurrentContext(void)" (?getCurrentContext#Catch##YAAAUIContext#1#XZ) referenced in function "struct Catch::IResultCapture & __cdecl Catch::getResultCapture(void)" (?getResultCapture#Catch##YAAAUIResultCapture#1#XZ) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 7 error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionResultBuilder::setOp(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?setOp#ExpressionResultBuilder#Catch##QAEAAV12#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function "private: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionLhs<int const &>::captureExpression<0,int>(int const &)" (??$captureExpression#$0A#H#?$ExpressionLhs#ABH#Catch##AAEAAVExpressionResultBuilder#1#ABH#Z) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 8 error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionResultBuilder::setRhs(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?setRhs#ExpressionResultBuilder#Catch##QAEAAV12#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function "private: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionLhs<int const &>::captureExpression<0,int>(int const &)" (??$captureExpression#$0A#H#?$ExpressionLhs#ABH#Catch##AAEAAVExpressionResultBuilder#1#ABH#Z) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 9 error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionResultBuilder::setLhs(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?setLhs#ExpressionResultBuilder#Catch##QAEAAV12#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function "private: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionLhs<int const &>::captureExpression<0,int>(int const &)" (??$captureExpression#$0A#H#?$ExpressionLhs#ABH#Catch##AAEAAVExpressionResultBuilder#1#ABH#Z) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 10 error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionResultBuilder::setResultType(bool)" (?setResultType#ExpressionResultBuilder#Catch##QAEAAV12#_N#Z) referenced in function "private: class Catch::ExpressionResultBuilder & __thiscall Catch::ExpressionLhs<int const &>::captureExpression<0,int>(int const &)" (??$captureExpression#$0A#H#?$ExpressionLhs#ABH#Catch##AAEAAVExpressionResultBuilder#1#ABH#Z) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 11 error LNK2019: unresolved external symbol "public: __thiscall Catch::AutoReg::~AutoReg(void)" (??1AutoReg#Catch##QAE#XZ) referenced in function "void __cdecl `anonymous namespace'::`dynamic atexit destructor for 'autoRegistrar27''(void)" (??__FautoRegistrar27#?A0x3911e331##YAXXZ) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1 1 FirstCPPApplication
Error 12 error LNK1120: 11 unresolved externals C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\Debug\FirstCPPApplication.exe FirstCPPApplication
long story short: split your single project solution into 3, use a .lib of the old exe, add the projects to the appropriate paths, update the linker, and you're good to go.
AE Drew's answer helped solve my problem, but I want to put a more full
solution to the question's title, in case anyone's coming from Google,
especially if they are looking for a simple breakdown from a beginner's
perspective.
If you only had one project in your solution that built a .exe for you, CATCH
wouldn't work: your solution needs 3 projects (as far as I know) to be able to
test your code.
Source_project, The main codebase project (in which the source code for
your application resides)
Test_project, The test suites project (in which the REQUIRES tests appear
as outlined in the above question)
Main_project, The project where you actually call and run the code from the
source codebase.
In order to convert your original single-project solution into something that
you can use in both tests and to properly run, you'll need to build a .lib or
a .dll so that other projects (including other people's projects) can use the
same code. Altering this answer, all it takes is to
right-click on your project in the Solution Explorer, and select >
Properties.... Under Configuration Properties -> General there's an > option
called Configuration Type. If you change it to [Static Library > (.lib)], your
project will generate a [.lib] when it is built.
And then in the 3rd project, main_project, where you have a barebones setup
from a Win32 Console Application that only contains a file that looks something
like:
#include "stdafx.h"
#include "HEADER_FROM_FIRST_PROJECT.h"
int _tmain(int argc, _TCHAR* argv[])
{
METHOD_FROM_FIRST_PROJECT();
return 0;
}
where you import a header file from Source_project, the first project that we
created (the one that used to be an exe, but is now building to a lib). But
that's not going to run yet, you need to add the Source_project's directory to
this projects additional directories, by right clicking the project in the
Solution Explorer, under Properties > Configuration Properties > C/C++ > General >
Additional Include Directories, add the source_project's folder to the list. This'll
allow the #include lines to automatically search that directory for the appropriate
files, saving you from having to write ../source_project/HEADER_FROM_FIRST_PROJECT.h.
Finally, the last step is to make sure that the linker will be able to actually
find the objects that you are trying to include. And since we're building a
.lib, we're able to do this rather simply. In the same settings dialog box as
before, the Projects Properties dialog, we'll navigate instead to Configuration
Properties > Linker > Input > Additional Dependencies and add the relative path to the
source_project.lib file, which would look something like ../Debug/source_project.lib.
Note that if you have any .dlls that are in the old exe project, it'll
need to be moved into the new main_project.
Also note that this is all very new to me and some of the terms and information are bound to be incorrect.
Just scanning through the links you provide, I think you may need to add this line at the top of your file.
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
It looks like the functions you are trying to link are within #if defined CATCH_CONFIG_MAIN .... #endif preprocessor directives.