Got Stucked in C++ Static Library Loading.. for some time

I used to load library using 1 single .dll file, so when I happen to do method calling between 2 projects in a solution, I got puzzled..

In the solution, doing method calling between projects is constant, so as far as I can see, the dynamic calling method is onerous. It‘s also not Okay to call method from the other project directly, that will invoke the unresolved external link error(2001,1014,2011, etc..) during link.

Eventually I found that static calling is the remedy. In this way, you can avoid doing onerous calling that dynamic calling might cause. But the shortcoming is to attach a .lib with the release, making the size larger. Most times .lib files are small in size.

dynamic calling in x86 programs:

1 //method definition in .dll: type Func(type1 t1, type2 t2);
2 typedef type (*F)(type1,type2);
3 HINSTANCE hInst = new LoadLibrary(".dll");
4 F f = GetProcAddress(
5         hInst,
6         "Func"
7 };
8 //method name never coincides.

static calling:

1 //statically calling method
2 //First, specify the additional c/c++ include directory where func.h is in C/C++ general from project properties.
3 //Second, if needed, specify the func2.lib file directory in link general from project properties
4 //func.h
5 #include "func2.h"//this file contains the function definition
6 #pragma comment(lib, "func2.lib")//.lib file contains info about method addresses in .dll file
7 func2();//method calling
时间: 2024-08-25 16:25:16

Got Stucked in C++ Static Library Loading.. for some time的相关文章

使用Xcode 5创建Cocoa Touch Static Library(静态库)

转自:http://blog.csdn.net/jymn_chen/article/details/21036035 首先科普一下静态库的相关知识: 程序编译一般需经预处理.编译.汇编和链接几个步骤.对于我们项目中的一些公共代码,如果想要对其进行复用,可以把这些代码编译成一个静态库文件.在链接步骤中,链接器会从库文件中取得对应的代码并生成可执行文件.静态库的执行文件中包含了库中的完整代码,但是多次使用会产生多份冗余拷贝. 静态库和动态库的区别在于静态库在链接阶段被复制,与程序的运行阶段无关:动态

ios中静态库的创建和使用、制作通用静态库(Cocoa Touch Static Library)

创建静态库可能出于以下几个理由: 1.你想将工具类代码或者第三方插件快捷的分享给其他人而无需拷贝大量文件.2.你想让一些通用代码处于自己的掌控之下,以便于修复和升级.3.你想将库共享给其他人,但不想让他们看到你的源代码. Xcode6创建静态库详解(Cocoa Touch Static Library) 一.创建静态库文件 打开Xcode, 选择File ----> New ---> Project. 新建工程. 选择iOS ----> Framework & Library -

区别:Use MFC In A Shared DLL 和 Use MFC In A Static Library

摘自:Programming Windows with MFC, 2nd Edition Choosing Use MFC In A Shared DLL minimizes your application's executable filesize by allowing MFC to be accessed from a DLL. If you choose Use MFC In A StaticLibrary instead, Visual C++ links MFC code into

Use MFC in a Static Library 和 use MFC in a Shared

在这个选项上什么时候选哪个? 如果选择use MFC in a Shared DLL 的话,你编译后的程序中不包含MFC库,所以文件会比较小,但是如果你的程序直接移到一个没有安装过MFC的机器上时,可能会导致找不到MFC的DLL. 如果选择Use MFC in a Static Library ,那你编译后的程序就直接包含了调用MFC的部分的库,文件可能会大一些,但是可以直接移到其他机器上运行. 前者是静态链接,发布不用带MFC的DLL文件.    后者是动态连接,发布要带MFC得DLL文件.如

iOS 元件组件-创建静态库static library

概述 在项目开发的过程中,经常使用静态库文件.例如两个公司之间业务交流,不可能把源代码都发送给另一个公司,这时候将私密内容打包成静态库,别人只能调用接口,而不能知道其中实现的细节. 库是一些没有main函数的程序代码集合.除了静态库,还有动态链接库,他们之间的区别是:静态库可以编译到我们的执行代码中,应用程序可以在没有静态库的环境中运行:动态库不能编译到我们的执行代码中,应用程序必须在有链接库文件的环境下运行.另外,动态库在AppStore里,很有可能被拒绝,上架不了. 因而,一般情况下,我们都

iOS在Cocoa Touch Static Library使用CocoaPods

1.在XCode中新建静态库工程:DDLogLib. 2.添加对外暴露接口的头文件DDLogLibHeader.h 3.命令行进入DDLogLib目录,运行pod init,并修改Podfile 4.运行pod install,并打开DDLogLib.xcworkspace. 5.运行pod spec create DDLogLib,创建DDLogLib.podspec文件,并编辑. #  Be sure to run `pod spec lint DDLogLib.podspec' to en

基于pod自动创建:开发静态库(Static Library)

参考:http://blog.csdn.net/youtk21ai/article/details/50750300 http://www.cnblogs.com/brycezhang/p/4117180.html http://www.cocoachina.com/ios/20150228/11206.html 1.执行命令pod lib create TrapezoidButton.在此期间需要确认下面5个问题. What language do you want to use?? [ Sw

unrecognized selector sent to class & static library with category problems

一:这里先讲解网络上基本解决方案,解决不了的,直接跳到第二步 1.苹果官方的解决网址:https://developer.apple.com/library/mac/qa/qa1490/_index.html 2.出现这个问题的原因网址:http://www.cnblogs.com/wendingding/p/3893095.html 二:重写编写自己的framework: 在framework中有关出现的category文件全部按照规范的格式进行编写:一个category对应一个.h与.m.

IOS三步生成静态库(static library )

一.创建 (创建一个静态库项目) 二.编译 (command+B) 三.合并lib lipo -create 真机.a 模拟器.a -output /Users/my/Desktop/lib/lib.a