I have a dll and associated lib file which contains a number of std::vector instances e.g.
In data.h I have:
namespace xyz{
extern DllExport std::vector<double> delays;
...
And in data.cpp I have:
namespace xyz{
std::vector<double> delays{0, 1, 4, 24, 52, 104};
...
data.cpp is compiled and linked into mydata.lib,mydata.dll and delays appears to be visible as an export:
dumpbin /exports ..\bin\debug\mydata.lib | grep delays
?delays@xyz@@3V?$vector@NV?$allocator@N@std@@@std@@A (class std::vector<double,class std::allocator<double> > xyz::delays)
I compile program.cpp, including data.h, which wants to use delays e.g.
for (int i = 0; i < xyz::delays.size(); i++)
std::cout << xyz::delays[i] << std::endl;
attempting to link with mydata.lib but I get e.g.
cl -EHsc -std:c++17 -I../include -Zi -MDd ../src/exe/program.cpp -link -DEBUG ../bin/debug/data.lib /OUT:../bin/debug/program.exe
program.obj : error LNK2001: unresolved external symbol "class std::vector<double,class std::allocator<double> > xyz::delays" (?delays@xyz@@3V?$vector@NV?$allocator@N@std@@@std@@A)../bin/debug/program.exe : fatal error LNK1120: 1 unresolved externals
Class definitions in data.lib, dll are fine to use in program but can I incorporate some data e.g. delays into a lib,dll so I can share and access it with whatever programs call on the lib,dll?
In case it isn't obvious using Windows 10 and microsoft compiler (19.16) and linker (14.16).
Thanks...