Noob using Labview_DLL

Post Reply
happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Noob using Labview_DLL

Post by happilylazy »

Please if you can help me with this.
I just patched Biosemi to my laptop, installed drivers and downloaded ActiView604-Light, but there is only [b]Labview_dll.dll[/b] withouth header .h or library .lib
So I have written dynamic dll loading, please tell me if I'm doing something wrong here.

[code]#include <stdio>
#include <stdlib>
#include <time>

#include <windows>
#include <conio>
#include <string>

// DLL function signature
typedef HANDLE (*OPEN_DRIVER_ASYNC)(void);


int main (void) {
HANDLE usbHandle;
OPEN_DRIVER_ASYNC opendriver;

HINSTANCE hinstLib = LoadLibrary(TEXT("Labview_dll.dll"));
if (hinstLib == NULL) {
printf("ERROR: unable to load DLL\n");
return 1;
}

// Get function pointer
opendriver = (OPEN_DRIVER_ASYNC)GetProcAddress(hinstLib, "OPEN_DRIVER_ASYNC");
if (opendriver == NULL) {
printf("ERROR: unable to find DLL function\n");
FreeLibrary(hinstLib);
return 1;
}

// Call function.
usbHandle = opendriver();

// Unload DLL file
FreeLibrary(hinstLib);

// Display result
printf("The End.\n");

return 0;

}
[/code]

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

There are labview_dll.h and labview_dll.lib files in the driver download package.

If you link with the .dll file you don't need to use the LoadLibrary and
GetProcAddress calls.

Otherwise everything looks OK.

Paul

happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Post by happilylazy »

lol, I haven't seen this there. Damn, I'll try this instead since this way I have definitions of the functions.

happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Post by happilylazy »

OK, I found header, lib and dll, wrote this simple example, but am I forgetting something here o_O
It doesn't want to compile and whines about:
error LNK2019: unresolved external symbol __imp__OPEN_DRIVER_ASYNC referenced in function _main
fatal error LNK1120: 1 unresolved externals

[code]
#include <stdio>
#include <stdlib>
#include <time>

#include <windows>
#include <conio>
#include <string>

#include "labview_dll.h"

__declspec(dllimport) HANDLE OPEN_DRIVER_ASYNC(void);

int main (void) {
HANDLE usbHandle;

usbHandle = OPEN_DRIVER_ASYNC();

return 0;
}
[/code]

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

Happ,

It looks like the linker doesn't have the labview_dll.dll file.
Do you include it explicitly as a library to be searched?

Paul

happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Post by happilylazy »

[quote="pmac"]Happ,

It looks like the linker doesn't have the labview_dll.dll file.
Do you include it explicitly as a library to be searched?

Paul[/quote]


I have been at this for a while now and I keep getting the same error message over and over again, does anybody know how to do this in Visual Studio 2008?

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

Happ,

I don't often use Visual Studio.

Have you tried something like this:

http://www.learncpp.com/cpp-tutorial/a2 ... 5-express/

Paul

happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Post by happilylazy »

OK, so let's start from the scratch.
I have dynamic library labview_dll (.h, .lib, .dll), how do I write the first example program with it in C or C++.
Can you please help me with this, small example or tutorial.

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

Hi Happ,

I downloaded Visual C++ 2008 and created a new project.

I added your above code as source file "main.cpp".

In Project->Properties->Configuration Properties->C/C++->General, item "Additional Include Directories"
I added: c:\...\developers kit\c-code (... is whatever is needed on your system to point to the downloaded labview_dll.h file).

In Project->Properties->Configuration Properties->Linker->General, item "Additional Library Directories"
I added: c:\...\developers kit\c-code (... is as above but for the labview_dll.lib file).

I put a copy of Labview_DLL.dll in the same directory as the main.cpp file created above.

I added a ".h" to each of the standard include lines in main.cpp so for instance,
#include <stdio> becomes #include <stdio>

Now your program compiles and runs.

You can harvest code from labview_dll_synctest.cpp to make your acquisition stream data into the ring buffer.

Paul

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

Correction:

I added a ".h" to each of the standard include lines in main.cpp so for instance,
#include <stdio> becomes #include <stdio>

Paul

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

Correction 2:

For some unknown reason the ".h" is being removed in my previous posts!!!

Paul

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

Oh, I think I had to do one more thing,

Add Labview_DLL.lib to the project's Source Files as an Existing Item.

Paul

happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Post by happilylazy »

Thank you for the help.

Yeah, the ".h" part gets cut of constantly, but I got it.
The thing is, I tried all of the steps stated in your last post but i still couldn't compile. So I asked my very good programming friend and he couldn't do it too, like ".lib" doesn't have all the function definitions.

Can you please "zip" the MS Visual Project, the last one discussed that worked and RapidShare it or somehow else give it to me please.

Damn this frustrates me.

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

Happ,

I just did it all again as a new project and it worked!

Did you do this additional step that I posted somewhat later on Thursday:

"Add Labview_DLL.lib to the project's Source Files as an Existing Item. "

What error message(s) are you getting?

Paul

happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Post by happilylazy »

OK, I forgot to mention my system is Windows7 64bit, and as such I downloaded the Win7 64bit version of the drivers, and they couldn't compile no matter how much I tried.
Then I downloaded 32bit version and voila, it compiled like a charm.

Has anybody had the same problem? Seams like a problem in the ".lib" file. Should I contact BioSemi guys about this?

Still, I have to test are my drivers now compatible with this dll version, I somehow doubt it referencing to main Murphys Law.

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

According to the following Microsoft page, the Express edition is 32 bits only:

http://msdn.microsoft.com/en-us/library ... S.90).aspx

You can use 32 bit applications on 64 bit Windows but be careful ...
install the 64 bit driver package from BioSemi to get the correct WinUsb driver installed then for development with Microsoft's Visual Studio Express use the labview_dll.lib and labview_dll.dll from the 32 bit BioSemi package.

Paul

happilylazy
Posts: 20
Joined: Mon Jun 21, 2010 3:27 pm
Location: Karlskrona

Post by happilylazy »

Tnx, I did exactly that.
But i have MS Visual Studio 2008 Professional Edition so there should be no problem there.

I successfully ran the program and didn't receive any error.

Now I have to get the GSR data and analyze it to use it in the game. Please can you point me in this direction (post, thread, blog).

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Post by pmac »

For C, you can lift some code from the test program labview_dll_synctest.cpp in the C-code subdirectory of the BioSemi driver package.

There was this recent discussion:
viewtopic.php?t=452

Or consider something built on:
http://www.biosemi.com/download/ActiView604-Light.zip

Paul

Post Reply