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,则打开 ...
随机推荐
- 如何去除windows下文本的^M
使用vi编辑,输入命令: :%s/^M/\r/g 用来把^M换成回车 注意的是^M要使用CTRL-V CTRL-M生成,而不是直接键入^M
- getResourceAsStream 地址
getResourceAsStream ()返回的是inputstream getResource()返回:URL Class.getResource("") 返回的是当前C ...
- python 打包详解
基本步骤: 1. 写setup.py 2. 运行“python setup.py sdist” 3. 在当前目录下会生成文件夹“dist”,打包好的代码就在dist中,以“.tar.gz”的形式被压缩 ...
- 计算机基础-day2
为何要有操作系统? 首先要说明一下操作系统是什么? 操作系统是协调.管理.控制计算机硬件和为应用程序提供接口的控制软件,操作系统向下连接硬件,向上承载应用程序. 由于硬件不论种类还是工作流程都是繁杂的 ...
- (转)求质数算法的N种境界[1] - 试除法和初级筛法
★引子 前天,俺在<俺的招聘经验[4]:通过笔试答题能看出啥?>一文,以"求质数"作为例子,介绍了一些考察应聘者的经验.由于本文没有政治敏感内容,顺便就转贴到俺在CSD ...
- NOIP2005 day1 t1 谁拿了最多奖学金
题目描述 某校的惯例是在每学期的期末考试之后发放奖学金.发放的奖学金共有五种,获取的条件各自不同: 1) 院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1 ...
- [Contest20170910]string
给定一个由且仅由字符$'H','T'$构成的字符串$S$ 给定一个最初为空的字符串$T$,每次随机地在$T$的末尾添加$'H'$或者$'T'$ 问当$S$为$T$的后缀时,在末尾添加字符的期望次数 妙 ...
- [转]提示错误 package javax.servlet.jsp does not exist package javax.servletr.jsp.tagext does not exist
你在JAVA servlet容器运行的时候没配置servlet-api.jar,tools.jar,rt.jar,jsp-api.jar的classpath 我的classpath= .;%JAVA_ ...
- Codeforces Round #114 (Div. 1) D. Wizards and Roads 笛卡尔树+树贪心+阅读题
D. Wizards and Roads 题目连接: http://www.codeforces.com/contest/167/problem/D Description In some count ...
- python 实现简单的KNN算法
from numpy import * import operator def createDataSet(): group = array([[3,104],[2,100],[1,81],[101, ...