把一个包含多个子函数的C文件编译成obj添加到cs.lib中,如何在调用这个obj中的一个函数的时候不把其他函数也添加到程序中
把一个包含多个子函数的C文件编译成obj添加到cs.lib中,怎么在调用这个obj中的一个函数的时候不把其他函数也添加到程序中?
我现在写 了一个包含三个子函数的C文件,编译成obj后,用tlib添加到了cs.lib中,在另一个C文件的main函数中,调用了其中两个函数,但是我在debug下查看,发现内存中也有那个没有被调用的子函数的代码,这是为什么,怎么才能让没有被调用的函数不加载到程序中?
------解决方案--------------------
很正常, 除非你Loadlibrary运行时lazy load加载指定的函数.
RTLD_LAZY
Perform lazy binding. Only resolve symbols as the code that references them is executed. If the symbol is never referenced, then it is never
resolved. (Lazy binding is only performed for function references; references to variables are always immediately bound when the library is
loaded.)
------解决方案--------------------
这是静态库的特点,链接时整个库都放到程序中去了,造成程序体积增大,这是缺点,正为了消除这个缺点,才有了动态链接库,动态链接库进行运行时链接。
------解决方案--------------------
我现在写 了一个包含三个子函数的C文件,编译成obj后,用tlib添加到了cs.lib中,在另一个C文件的main函数中,调用了其中两个函数,但是我在debug下查看,发现内存中也有那个没有被调用的子函数的代码,这是为什么,怎么才能让没有被调用的函数不加载到程序中?
------解决方案--------------------
很正常, 除非你Loadlibrary运行时lazy load加载指定的函数.
RTLD_LAZY
Perform lazy binding. Only resolve symbols as the code that references them is executed. If the symbol is never referenced, then it is never
resolved. (Lazy binding is only performed for function references; references to variables are always immediately bound when the library is
loaded.)
------解决方案--------------------
这是静态库的特点,链接时整个库都放到程序中去了,造成程序体积增大,这是缺点,正为了消除这个缺点,才有了动态链接库,动态链接库进行运行时链接。
------解决方案--------------------