LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Third party compiled .dll throws bad COFF Library member header link error

Solved!
Go to solution

Hello,

Has anyone successfully worked through the process of linking and building third party library files into a LabWindows executable?

 

Specifically, I am trying to build an executable in CVI that depends on .dll and .lib files generated using the minGW compiler. (gcc)  This always results in a failed link attempt with:

"Aborted load of library "library path/name".
And:
"Bad COFF Library member header."

I have read the minGW docs, to verify it produces COFF complaint files, by default, but evidently there is something I have missed. 

The dll is simple (two exported functions) And the using program is even simpler, a main() with a single call to one of the dll_exports.  The following files are included in the attached zip file:

files for building executable in LabWindows/CVI:
LWCVI_use_test_dll.c
LWCVI_use_test_dll.cws
LWCVI_use_test_dll.prj
test_dll.h
test_dll.lib
test_dll.dll

 

files for creating .dll using minGW

test_dll.h

test_dll.c

 

Also the following #define is used to export function in minGW project

 

#define DLL_EXPORT __declspec(dllexport)

 

 

Any help will be greatly appreciated
Thanks,
Ryk

0 Kudos
Message 1 of 7
(4,496 Views)
Solution
Accepted by topic author ryk

There is something wrong with test_dll.lib, but I don't know what it is.

 

You can, however, generate an alternative import library within CVI from the test_dll.h file. Open this file in CVI, remove the #include <windows.h> line, then use the Options|Generate DLL Import Library... menu item to generate a new library.

 

Attached is the import library I generated using this method.

 

--
Martin
Certified CVI Developer
Message 2 of 7
(4,456 Views)

Msaxon,  ...  (What version of CVI did use to create the new import lib?)

 

The import lib you sent, "test_dll.lib" worked right away.  Great! Thanks.

 

But I am curious, what version of CVI are you using.  I am using version 2010, and do as you suggested, and opened the file test_dll.h in my CVI editor, and used the Options->Generate DLL Import Library utility, after displaying  the file selection popup, and I type in the desired name "test_dll.lib", the CVI environment collapsed.  I repeated this after having made sure the original "test_dll.lib" did not exist in the target directory, it still collapsed.

 

Ryk

0 Kudos
Message 3 of 7
(4,447 Views)

Msaxon,

 

I just discovered that I was using the Generate DLL Import Library utility wrong.  In the filename box, at the bottom of the FileSelectPopup, I was typing the name of the .lib file I wanted.  This always results in CVI crashing.  When I just selected the .dll for which the .lib is to be created, it all worked fine.

 

So, thanks for your help.

 

Ryk

0 Kudos
Message 4 of 7
(4,441 Views)

Hello -

 

This appears to be an issue with the way we are reading the import library.  I've filed a bug report with ID 289949 for further investigation.

 

NickB

National Instruments

0 Kudos
Message 5 of 7
(4,399 Views)

Hello  Ryk,

 

 

Would you please explain how to resolve the problem?

 

 

David

0 Kudos
Message 6 of 7
(4,176 Views)

At the time I saw this problem, CVI was not reading the files correctly and a bug report was filed describing the issue (see earlier tags in this post) So the problem may not exist anymore, but here was my workaround at that time:

 

I used the "Generate DLL Import Library" utility that is built into the LabWindows/CVI environment under the Options menu.  Once the .dll is built (using a third party compiler) place it and the header file prototyping the functions somewhere in your CVI project directories. Open the header file in the CVI editor.  (If it is already opened along with other files, bring it into focus by selecting it)  Under the Options Menu, select Generate DLL Import Library.  Follow the prompts appropriate to your project.  (i.e. I just said "OK" without selecting either IVI or VXIplug&play for that popup prompt).  When the file select popup occurs, navigate to the target .dll and select it.  After responding to any additional prompts, a .lib will be produced that should be completely compatible with CVI.

 

Hope this helps,

Ryk

0 Kudos
Message 7 of 7
(4,171 Views)