C++ dll中的vector.h在我的应用程序中不可用

C++ dll中的vector.h在我的应用程序中不可用,c++,vector,dll,C++,Vector,Dll,我是新来的…我的申请有问题。 我已经编写了一个dll,其中我使用了一个结构和一个向量。在向量中,我要放置我的结构实例。到目前为止一切都很好 dll已导入到我的应用程序中。现在我想在应用程序中使用我的dll的向量,但这不起作用 我没有收到任何错误,我想做的是在我的main()应用程序中获取信息,例如,通过以下方式: #include "lib.h" #include <iostream> int main() { char setData[4];

我是新来的…我的申请有问题。 我已经编写了一个dll,其中我使用了一个结构和一个向量。在向量中,我要放置我的结构实例。到目前为止一切都很好

dll已导入到我的应用程序中。现在我想在应用程序中使用我的dll的向量,但这不起作用

我没有收到任何错误,我想做的是在我的main()应用程序中获取信息,例如,通过以下方式:

#include "lib.h"
#include <iostream>

    int main()
    {
        char setData[4];
        setData[0] = 0xBE;
        setData[1] = 0x3E;
        setData[2] = 0xB8;
        setData[3] = 0x13;

        getuseablePID(setData);     //this function is in my dll and copies the information of my csv-Data to my vector

        //here i want to know the size of my vector an want to print one element but this doesn't work 
        int a = globals::getInstance()._csvContent.size();
        cout << globals::getInstance()._csvContent.PID;

        return 0;
    }
EXPORT struct globals {
    static globals& getInstance()
    {
        static globals instance;
        return instance;
    }
    std::vector<csvDatei_Para> _csvContent;
};
#包括“lib.h”
#包括
int main()
{
字符集数据[4];
setData[0]=0xBE;
setData[1]=0x3E;
setData[2]=0xB8;
setData[3]=0x13;
getuseablePID(setData);//此函数位于我的dll中,用于将csv数据的信息复制到我的向量
//这里我想知道向量的大小,我想打印一个元素,但这不起作用
int a=globals::getInstance()。\u csvContent.size();
cout请测试此代码:

#include <fstream>
#include <string>
#include <vector>
using namespace std;
#ifndef GUARD_DLLHDR_H
#define GUARD_DLLHDR_H

#if defined(BUILD_MY_DLL)
#define DLLSYM __declspec(dllexport)
#else
#define DLLSYM __declspec(dllimport)
#endif

#if defined(__cplusplus)
extern "C" {
#endif

    struct csvDatei_Para
    {
        string PID;
        string Beschreibung;
        string Byteanzahl;
        string Min;
        string Max;
        string Einheit;
        string Wertetab;
    };


    struct globals {
        static globals& getInstance()
        {
            static globals instance;
            return instance;
        }
        std::vector<csvDatei_Para> _csvContent;
    };
    DLLSYM extern globals myGlobals;

#if defined(__cplusplus)
}
#endif

#endif
#包括
#包括
#包括
使用名称空间std;
#ifndef防护罩
#定义防护装置
#如果已定义(构建我的DLL)
#定义DLLSYM\uuu declspec(dllexport)
#否则
#定义DLLSYM_uudeclspec(dllimport)
#恩迪夫
#如果已定义(uuu cplusplus)
外部“C”{
#恩迪夫
结构csvDatei_第
{
串PID;
串贝什雷朋;
比坦扎尔弦;
字符串最小值;
字符串最大值;
字符串Einheit;
线状Wertetab;
};
结构全局{
静态全局变量&getInstance()
{
静态全局实例;
返回实例;
}
std::vector_csv内容;
};
DLLSYM外球myGlobals;
#如果已定义(uuu cplusplus)
}
#恩迪夫
#恩迪夫
现在我有了一个解决方案

我编写了一个函数,它返回一个globals实例。 这个实例可以用来获取结构的变量

在my.h中:

EXPORT struct globals getValues();
在my.cpp中:

struct globals getValues(){
return globals::getInstance();
}
在我的申请中:

getValues()._csvContent.PID;

它不起作用?您似乎没有实际导出任何对象。您定义了导出,但没有实际将其放在我认为您要导出的对象前面。不过,如果您提到了错误,也会有所帮助你得到了。添加错误代码也有助于轻松完成问题。我更新了我的问题,也许现在更容易理解我想做什么。这应该是对问题的编辑,而不是回答,因为你没有回答这里的问题。谢谢你的示例代码;但现在我不知道如何获取信息。。。我尝试了“myGlobals.\u csvContent.size()”,得到了错误LNK2001和LNK1120
getValues()._csvContent.PID;