LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI can not link VS2010 static lib files

Solved!
Go to solution

A completely new static lib file created in VS2010 Express hat the following content:

 

StaticLib.h:

void __stdcall call( void );

 

StaticLib.c

void __stdcall call( void ){ }

 

VS2010 compiles this as a c file. This is already ensured by the ending ".c", but to be safe I use the compiler option /TC .

All other options are at their default value. I compile using "Release | Win32".

 

The created lib file is copied to an new CVI folder, along with the header.

Both files are added to the project.

In addition a main.c is created with the following content:

 

void main ( void ){ call(); }

 

The compile attempt is aborted with the following error message:

 

 Bad header encountered while reading external module: 'Release\StaticLib.obj'.

 Aborted load of member "Release\StaticLib.obj" from library "c:\C90\LibImportTest\Release\LibImportTest.lib".

 

Is there a way to reuse static lib files compiled in VS2010 with CVI?

If so please show me a minimal example.

( please do not post any suggestions involving dlls )

 

0 Kudos
Message 1 of 6
(3,458 Views)

Do you run a 64 bit Operating System?

 

Best regards,

Adilo

0 Kudos
Message 2 of 6
(3,433 Views)

Yes, but both projects are compiled as 32 bit.

0 Kudos
Message 3 of 6
(3,412 Views)

I also posted this on the stackoverflow forum.

 

I found a possible cause for the problem. Is CVI capable of linking multithread static libraries?

 

0 Kudos
Message 4 of 6
(3,403 Views)
Solution
Accepted by topic author ComputerUser

I tried this with CVI 2012. I think its the VC 2010 Project Setting: Configuration Properties >> General >> Whole Program Optimization = Use Link Time Code Generation that causes the problem with CVI. Change this setting to "No Whole Program Optimization" and CVI 2012 is able to link the VC 2010 lib file for me. Hope this is the same issue for you. If not, try changing other VC optimization or language settings in the Project Properties dialog..

0 Kudos
Message 5 of 6
(3,384 Views)

Thank you.

I just tried it and it solves the Problem.

 

If you have a stackoverflow account post there too - i can accept your solution there also.

0 Kudos
Message 6 of 6
(3,380 Views)