LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I put some linker options?

Solved!
Go to solution

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!

0 Kudos
Message 1 of 5
(3,080 Views)

If its an .obj file or a .lib, try adding it to your cvi project and recompile. 

0 Kudos
Message 2 of 5
(3,051 Views)

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!

0 Kudos
Message 3 of 5
(3,040 Views)
Solution
Accepted by topic author pcandme

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.

Message 4 of 5
(3,029 Views)

@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 Smiley Wink

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