// liblas
#include <liblas/liblas.hpp>
#include <liblas/laspoint.hpp>
#include <liblas/lasreader.hpp>
#include <liblas/cstdint.hpp>
#include <fstream>
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
std::ifstream ifs;
ifs.open( "c:\\temp\\input.las", std::ios::in | std::ios::binary);
liblas::LASReader reader(ifs);
}
The source code is simple enough and the syntax is correct. After some research I found out that the liblas.lib file I was linking was a released (non-debug) version while I was compiling a debug version of my C++ executable. Due to licensing issues, libLAS can only be distributed in released version. If you want to compile a debug executable, then you have to download the liblas source code and compile your own debug liblas.lib. Otherwise, you can only build release copies of your executable.
Monday, March 7, 2011
Tip for developing a liblas C++ program with Microsoft Visual Studio 2008
Recently I tried to write a C++ program for reading a LiDAR LAS file using Microsoft Visual Studio and the open source library liblas. I followed the sample tutorial from the liblas.org web site. The simple code below simply opens up a LAS file and creates a LASReader class. Compiling the simple code is okay but when I ran it, the program crashed when trying to create the LASReader class. What was the problem?
Hi,
ReplyDeletecan I ask you how to get the liblas.lab? I build the liblas in visual studion 2010 but there's no .lib file?
In addition, how you cen set new project to link to liblas?
Thank you. I am a newbie in this.
Stephie
ReplyDeleteYou can download the latest liblas.lib for Windows using the OSGeo4W installer from http://www.liblas.org/download.html.
I have not tried VS2010 but there should be some project settings there to add in the liblas include header files and library directories, e.g. [OSGeo4W]\include\liblas and [OSgeo4W]\lib
Very interesting and informative post! This information is really helpful for us. Thanks for sharing.
ReplyDeletemicrosoft visual studio 2010