Remember once C ++ programming reference obj file as a static library files

Brief introduction

Common name is generally static library file ***.lib, for example, nisyscfg.libis a static library file, but is actually a routine reference **.objfile as a static library, a little unconventional ah.

This is a NI488.2 routine, a routine in which the documentation is as follows:

Microsoft Visual C++ (64-bit)
With Microsoft Visual C++ (Version 8.0 or higher), this is done by
typing in using the 64-bit environment:
cl /I"%NIEXTCCOMPILERSUPP%\include" 4882query.c "%NIEXTCCOMPILERSUPP%\lib64\msvc\ni4882.obj" /MD

As can be seen in the compilation command to set the first sample program contains the file path, the file path to the library. Where libraries are ni4882.obj . According to project documentation set:

Set the header file path, file path library

Add the name of dependent libraries

unresolved external symbol

Create a new command-line project, which was originally only the output of the Hello World !!! , I intend to change the name of the entry function for the sample program int __cdecl entry_4882query(void)as a function of the introduction to the command line main()functions, directly translated, it was an error, confused.

Thought for a moment, just new construction is C++construction, but are all examples of works written in C language, is it a problem here, so I'm going to add some finishing touches something in the example of project source files, as follows:

#include "ni4882.h"

#ifdef __cplusplus
extern "C" {
#endif

int __cdecl entry_4882query(void)
{
    //.....
}

#ifdef __cplusplus
}
#endif

However, after compiling or wrong.

Finally, the aid will be, they would understand the original source and header files need to add __cplusplusmarks for the job.

Between the computer and the instrument through a GPIB card, the instrument performs power results are as follows:

666431-20190618163943758-1405797489.png

Instrument off the results:

666431-20190618163959994-337430845.png

to sum up

  1. Do not fall into thinking errors, filed a static library file is *.liblikely to vendors is a *.objfile;
  2. C code with C ++ code compatibility issues, and newcomers stepped pit too little, what problems are encountered new problems.

Reproduced in: https: //www.cnblogs.com/LinTeX9527/p/11045815.html

Guess you like

Origin blog.csdn.net/weixin_34337381/article/details/93460765