Switch Hardware and Software

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use more than one .uir callback file in a VC++ project

Hi,

I have a DLL project developed in Labwindows CVI 6.0. This project contains a .uir file. I'm generating UIR callbacks object file (.obj) and including the .obj file and .lib file in my VC++ application project. With this it works fine.

Now i have to integrate one more CVI dll with UIR call backs in it to my VC++ project. I included the additional .obj file and .lib file into my VC++ project. Now i have 2 UIR callback .obj files (SmallM_cbacks.obj & BigM_cbacks.obj) and 2 .lib files (1 for each DLL) included in my VC++ project. But when i build the project i'm getting the following link errors.

SmallM_cbacks.obj : error LNK2005: ___UICallbackSymbolCount already defined in BigM_cbacks.obj
Smal
lM_cbacks.obj : error LNK2005: ___UICallbackSymbols already defined in BigM_cbacks.obj
SmallM_cbacks.obj : warning LNK4006: ___UICallbackSymbolCount already defined in BigM_cbacks.obj; second definition ignored
SmallM_cbacks.obj : warning LNK4006: ___UICallbackSymbols already defined in BigM_cbacks.obj; second definition ignored


Since .obj files are generated by CVI, i don't have any control over them.

Can anybody tell me how to resolve this linking problem ?

Thank you in advance,
Swamy
0 Kudos
Message 1 of 10
(8,467 Views)
Hello Swamy,
Are you trying to combine two CVI projects in VC++, and create one dll out if it? That is not possible to do. You cannot have two obj files for uir files, because those two generated obj files contain the same symbols. You can fist combine two projects in CVI, create one obj file, then import it to VC++.

Mika Fukuchi
Application Engineer
National Instruments
Message 2 of 10
(8,466 Views)
Hi,

Thanks. I appreciate your response.

I can make my application work with this approach. But the tasks performed by different CVI DLLs that i'm trying to link to VC++ are totally different. That was my whole purpose of seperating them.

This problem arises because, every UIR callback object file (.obj) will contain at least 2 symbols '__UICallbackSymbolCount' & '__UICallbackSymbols'. The naming convention is causing all the problems here. If CVI can prefix or postfix these symbols with project name or any other approach to uniquely name these symbols, then the problem can be solved properly.

Any comments ?

Thanks again.
-Swamy
0 Kudos
Message 3 of 10
(8,466 Views)
Hello Swamy,
Are you just trying to link two DLLS that you created in CVI, in your VC++ project? In that case, you don't need the obj files for callbacks included in your VC++ project. You'll just need .dll, .lib, and .h files. Also, make sure you use LoadPanelEx instead of LoadPanel. You need the obj file for the callbacks only if you want to compile/link your files you created in CVI, in another compiler, in this case, VC++. Does that make sense?

Mika Fukuchi
Application Engineer
National Instruments
0 Kudos
Message 4 of 10
(8,466 Views)
Hi,

I think i wasn't clear.
My DLL (CVI)projects contains UI and the functions exposed from my DLL uses some of the UI features. It simulates clicks on some UI items like buttons and depending on that it takes some action. So i need to reference .uir file. Also for the linking to succeed, i need the .obj file generated through CVI.

Correct me if i'm wrong.

Since i have 2 seperate DLLs, both containig some UI, i'm having 2 .uir files & DLLs in my .exe path. Also i'm including the .lib & .obj files during the build. This is still causing the grief.


Thanks,
Swamy
0 Kudos
Message 5 of 10
(8,466 Views)
Hello,
Oops, I made one mistake. You'll need .dll, .lib, .h, AND .uir files. But you do NOT need to include the .obj file for the callback table, in your Visual C++ project, as long as you created the DLL in CVI.
0 Kudos
Message 6 of 10
(8,466 Views)
Hi,

Whatever you said in the earlier comment makes perfect sense. I wrote a sample and tried that. It works fine without the .obj file. Thanks a lot.

But what if, i have 2 static libraries built using CVI which, contains UI ? I wrote samples to test the same. But if i don't include .obj files in my VC project, compilation & linking succeeds. But during run-time it fails with error code '-86 '. But if i include the .obj files, it works fine.

I'm supposed to build static libraries in my project. Pls let me know how to make it work ?

All these times, i was thinking that behavior would be the same both for static library and DLL. I know, i was definitely wrong. Sorry for that.

I appreciate your help.
Swamy
0 Kudos
Message 7 of 10
(8,466 Views)
Hello,
Yes, you are correct. If you want to use a static library created in CVI, and if that library exports a function that loads a panel, then you'll need the obj file for the callback table included in your Visual C++ project.

Mika Fukuchi
Application Engineer
National Instruments
0 Kudos
Message 8 of 10
(8,466 Views)
Thanks.

So if i understand correctly, you mean to say that we can't include more than 1 .obj files into VC project & this is a limitation of CVI.

Pls clarify.


Thanks,
Swamy
0 Kudos
Message 9 of 10
(8,466 Views)
Yes, you can. I've just created a KnowledgeBase explaining how. Here is the link to it:

http://pong.ni.com/public.nsf/websearch/AE2DC850FAA1C66686256CB00072B982?OpenDocument

Mika Fukuchi
Application Engineer
National Instruments
0 Kudos
Message 10 of 10
(8,467 Views)