-1

I am trying to create a C++ library that utilizes a third party library. My custom library compiles fine. However, when I try to test it out with a console application, the console application gives me errors from building. My setup is below:

Platform - Visual Studio Community 2017

//MyLib.h
#include <ThirdPartyLib.h>
namespace MyLib
{
    class MyLibClass
    {
    public:
        static void SomeFunction();
    };
}


//MyLib.cpp
#include MyLib.h
void MyLib::MyLibClass::SomeFunction()
{
    ThirdPartyLib::ThirdPartyFunction();
}


//MyConsoleApplication.cpp
#include "..\MyLib\MyLib.h"
#pragma comment(lib,"..\\Debug\\Mylib.lib")
int main()
{
    MyLib::SomeFunction();
    return 0;
}

My custom library is able to compile fine. When I try to compile the console application, I get a bunch of errors about the third party library like the one below.

LNK2019: unresolved external symbol 'public virtual _thiscall ThirdPartyLib::Foo::~Foo(void)' referenced in function 'private void _thiscall MyLib::MyLibClass::SomeFunction(void)'

I have given my console application the location of where it can find the third party library as well. Can anyone help?

1 Answers1

0

You haven't included ThirdParyLib.lib in you program, have you? What you are getting are linker errors complaining that it cannot find the functions definitions of the functions in ThirdPartyLib.h header file.

Try this :

#pragma comment(lib,"..\\Debug\\ThirdPartyLib.lib")

Please note that ThirdPartyLib.lib is placed in the debug directory as per above example.