Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Unresolved external symbols when linking C++ with ni.4882.obj

Solved!
Go to solution

Moving from 32-bit XP to Windows 7 using Microsoft Visual Studio 2008 C++.  When linking with NI-488.2 version 3.0.2 I (ni4882.obj) get the following warning and errors:

 

1>Linking...

1>ni4882.obj : warning LNK4217: locally defined symbol _time64 imported in function time

1>ni4882.obj : error LNK2019: unresolved external symbol __imp_rand referenced in function LoadFunction

1>ni4882.obj : error LNK2019: unresolved external symbol __imp_srand referenced in function LoadFunction

1>ATP.exe : fatal error LNK1120: 2 unresolved externals

1>Creating browse information file...

1>Microsoft Browse Information Maintenance Utility Version 9.00.21022

1>Copyright (C) Microsoft Corporation. All rights reserved.

 

Any ideas.

0 Kudos
Message 1 of 10
(10,670 Views)

Hi ndg12,

 

I recommend you to take a look to these MSDN pages to solve these errors and that warning:

 

http://msdn.microsoft.com/en-us/library/aa3se25k.aspx

http://msdn.microsoft.com/en-us/library/799kze2z.aspx

 

Regards,

 

Carmen C

 

0 Kudos
Message 2 of 10
(10,634 Views)

I would start with the ReadMe and look at the notes on the Microsoft Visual Studio Support table.  This KB may also help assuming you are porting older code


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 10
(10,630 Views)

Got an error when attempting to navigate to the ReadMe page.  Aren't these errors being generated from within the National Instruments "ni4882.obj" file?  Was it generated with a later version of Microsoft Visual than my 2008 version?  I don't have source code for that object file.

0 Kudos
Message 4 of 10
(10,602 Views)
Solution
Accepted by topic author ndg12

Apparently this problem can be alleviated by using dynamic link libraries rather than static link libraries.  I would certainly prefer static libraries since my application will be distributed widely.  Don't know who to blame.  It could be a NI or a Microsoft problem.

0 Kudos
Message 5 of 10
(10,565 Views)

There are 2 ways of linking libs with MSVC and more generally IDE's (sorry if repetitive) :

• .dll => linked by environment path => dynamic

• .lib => linked in your IDE and/or makefile => static

 

I personnaly never use .obj, but I'd bet you should avoid using it and prefer .lib.

0 Kudos
Message 6 of 10
(10,547 Views)

 

 

Hi Guys,

 

I got this error too recently. Was troubling me a lot. I was using Windows 7 OS, Visual Studio 2010 compiler.

 

The fix for this is pretty much straight forward and solution lies in the Project settings only.

To my knowledge, with /MDd switch, it causes the compiler to place the library name MSVCRTD.lib into the .obj file.

But with /MTd switch, This option just causes the compiler to place the library name LIBCMTD.lib into the .obj file so that the linker will use LIBCMTD.lib to resolve external symbols. For details, please refer to this MSDN article:

https://msdn.microsoft.com/en-us/library/2kzt1wy3(VS.71).aspx

 

Its very useful.

 

Also

 

MDd stands for Multi-threaded Debug DLL
MTd stands for Multi-threaded Debug

 

Thanks,

Kiran

 

 

 

 

0 Kudos
Message 7 of 10
(9,139 Views)

What was "the fix" in project settings that was straightforward? I have been struggling with this issue for a while now and the page linked does not exist anymore. Is it possible to use static linking with NI488.2 libraries or was "the fix" to use dynamic linking? Because my application requires static linking.

0 Kudos
Message 8 of 10
(6,164 Views)

Since this is an old post, I would reccommend creating a new post and link to this one for increased visibility.

 

However, I was able to find the broken link from above using the Wayback Machine.

 

https://web.archive.org/web/20141015005439/http://msdn.microsoft.com:80/en-us/library/2kzt1wy3(VS.71...

 

Hopefully that will help you with your problem.

Casey G.
0 Kudos
Message 9 of 10
(6,148 Views)

Thanks, I will try a new thread.

 

edit: new thread is here: https://forums.ni.com/t5/Instrument-Control-GPIB-Serial/NI-488-2-static-linking/td-p/3738956

 

 

0 Kudos
Message 10 of 10
(6,144 Views)