Flying Swissman
Flying Swissman

Reputation: 803

Creating a DLL for Labview

I have a c-project from which I make an .exe using Mingw gcc compiler. I need to make a dll for labview. I've read various locations how to this but none seem to completley inform me how this is done.

I added the compiler setting -shared

enter image description here

And then I was able to successfully load the dll and use the functions in an other C-project and also in labview.

However all functions are visible in labview and i haven't added the

__declspec(dllexport)

which I'm told to do for example on the Mingw website.

Have I done this correctly, or is there something that could go wrong here?

Upvotes: 0

Views: 870

Answers (1)

oysstu
oysstu

Reputation: 163

In gcc, all symbols (functions) are exported by default. This is not the case for Visual Studio, which most of the guides are based on.

Control of exported symbols can however be enforced by disabling the default export. This can be done by passing.

-fvisibility=hidden

To every call to the compiler. And subsequently marking exported functions with.

__attribute__ ((dllexport))

Just as you would use declspec. There are benefits to doing this, which is better explained in the following page. https://gcc.gnu.org/wiki/Visibility

Edit : I see that using mingw changes this a little.

If you pass the -no-undefined and --enable-runtime-pseudo-reloc options to the linker, you don't have to add dllimport or dllexport attributes to the source code that the DLL is made with ; all functions are imported/exported automatically by default, just like in unices.

From: http://www.mingw.org/wiki/sampledll

Are you passing any of these flags to the linker?

Upvotes: 2

Related Questions