Jump to content
Martijn

Compile shared library as part of package install

Recommended Posts

Hi all,

I'm using VIPM to distribute a package that adds functionality to LabVIEW via a C library. This works fine under Windows as I simply distribute 32- and a 64-bit pre-compiled versions of the DLL in the package and get LabVIEW to load which one it prefers at runtime. I want to expand to Linux support, in which case the analog is a shared library, but then pre-compilation is undesirable and it would be better to create the library at install time.

 

I'd imagine the correct thing to do in this situation is to create a post-install VI script to run GCC and compile the source for the host machine; has anyone done this before?

 

Cheers,

Martijn

Share this post


Link to post
Share on other sites

Hi Martijn,

 

Yes, I think you could add a post-install custom action VI that compiles your shared lib via the command line at install time.

 

But, would configuring the Call Library Function node with a .* (instead of ".DLL") file extension maybe solve your issue? What I mean is that, if you have the platform-independent shared libraries in the same folder and use the ".*" convention in the CLF node, then LabVIEW will load the right one for the target platform? For example, you could put "mylib.dll" (Windows) and "mylib.so" (Linus) side-by-side.

 

 

See this doc for more info:

http://zone.ni.com/reference/en-XX/help/371361J-01/lvexcodeconcepts/configuring_the_clf_node/

 

I hope this helps,

 

-Jim

Share this post


Link to post
Share on other sites

Hi Jim,

Looks like the Post Install Action is indeed what I want. The logic I've gone with is the check the "Files Installed" attribute for the source file to be compiled, and if found, use that path to execute the gcc call in the correct directory. My initial attempt used "Folders Created" to get the base dir but this did not seem to work when upgrading a package because I'm guessing the folders themselves are not recreated, but I think this works much better.

 

I am indeed using the .* convention of the CLN to pick the relevant library, which seems pretty convenient. I was just wondering if there were any unintended side-effects I should be aware of using this on other platforms than Windows. In particular I'm not clear on how it distinguishes 32/64-bit on Linux. Sadly I do not have a Linux license so I can't directly test myself.

 

Cheers,

Martijn

Share this post


Link to post
Share on other sites

In particular I'm not clear on how it distinguishes 32/64-bit on Linux.

 

Actually, I presume the lib*.* convention works the same on all platforms so I suppose I could distribute cross-compiled versions for each permutation. It will probably work but it'd be nice to get a Post Install Action to do it for me :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.