vs2005下面编译自己的luars232.dll
vc6在win7下用不了,大家建议使用vs2005。。。所以就装了,但是还是提示有不兼容,不过是可以用的。先凑合用,装了个2012,庞然大物!而且折腾了半天不知所云。先这样吧。
简单记录操作过程,参考了msdn的文档;http://msdn.microsoft.com/en-us/library/ms235636(v=vs.80).aspx
1、file->new proj
2、proj types, C++->win32
3、template->win32 console application
4、输入你的proj name和path,ok&next
5、application settings,application types->dll(or console application if not available). Some versions of Visual Studio do not support creating a DLL project using wizards. You can change this later to make your project compile into a DLL
6、application settings,additional options->empty project
7、add your code to project
我添加的源文件是lua的扩展库librs232.zip里copy出来滴。到这一步骤位置,没有遇到什么问题。
err1 -编译,遇到下面这个问题:
error C2491: 'luaopen_luars232' : definition of dllimport function not allowed
msdn的帮助看得有点晕,然后找到原来的工程,比较了下,在“属性->配置属性->C/C++->命令行”添加了下面两个宏,然后就可以编译了:
/D_CRT_SECURE_NO_DEPRECATE /DRS232_EXPORT
转到问题所在代码行,这些代码意思是如果我们没有定义DRS232_EXPORT,那么我们就定义函数为__declspec(dllimport),而我们生成dll使用定义__declspec(dllexport)。所以就又错了。
err2 -编译,遇到说是缺头文件,
fatal error C1083: Cannot open include file: 'lauxlib.h': No such file or directory 1>rs232.c
这个是正常的,是应该添加我们用到的头文件,添加标准头文件在这里:“属性->配置属性->C/C++->常规->附加包含目录”。
我的lua include文件在这里:C:\Program Files\Lua\5.1\lib
添加之,然后就可以了。
err3 -链接,遇到说无法解析符号,
error LNK2019:无法解析的外部符号
当里个当,猜是没有给连接器制定lib文件的缘故,所以在这里,添加lib路径:“属性->连接器->输入->附件依赖项”。
我的lua lib路径是:C:\Program Files\Lua\5.1\lib\lua5.1.lib
err4 -但是继续编译遇到另一个问题:
LINK : fatal error LNK1104: 无法打开文件“C:\Program.obj”
搜了一下,说是我们要自觉的给我们路径加上引号,比如上面的lib,应写作: "C:\Program Files\Lua\5.1\lib\lua5.1.lib"
如果没有了上面的引号,而且引号必须是英文滴。因为如果没有引号,在编译器自动生成的makefile里,编译器能找到的就是C:\,而不是我们添加的lib路径。修改之,则没有其它问题。
到此为止,俺再vs2005下的第一个dll文件生成成功。
===
另外,留一下文档,怎么使用我们编译好的dll。
To create an application that references the dynamic link library
To create an application that will reference and use the dynamic link library that was just created, from the File menu, select New and then Project….
From the Project types pane, under Visual C++, select Win32.
From the Templates pane, select Win32 Console Application.
Choose a name for the project, such as MyExecRefsDll, and enter it in the Name field. Next to Solution, select Add to Solution from the drop down list. This will add the new project to the same solution as the dynamic link library.
Press OK to start the Win32 Application Wizard. From the Overview page of the Win32 Application Wizard dialog, press Next.
From the Application Settings page of the Win32 Application Wizard, under Application type, select Console application.
From the Application Settings page of the Win32 Application Wizard, under Additional options, deselect Precompiled header.
Press Finish to create the project.
To use the functionality from the class library in the console application
After you create a new Console Application, an empty program is created for you. The name for the source file will be the same as the name you chose for the project above. In this example, it is named MyExecRefsDll.cpp.
To use the math routines that were created in the dynamic link library, you must reference it. To do this, select References… from the Project menu. From the Property Pages dialog, expand the Common Properties node and select References. Then select the Add New Reference… button. For more information on the References… dialog, see References, Common Properties, <Projectname> Property Pages Dialog Box.
The Add Reference dialog is displayed. This dialog lists all the libraries that you can reference. The Project tab lists all the projects in the current solution and any libraries they contain. From the Projects tab, select MathFuncsDll. Then select OK. For more information on the Add Referencedialog, see Add Reference Dialog Box.
To reference the header files of the dynamic link library, you must modify the include directories path. To do this, from the Property Pages dialog, expand the Configuration Properties node, then the C/C++ node, and select General. Next to Additional Include Directories, type in the path to the location of the MathFuncsDll.h header file.
Dynamic link libraries are not loaded by the executable until runtime. You must tell the system where to locate MathFuncsDll.dll. This is done using the PATH environment variable. To do this, from the Property Pages dialog, expand the Configuration Properties node and select Debugging. Next to Environment, type in the following: PATH=<path to MathFuncsDll.dll file>, where <path to MathFuncsDll.dll file> is replaced with the actual location of MathFuncsDll.dll. Press OK to save all the changes made.
vs2005下面编译自己的luars232.dll的更多相关文章
- dnSpy进行反编译修改并编译运行EXE或DLL
dnSpy对目标程序(EXE或DLL)进行反编译修改并编译运行 本文为原创文章.源代码为原创代码,如转载/复制,请在网页/代码处明显位置标明原文名称.作者及网址,谢谢! 本文使用的工具下载地址为: h ...
- c#动态编译并动态生成dll
/// <summary> /// 动态编译并执行代码 /// </summary> /// <param name="code">代码< ...
- VS2005 VS2008编译的程序在Win7下以管理员身份运行的设置
在VS2005或者VS2008 里面,直接项目右键---属性---连接器---清单文件---uac执行级别 选择requireAdministrator 重新编译 这样你的程序直接运行就拥有管理 ...
- VS2005混合编译ARM汇编代码-转
原文地址:http://blog.csdn.net/annelcf/article/details/5468093 公司HW team有人希望可以给他们写一个在WinCE上,单独读写DDR的工具,以方 ...
- windows下编译php7图形库php_ui.dll
CSDN博客 具有图形化编程才有意思,这几天看到了php ui 图形扩展,只是现在只能下载php 7.1的 本次教程编译php7.2.6的 php ui 要是linux下编译起来比较简单 但是 win ...
- 用 ilasm 反编译、修改.net dll文件
有些.net dll我们没有源码,如果要修改某些东西,可以用ilasm.exe反编译为il代码,修改后再编译回dll ilasm通常放在以下路径 C:\Windows\Microsoft.NET\Fr ...
- boost_1_34_1在c++builder6编译(把所有dll文件复制到windows系统目录,所以lib文件复制到bcb6\lib目录)
boost_1_34_1.zip boost 正则表达式 bcb6编译boost_1_34 有个项目要对大量的文本信息进行分析,以前的方法是自己写函数然后进行分析.现在发现一个正则表达式的处理方法,其 ...
- QT发布 - 动态编译,删减以来dll
经常看到网上有些论调说 Qt 程序无比庞大,甚至拿 .NET 程序来比,说 Qt 程序打包以后跟 .NET 安装包差不多大.由此影响了很多人对 Qt 的选择.我觉得有必要对此做一些澄清-- 显然这个说 ...
- 编译boost库的dll和lib
下载Boost 下载链接:Boost Downloads 下载完成后,将其解压放置到需要编译保存的目录下,比如我自己的目录: F:\Work\Boost 打开VS编译 如果是使用的VS2017,则打开 ...
随机推荐
- VM虚拟机安装kali linux
点击文件,新建虚拟机新建一个虚拟机 点击后出现这个,选择典型 点击下一步,然后选择安装程序光盘映像文件(iso),然后浏览,找到你下载的镜像 点击下一步,选择linux,选择最高Debian版本的,6 ...
- 查看Linux系统资源占用
Linux查看进程占用磁盘IO yum install -y itop iotop -oP Linux查看进程网络使用 yum install -y nethogs nethogs nethogs e ...
- 27、Flask实战第27天:cms后台登录
cms后台登录界面 后台登录页面,我们不用自己写,只需要去Bootstrap中文网去找一个模板改一下就行 这里使用的模板是:https://v3.bootcss.com/examples/signin ...
- Xamarin.Forms教程下载安装Visual Studio 2015
Xamarin.Forms教程下载安装Visual Studio 2015 下载安装Visual Studio 2015 Visual Studio 2015是微软提供的IDE,其中集成了Window ...
- SD 一轮集训 day4 弦形袋鼠
可以发现把每一个 a[i] * b[i] 加到矩阵里去,就相当于 把一个 1*m 的向量伸缩后变成 n个再加到矩阵里去,所以答案就是远=原矩阵中线性线性无关组的个数. (而且好像一个矩阵横着消元和竖着 ...
- [转]java中JSONObject与JSONArray的使用详细说明及有关JSON的工具类
JSONObject与JSONArray的使用 一.JAR包简介 要使程序可以运行必须引入JSON-lib包,JSON-lib包同时依赖于以下的JAR包: 1.commons-lang.jar 2.c ...
- QPS相关的概念收集(吞吐量(TPS)、QPS、并发数、响应时间(RT))
一.概念: 1.响应时间(RT) 响应时间是指系统对请求作出响应的时间.直观上看,这个指标与人对软件性能的主观感受是非常一致的,因为它完整地记录了整个计算机系统处理请求的时间.由于一个系统通常会提供许 ...
- FIREMONEY手机虚拟键盘遮挡的解决
FIREMONEY手机虚拟键盘遮挡的解决 尝遍了网上人们提供的N种方法之后,发现还是老猫的方法才是彻底解决问题的办法. 老猫“不看后悔XXX”--->RAD10.2.3 Flying Wang ...
- 前端工业化工具Gulp初体验
1. 全局安装 gulp: npm install --global gulp 2.在项目目录下,用以下命令创建一个基本的package.json文件 npm init 3.安装Gulp npm in ...
- Unity3d-Socket之龙一编年史network.dll分析(1)
今天闲着无聊,看到群里的老大共享了反编译的工具,就下载下来玩下. 说道反编译我个人不太推崇反编译,感觉不道德,毕竟是人家的代码,但是又回想一下,我们拿代码看是抱着学习的态度又有何不可,所谓既是民族的也 ...