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,则打开 ...
随机推荐
- 最简单的Web Service实现
概述 这里提供一个最简单的Web Service的实现,基于JAX-WS.除了jdk不需要任何其他jar包,使用Eclipse提供的Web Services Explorer访问服务. 服务端的实现 ...
- Python开发基础-Day17面向对象编程介绍、类和对象
面向对象变成介绍 面向过程编程 核心是过程(流水线式思维),过程即解决问题的步骤,面向过程的设计就好比精心设计好一条流水线,考虑周全什么时候处理什么东西.主要应用在一旦完成很少修改的地方,如linux ...
- AGC 016 C - +/- Rectangle
题面在这里! 结合了贪心的构造真是妙啊2333 一开始推式子发现 权是被多少个w*h矩形覆盖到的时候 带权和 <0 ,权都是1的时候带权和 >0,也就是说被矩形覆盖的多的我们要让它尽量小. ...
- 【DFS】Paintball(6-22)
[UVA11853]Paintball 算法入门经典第6章6-22(P175) 题目大意:有一个1000*1000的正方形战场,西南角坐标(0,0),西北角坐标(0,1000),有n个敌人,每个敌人处 ...
- BZOJ 2956 模积和(分块)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2956 [题目大意] 求∑∑((n%i)*(m%j))其中1<=i<=n,1 ...
- Java并发(四):happens-before
happens-before 一个操作执行的结果需要对另一个操作可见,那么这两个操作之间必须存在happens-before关系 happen-before原则是JMM中非常重要的原则,它是判断数据是 ...
- Java高级架构师(一)第39节:Nginx的Rewrite模块
- Codeforces Round #344 (Div. 2) A. Interview 水题
A. Interview 题目连接: http://www.codeforces.com/contest/631/problem/A Description Blake is a CEO of a l ...
- opencv中SiftDescriptorExtractor所做的SIFT特征向量提取工作简单分析
SiftDescriptorExtractor对应于SIFT算法中特征向量提取的工作,通过他对关键点周围邻域内的像素分块进行梯度运算,得到128维的特征向量.具体有如下几个操作: 0.首先,我们假设在 ...
- ECSHOP中transport.js和jquery冲突的解决方法
jQuery 和global.js 冲突 百度和google多次,根据网上的大多数建议和自己测试,解决办法如下:删除global.js 或者global.js 文件的10-13行屏蔽//Object. ...