From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Export functions in CVI executable

I know how to export functions, when creating DLL - using __cdecl(dllexport) functionname...
I want to do the similar if my target is not DLL but executable. Even, when I include export functions in executable, there are no export table in it. Also, no available such target options (for export) in CVI environment 5.5. Please tell me, how to make functions visible also in exe files (I needed for protection software, which requires such functions in my application exe). Thanks!
0 Kudos
Message 1 of 5
(3,606 Views)
Hello

You cannot export a function from an executable in CVI, I guess the way the options are set, you are only allowed to export symbols only if you create a dll.
Generally, this is not considered healthy (even by Microsoft) because if you end up using LoadLibrary to load the exe, its startup code and global data will not get initialized, causing general unpredictable funckiness. Here is a discussion on the topic i found on google about it.

You might want to consider maki
ng a COM server out of the executable.

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 5
(3,607 Views)
Hi,

I do not want to load a exe like a dll from another exe, I just want to have the address of a function inside my exe. Of course, it would be quite simple if I would do it from c code, but in my case a third party library included in my project has the built-in capability to request the address of a certain function inside a dll or alternatively inside the executable itself. CVI promises for compatibility to Visual C++, but in this case it isn't (because the CVI executable does not have a symbol export table like the Visual C++ executable). The library fails, is there any chance to have the symbol export table inside the executable?

regards
0 Kudos
Message 3 of 5
(3,455 Views)
Hi W. Lenz,

You can create a map file for CVI executables by selecting Build >> Target Settings and then choose the Generate map file option.  This map lists the address of every function and variable and the name of the function or variable. This feature is useful for example if your program crashes and provides an address where the failure occurred.  You can view the map file to check which function or variable the crash occurred in.

The map file is found in the cvibuild.projectname directory under the main project directory with a filename of map_projectname.txt if you create a release executable or map_projectname_dbg.txt if you create a debuggable executable.

Hope this helps!

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 4 of 5
(3,445 Views)
Thank you Jonathan N.,

now the map information should have been embedded into the executable. I cannot modify the dll which assumes to find an exported function as it does in executables build with Visual C++ (when the export qualifier in the function prototype is present).
For compatibility reason, you should consider to include the export table of CVI executables in future versions (please).

regards Walter

0 Kudos
Message 5 of 5
(3,433 Views)