06-04-2020 01:02 PM
Hello.
I have problem that appear on windows cvi project when I compile it in "Release64".
Printf doesn't work in functions laoded from dll library. Everything work fine except printf. Seems like printf or std::cout just ignored in that functions. But if I compile dll library for "Win32" version and cvi project for "Release" version then I can see messages from that library.
I also tried to do the same and create project in Visual Studio. And that project works fine. I can see messages from printf both in 64 and 32 build versions
Here is exact same code that I tried in Visual Studio project and Windows cvi:
#include <Windows.h>
#include <stdio.h>
// pointer to function loaded from dll
int (*add3DArraysLib)(int);
int main()
{
HINSTANCE dllHandle = NULL;
// loading dll library
dllHandle = LoadLibrary(TEXT("Reconstruction_library_newcuda.dll"));
if (dllHandle == NULL)
{
printf("Coudln't load library\n");
}
add3DArraysLib = (int(*)(int))GetProcAddress(dllHandle, "add3DArraysLib");
DWORD errorMessageID = GetLastError();
if (errorMessageID == 0)
{
printf("OK!");
}
else
{
printf("error - %d\n",errorMessageID);
}
int var;
var = add3DArraysLib(10);
printf("var - %d.\n", var);
return 0;
}
Also I'll show you code of function that called from library:
// Header.h:
#define DLLReturnType __declspec(dllexport)
extern "C"
{
DLLReturnType int add3DArraysLib(int value);
}
// Source file:
#include <stdio.h>
#include "Header.h"
DLLReturnType int add3DArraysLib(int value)
{
printf("Received value - %d\n", value);
return value + 1;
}
In all cases function return expected "11". But in case of building library and cvi project for 64 bit version printf ignored and I just receive value returned from function.
Thank you for help.