12-14-2018 12:26 AM
Deal all,
I'm looking for how to set a linker option, specifically something like "/INCLUDE" (Force Symbol References) in the Visual Studio IDEs.
I tried to add "#pragma comment(linker, "\INCLUDE: <symbol>") to my code but it didn't work. I guess the "\INCLUDE" option only works for the VS.
So, can I do it in CVI? If so, how? I looked through all menu items that seem to be related to it but couldn't find.
BTW, I need it for using TCMalloc in CVI without changing all malloc() to tc_malloc(). I could make it by calling tc_malloc() function at least once somewhere in code, but I would like to do it by more 'convincing' way.
Thanks!
Solved! Go to Solution.
12-14-2018 07:42 AM
If its an .obj file or a .lib, try adding it to your cvi project and recompile.
12-16-2018 08:39 PM - edited 12-16-2018 08:41 PM
Thank you for your comment, Razvan_Pora.
I already added all the needed files such as .lib and .h to the project tree and included the header file in the source file.
I can be sure it's not automatically applied by measuring the time consumed for malloc. I could see the much faster result only when I call tc_malloc() at least once and then use malloc(), which means the rest malloc() invocations were automatically replaced by tc_malloc(). It's still slow and seems the default malloc() is invoked when I don't call tc_malloc() at least once, which means the malloc() functions were not automatically replaced by tc_malloc().
Visual Studio has the option, "Force Symbol References," in order to replace malloc() with tc_malloc() automatically, or we can put #pragma comment(linker, "/include:__tcmalloc") in the code, but it seems CVI doesn't have the option nor does it support #pragma comment. Am I missing something here?
Thanks!
12-17-2018 02:30 AM - edited 12-17-2018 02:32 AM
In C you have several options to replace standard C functions with your own, such as 'weak' definitions or using preload. Some only work in gcc and CVI uses clang (but you can change that).
In your case you may also be able to simply add /Dmallod=tc_malloc to the [Options][Build options] macros.
12-17-2018 06:06 PM - edited 12-17-2018 06:08 PM
@gdargaud 작성:
In C you have several options to replace standard C functions with your own, such as 'weak' definitions or using preload. Some only work in gcc and CVI uses clang (but you can change that).
In your case you may also be able to simply add /Dmallod=tc_malloc to the [Options][Build options] macros.
Thank your for your comment, @gdargaud!
Adding the macro option works like a charm!
#EDIT: BTW, there was a small typo, /Dmallod ==> /Dmalloc