03-15-2011 12:02 PM
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
Solved! Go to Solution.
03-18-2011 12:09 PM - edited 03-18-2011 12:09 PM
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.
03-18-2011 03:39 PM
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
03-18-2011 04:23 PM
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
03-21-2011 09:20 AM
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
10-01-2012 10:04 AM
Hello Ryk,
Would you please explain how to resolve the problem?
David
10-01-2012 01:31 PM
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