LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compiling CIN within several source files, help!

Hello!

I've been working with cins and achieved success, building VI's with CIN under linux.

 

But now I need to implement Jungo Windriver PCI driver program under Windows XP in Labview.

 

Last time I worked with only one source file and everything was ok.

 

But this project compiles with at least 5-6 .c source files and makes executable.

 

1) How can I build one single CIN from several source files?

 

2) What changes I should do in a makefile?

 

Thank you in advance.

0 Kudos
Message 1 of 9
(3,447 Views)
Consider using a DLL instead. CIN's are not used anymore, because there are
disadvantages, and no benefits to use them.

Regards,

Wiebe.


0 Kudos
Message 2 of 9
(3,436 Views)

Okey, I've just tested an example of using DLL via Call Library Function Node in the manual.

 

But Can I Export to one DLL not only one function like this:

 

_declspec(dllexport) long avg_num(float a[], long size, float *avg);

 

_declspec(dllexport) long avg_num(float a[], long size, float *avg)
    {
 .......

 .......

 }

 

Can I export to one DLL many functions that contain my .c project ?

 

And one more question: My project consists of 7 .c files + many headers. In one virtex5_diag.c there is defined main function.

 

As I understand this is the main project file and others define different functions.

 

Should I compile other files too?

0 Kudos
Message 3 of 9
(3,427 Views)

Okey, now I've tested and successfully implemented 2 different functions in one DLL.

 

But what is unclear now: what to do if my project.c code uses functions which are defined in other .c and .h files ?

 

Regards

0 Kudos
Message 4 of 9
(3,424 Views)
These are all C questions, not LabVIEW questions.

In short:

If you use functions from other C files, they need to be compiled. By
linking the compiled files, the functions become available to the other
compiled files.

Functions are exported by the linker. So when exporting a function it
shouldn't matter where the function is. The C compiler doesn't distinguish
between files. They are all linked together to one big binary with internal
and external functions. If one happens to have a "main", then thet's the
main. If some functions are exported, who cares in what C file they are?

Hope it helps, but compiling several C files is really basic stuff, so
reading a C book might be usefull as well. Compiling a PCI Driver does not
seem very basic (haven't done it, but I can guess), so good luck!

Regards,

Wiebe.


0 Kudos
Message 5 of 9
(3,419 Views)

Thank you for a clear answer. However, I want to ask: Does it care for example if that driver project was created for .EXE program generation? (building a project there is a choice DLL or EXE) and program generates source files for the project. I mean can I build DLL from a " .c " program, or should change source code and learn building DLL's ?

 

As I understood I can simply compile other source files (containing function definitions) and link them to the main file during compilation as .obj files?

And what to do If compiler notifies me about plenty of undefined symbols? I mean how can I find which one library is needed?

 

Best Regards

0 Kudos
Message 6 of 9
(3,403 Views)
Haven't read the book jet?

"ACiDuser" <x@no.email> wrote in message
news:1222904409228-785779@exchange.ni.com...
> Thank you for a clear answer. However, I want to ask: Does it care
> for example if that driver project was created for .EXE program
> generation? (building a project there is a choice DLL or EXE) and
> program generates source files for the project. I mean can I build DLL
> from a &quot; .c &quot; program, or should change source code and learn
building
> DLL's

A project can be configured to create .exe files. You can change the project
to create .dll files, and visa versa.

An .exe is a PE (portable executable) file with a winmain function. A .dll
is a PE file with some other functions windows recognises. You can even
create an .exe with exported functions (like LabVIEW.exe), and call it with
LabVIEW's CLN.

If an exe calls some initial stuff, you can call the same stuff in your dll
main.

>?&nbsp;As I understood I can simply compile other source
> files (containing function definitions) and link them to the main file
> during compilation as .obj files?

Yes. Although .obj files are used by some compilers, .a / .lib files by
others.

> And what to do If compiler notifies me about plenty of undefined symbols?
I mean how can I find which one library is needed?&nbsp;Best

Link to the .obj files that has these functions. How to know which .obj file
this is? Beats me, but usually the .h file and the .obj file have some
naming consistency...

Regards,

Wiebe.


0 Kudos
Message 7 of 9
(3,391 Views)

I've read this manual: http://zone.ni.com/devzone/cda/tut/p/id/3056

 

 There written:

 

"Every DLL file must have a DllMain function, which is the entry point for the library.

Unless you must do a specific initialization of the library, the default DllMain that MSVC created is sufficient.

Notice that this function does nothing."

 

And when I read Using External Code in Labview manual, there was nothing said about DllMain function, and I successfully compiled an example to DLL without any "DllMain" function and it worked fine with Labview.

 Now it is a great mess in my head.

 

Should I modify those other .c files according this manual or only main.c file?

 

Thank you.

 

0 Kudos
Message 8 of 9
(3,381 Views)
The Dllmain function can be used to do stuff when the dll is loaded, or when
a new thread of the dll is created, and when a thread is destroyed or the
dll is unloaded.

If you create a new dll project, you'll see how dllmain is called, and a
switch statement is used to execute one of the four cases mentioned above.

If you create a dll without dllmain, either the compiler includes a dummy or
having it isn't required...

Regards,

Wiebe.


0 Kudos
Message 9 of 9
(3,375 Views)