'Object not declared in this scope error in cpp?

I'm getting error

SPIGtestMain.cpp:"MockObj not declared in this scope"

though I've declared it globally in with extern keyword in SPIGtestMain.cpp file.

SPIGtestMain.cpp

#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "SPI.h"
#include "MockSPI.h"
using::testing::Return;

extern MockClass MockObj;
TEST_F(GivenANewSPI,WhenDemoIsCalled_TheComponentGetsVal)
{
    unsigned char const *Ptr;
    unsigned char const *BufLim;

    const unsigned char *DataSample;
    const unsigned char *EndOfSample;

    EXPECT_CALL(MockObj, PSDemo(Ptr,BufLim)).WillOnce(Return(25));
    EXPECT_EQ(Val,Demo(DataSample,EndOfSample);
}

MockSPI.h

#include <gmock/gmock.h>

class MockClass : public GivenANewSPI
{
    public:
        MockClass();
        ~MockClass();
    
        MOCK_METHOD2 (PSDemo,signed char(unsigned char const*,unsigned char const*));
};

SPI.h

#include "gtest/gtest_prod.h"

class SPI : public SPIProxy
{
    private:
        virtual signed char PSDemo(unsigned char const *Ptr,unsigned char const *BufLim) const;
        virtual signed char Demo(const unsigned char* DataSample, const unsigned char* EndOfSample) override;
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source