LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems adding the activex instrument/ experiencing undefined symbol link errors (Excel)

Any help on this would be HIGHLY appreciated.
 
I have a program which uses the excel commands heavily.  And I've had it working in the past.  Then it quit working.
 
I kept recreating the activex controller again and again until it fixed it.
 
Then it quit working again (just because I renamed the project).
 
I fixed it that time by adding the excelreport.c and excel2000.c files right into the build.
 
But now it's not working AGAIN and I can't figure out (1) what's breaking it in the first place and (2) how to fix it.
 
Basically here's the error:
 
link error
 
Undefined symbol '_ExcelRpt_WorkbookSave@12' referenced in "myfile.c"
 
referring to the command line
 
ExcelRpt_WorkbookSave (workbookHandle, pathname, 0);
 
So I mean it's compiling okay, it's just not linking for whatever reason.  Similar error for every excel command I use.
 
Here's how I'm rebuilding the activex controller:
 
Tools --> Create ActiveX controller
 
ActiveXServer: Microsoft Excel 11.0 Object Library
Instrument Prefix: Excel
Target .fp file:  (either excelreport.fp or excel2000.fp located at C:\Program Files\National Instruments\CVI80\toolslib\activex\excel
Add .fp File to project (checked)
 
and then just create it.  It then adds it to "instruments" both in the libraries frame and in the project frame.
 
The heavyhanded method of putting it in the build was accomplished just by opening the file in the project.
 
But even though those have fixed it in the past, both fail a lot of the time (all day today for instance) and I still have the problem.
 
Seriously...any thoughts on why it keeps breaking or how to fix it when it does?  It'll work fine for weeks and then take me several days to fix.
 
 

Message Edited by amberray on 09-14-2007 07:02 PM

Message Edited by amberray on 09-14-2007 07:05 PM

0 Kudos
Message 1 of 6
(4,261 Views)
amberray,

Any time you get a linker error, it means that the actual implementation of a function is not included in your project.  Normally, you include the implementation by adding a .c, .lib, or .obj file to your project that contains the definition.  In CVI, you can also use a .fp file to include an implementation by adding the .fp to your project.  The .fp file doesn't actually contain the implementation, but it is associated with a .c, .lib, or .obj file residing in the same directory that does.  If you look at the <CVI>\samples\activex\excel\excelreportdemo.prj, you will see that excelreport.fp is listed in the project, which is how the implementations are included.

If you want to see what implementation file is actually associated with a .fp file, you can select Instrument >> Edit, select your instrument, and press the "Show Info..." button.  It will show the "program file" that contains the implementation.

In addition to using any .fp file listed in your project, the CVI linker will also use any .fp files that have been loaded and are listed in the Instrument menu.  One side effect of this is that you can manually load (Instrument >> Load) or inadvertently load (such as running the ActiveX Controller Wizard *without* selecting the "Add .fp file to project" option) a .fp file and it will be included by the linker until you exit CVI and restart.  When you restart, the .fp file is not loaded (since it is not specifically listed in the project) and building the same code again will now result in a link error.

One last point about .fp files.  If one instrument (such as excelreport.fp) depends on another instrument (such as excel2000.fp), this information can be stored in the .fp file so that all you need to do is add excelreport.fp to your project and CVI will automatically load the implementations for excel2000.fp when the linker needs them.  So if you only use functions in excelreport.fp, you need to add excelreport.fp to your project, but you don't need to add excel2000.fp.

So all this is to say that you should to include the appropriate .fp files in your project.  Alternately, you can add the .c files to the project instead as mentioned in your post and it will work, but it is not the typical method.

Now, you mention that you have regenerated both excelreport.fp and excel2000.fp using the ActiveX Controller Wizard.  This might be your problem.  First, you shouldn't need to regenerate excel2000.fp as it should never change.  If you happen to accidentally make changes to it or delete it, you should repair your CVI installation or copy the files from another machine with CVI installed.  It is possible to regenerate excel2000.fp using the ActiveX Controller Wizard, but you need to choose every option exactly right (including the Compatibility Options and ActiveX control options) and probably need to resolve some naming conflicts in exactly the same way it was done originally.  This isn't easy, which is why you should repair or copy the files instead.  Second, there is no way to regenerate excelreport.fp as it was not created this way originally.  There is no way to restore this file other than to repair CVI or copy from another machine.

Hopefully that gives you a better understanding of what might be going wrong and how to go about fixing it.

Let us know if you get it figured out or if you need more info.

-Jeff

Message 2 of 6
(4,233 Views)
Thank you.  I know I've had the .fp files in my project and that doesn't solve it. 

I think you might be right though about having somehow corrupted the files.  I don't have another machine with CVI installed, but I do have the actual installation disks available.  I assume one of these would have it, yes?  Do you know which one?  I'll check it out when I get to work Monday.

If that doesn't work, do you know if NI would be willing to email me copies of the original files?  I will call and ask if I can't get it off the CDs.
0 Kudos
Message 3 of 6
(4,224 Views)
amberrray,

The fp file should be in the CVI installation CD located in Parts\CVI\Main\CVIMain1.cab. You need to change the extension of course. But I think it might be safer if you do a repair instead of moving the file from the CD.

Song D
Regards,

Song Du
Systems Software
National Instruments R&D
0 Kudos
Message 4 of 6
(4,195 Views)
There actually was a copy of the program on another computer and I got the files from there to replace the ones on mine (the entire contents of the excel folder, including the .fp files).  That didn't help.  I'm going to try do a re-install this afternoon, but I can't help wondering if my problem is elsewhere.  Could there be compatibility issues with some other program on the computer?  (some version of excel perhaps?  I'm running 2003)
 
 
0 Kudos
Message 5 of 6
(4,188 Views)
If the problem that you're still having is that you are getting the link error that you described in your initial post, then it is very unlikely that the root cause of the problem is any incompatibility with other software in your computer, Excel included. That particular link error is pointing exclusively to the Excel Reports library, which is implemented by excelreport.*.

Try loading and building the following CVI example: samples\activex\excel\excelreportdemo.cws. If that example builds and runs okay, then the problem should be limited to your project file, and it shouldn't be too hard to fix it. However, if the example project also gives you errors, then there's some kind of problem with excelreport.fp or excelreport.c. In that case, first make sure that excelreport.fp is included in the project. Then, click on Instrument>>Edit, select "Excel Report" from the list and then click on the "Show Info" button. You should see  toolslib\activex\excel\excelreport.c listed as the program file, with the "Compiled" checkbox enabled. Simply make sure that this file exists and that it hasn't been modified in any way (I expect that you also restored it when you copied your files from the other computer). You also can open this file and browse its contents. Make sure that the definition of the ExcelRpt_WorkbookSave function is there as expected. Finally, verify that excelreport.h is also unmodified, that its prototype definition for ExcelRpt_WorkbookSave matches what's in the .c file, and that it's included from your program.

Let us know what you find.

Luis

0 Kudos
Message 6 of 6
(4,175 Views)