jeudi 10 octobre 2019

unresolved external symbol CORBA server

I'm trying to create a server with OmniORB and I want to create several shared_ptrs. But When I do this I get the following 2 error

error LNK2019: unresolved external symbol __imp__invalid_parameter referenced in function "public: class std::shared_ptr<struct SharedPtr_i::Vector2> & __cdecl std::array<class std::shared_ptr<struct SharedPtr_i::Vector2>,1000>::operator[](unsigned __int64)" (??A?$array@V?$shared_ptr@UVector2@SharedPtr_i@@@std@@$0DOI@@std@@QEAAAEAV?$shared_ptr@UVector2@SharedPtr_i@@@1@_K@Z)
error LNK2019: unresolved external symbol __imp__CrtDbgReport referenced in function "public: class std::shared_ptr<struct SharedPtr_i::Vector2> & __cdecl std::array<class std::shared_ptr<struct SharedPtr_i::Vector2>,1000>::operator[](unsigned __int64)" (??A?$array@V?$shared_ptr@UVector2@SharedPtr_i@@@std@@$0DOI@@std@@QEAAAEAV?$shared_ptr@UVector2@SharedPtr_i@@@1@_K@Z)

I'm aware that most of these "unresolved external symbols" are caused by forgetting to import a *.lib file. However to my knownedge my code doesn't require an extra .lib file.

This is the code that is causing the issue for me:

#include "pch.h"
#include <array>
#include "sharedPtr.hh"

class SharedPtr_i : public POA_SharedPtr
{
private:
    struct Vector2
    {
        float x, y;
    };
public:
    inline SharedPtr_i() {}
    virtual ~SharedPtr_i() {}
    void CreateSharedPtr();
};

void SharedPtr_i::CreateSharedPtr()
{
    std::array<std::shared_ptr<Vector2>, 1000 > sharedPtrs;
    for (int i = 0; i < sharedPtrs.size(); i++)
    {
        sharedPtrs[i] = std::shared_ptr<Vector2>(new Vector2()); // This line caused the error
    }
}

In my testing I found out that the brackets ([ ]) are causing the error, but how do brackets cause an unresolved external symbol error?

any advice on how to solve the issue is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire