Closed TL4903 closed 2 years ago
Unfortunately I am not very familiar with Windows environment (DLL and stuff) development. Also, I am not sure I completely understand your scenario. Maybe if you show some code snippet, it becomes clearer.
Sure, here's some code. I can attach the entire Visual Studio solution if that'll help. The DataFrame object is built into a static library and I've added both HMDF_SHARED and DataFrame_EXPORTS as preprocessor definitions. I've also added the same preprocessor definitions to my DLL and exe projects. The DLL links against that static library and uses sample code:
DLL .h
extern "C" DATAFRAMEWORKDLL_API BOOL __cdecl Work(ULDataFrame& df);
DLL .cpp
DATAFRAMEWORKDLL_API BOOL __cdecl Work(ULDataFrame& df) { df.write<std::ostream, double>(std::cout, io_format::csv2);
return TRUE; }
My exec just creates a simple DataFrame and passes it to the DLL to be output to the console, which shows that it's empty:
std::vector
ULDataFrame df; df.load_data(std::move(idx_col), std::make_pair("IntCol", int_col));
df.write<std::ostream, int>(std::cout, io_format::csv2);
Work(df);
Attached is the output.
The line in the DLL that prints the data has the wrong type in it. Your column type is int not double
df.write<std::ostream, double>(std::cout, io_format::csv2);
should be
df.write<std::ostream, int>(std::cout, io_format::csv2);
While I agree that this is a stupid/silly mistake when writing the sample program, the problem still persists. I changed my program to output to file and I still see the issue.
ULDataFrame df;
df.load_data(std::move(idx_col), std::make_pair("IntCol", int_col));
Exec: df.write<std::ostream, int>(std::cout, io_format::csv2); df.write<double, int, std::string, hmdf::DateTime>("C:\temp\DataFrame\INPUT.txt", io_format::csv2);
Work(df);
DLL cpp:
DATAFRAMEWORKDLL_API BOOL __cdecl Work(ULDataFrame& df) { df.write<std::ostream, int>(std::cout, io_format::csv2); df.write<double, int, std::string, hmdf::DateTime>("C:\temp\DataFrame\OUTPUT.txt", io_format::csv2);
return TRUE; }
So writing to cout in DLL works , but writing to file in DLL doesn't work? what happens? exceptions? empty file?
BTW, you just need this
df.write<int>("C:\temp\DataFrame\INPUT.txt", io_format::csv2);
Neither writing to cout or file in the DLL fails, it just shows no column output. I'm just using it to illustrate that the HeteroVector is empty.
Attached are the input/output files. INPUT.txt OUTPUT.txt
Then it is kind of behind my expertise.
Are you running the codebase in master or one of the releases? Since Release 1.20.0, widows compiling became much more organized. That was contributed by @SpaceIm . Maybe he can help?
Also, take a look at file DataFrameExports.h
. See if that helps to give you a clue.
Ok, thanks for your help
@TL4903 , I am going to close this. But if you find a solution to this, please drop a note here for other people with similar issues
Hi, thanks for this great library, but I'm having a problem passing a reference/pointer to a DataFrame object across a DLL. I know templates need explicit specification before passing to a DLL and that's what I believe is causing the HeteroVector to come up empty on the DLL side while other attributes of the object like the size and index get passed correctly. Do you have any experience on how to get this to work? I know it's possible to serialize the DataFrame back and forth, but I'd like to avoid that overhead if at all possible.