LASlib:Win10 + VS2017 编译LASlib
一、下载解压
下载地址 http://lastools.github.io/download/LAStools.zip
解压地址 G:/LAStools/
二、编译
2.1 打开
用VS2017打开lastools.dsw。历史原因,一直点确定就可以。
2.2 移除失败的项目
2.3 修改代码
打开LASlib的头文件mydefs.hpp,定位到69行,只保留 #if defined(_MSC_VER),删除或注释改行其它代码。
2.4 注
Win 10系统需要,右键LASlib—属性—配置属性—常规—Windows SDK 版本—选择合适的。
否则可能出现错误:找不到Windows SDK 版本8.1。请安装所需的版本的Windows SDK或者在项目属性页中或通过右键单击解决方案并选择”重定解决方案目标”来更改SDK版本。
2.5 修改输出目录
右键LASlib—属性—配置属性—常规—输出目录—修改为“$(SolutionDir)$(ProjectName)\$(Configuration)\”。
2.6 修改头文件目录
右键LASlib—配置属性—C/C++—常规—附加包含目录—删除“...\laszip\stl”
2.7 修改运行库
右键LASlib—属性—C/C++—代码生成—运行库—笔者选择“多线程DLL(/MD)”。(默认应该是多线程/MT)
2.8 生成lib
右键LASlib—重新生成。结果在 G:/LAStools/LASlib/Release/LASlib.lib
三、测试
3.1 新建工程
(1)配置属性—常规—Windows SDK版本,与前者保持一致。
(2)配置属性—C/C++—代码生成—运行库,(默认)选择多选程DLL(/MD),与前者保持一致。
3.2 头文件目录
配置属性—C/C++—常规——附加包含目录,添加 G:\LAStools\LASlib\inc 和 G:\LAStools\LASzip\src
3.3 静态库
配置属性—链接器—输入——添加 G:\LAStools\LASlib\Release\LASlib.lib
3.4 测试代码
-
#include "lasreader.hpp"
-
#include "laswriter.hpp"
-
-
/* 将las文件转换为laz文件 */
-
void MDtestLASlib::on_pushButton_clicked()
-
{
-
LASreadOpener lasreadopener;
-
lasreadopener.set_file_name(
"G:/a1.las");
-
LASreader* lasreader = lasreadopener.open();
-
-
LASwriteOpener laswriteopener;
-
laswriteopener.set_file_name(
"G:/b2.laz");
-
LASwriter* laswriter = laswriteopener.open(&lasreader->header);
-
-
while (lasreader->read_point())
-
laswriter->write_point(&lasreader->point);
-
-
laswriter->close();
-
delete laswriter;
-
-
lasreader->close();
-
delete lasreader;
-
}
3.5 验证结果
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true"> <use xlink:href="#csdnc-thumbsup"></use> </svg><span class="name">点赞</span> <span class="count"></span> </a></li> <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true"> <use xlink:href="#icon-csdnc-Collection-G"></use> </svg><span class="name">收藏</span></a></li> <li class="tool-item tool-active is-share"><a href="javascript:;" data-report-click="{"mod":"1582594662_002"}"><svg class="icon" aria-hidden="true"> <use xlink:href="#icon-csdnc-fenxiang"></use> </svg>分享</a></li> <!--打赏开始--> <!--打赏结束--> <li class="tool-item tool-more"> <a> <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg> </a> <ul class="more-box"> <li class="item"><a class="article-report">文章举报</a></li> </ul> </li> </ul> </div> </div> <div class="person-messagebox"> <div class="left-message"><a href="https://blog.csdn.net/xinjiang666"> <img src="https://profile.csdnimg.cn/D/A/5/3_xinjiang666" class="avatar_pic" username="xinjiang666"> <img src="https://g.csdnimg.cn/static/user-reg-year/1x/4.png" class="user-years"> </a></div> <div class="middle-message"> <div class="title"><span class="tit"><a href="https://blog.csdn.net/xinjiang666" data-report-click="{"mod":"popu_379"}" target="_blank">累了就要打游戏</a></span> </div> <div class="text"><span>发布了60 篇原创文章</span> · <span>获赞 49</span> · <span>访问量 7万+</span></div> </div> <div class="right-message"> <a href="https://im.csdn.net/im/main.html?userName=xinjiang666" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信 </a> <a class="btn btn-sm attented bt-button personal-watch" data-report-click="{"mod":"popu_379"}">已关注</a> </div> </div> </div> </article>