Compiling LASlib in MSVC2010 (Visual Studio 2010)

1,825 views
Skip to first unread message

Evon Silvia

unread,
Jul 9, 2013, 6:33:50 PM7/9/13
to last...@googlegroups.com
Greetings LAStools enthusiasts!

I've looked around and noticed people struggling to compile LASlib with MSVC2010, in Visual Studio 2010. I thought I'd give some detailed instructions for what I did with some help from this group's archives.

I began by opening the laslib.dsw and allowing Visual Studio 2010 to convert it to a new solution file. I then made the following changes to the LASlib source code:
  • Commented out lines 56-60 of mydefs.hpp to remove the typedef of BOOL. (might break backwards-compatibility, but I don't care).
  • Replaced all instances of BOOL with bool in all files in /src and /inc.
  • Rename or delete the "stl" directory.
Required for my build - your mileage may vary:
  • Set up the project for 64bit compile.
    • Open Build --> Configuration Manager.
    • Selecting "<New...>" under "Active solution platform", set the name of the new platform to "X64", and copy settings from Win32.
    • Close the Configuration Manager.
  • Change the Runtime Library to DLL.
    • Right-click on the LASlib project, Properties.
    • On the top, select the Debug configuration and the new x64 platform.
    • Navigate to Configuration Properties --> C/C++ --> Code Generation
    • Change Runtime Library to "Multi-threaded Debug DLL (/MDd)"
    • Now select the Release configuration and the new x64 platform.
    • Change its Runtime Library to "Multi-threaded DLL (/MD)"
    • Save all changes.
Rebuild the laslib project, ignoring the massive number of warnings. Most of these are MSVC2010 whining to coerce you into using their specialized "secure" functions. If you use those functions to make MSVC2010 happy, though, you'll eliminate cross-platform (linux) support. Other warnings are related to Martin's various conversions of variables of type int, bool, and size_t. I opted not to go through and correct these since it was a hassle and might have unforeseen consequences if I wasn't paying attention.

Note that I have not built the example, the laszippertest, or the laszip projects. The laszip project failed to convert at all, but as far as I can tell, that code is included with LASlib anyway.

When connecting to LASlib in your project, simply add the new LASlib.lib libraries from the "lib" (release) and "libD" (debug) folders to your project and #include the appropriate headers in the "inc" directory. I did this in Qt Creator for my 64bit Qt-based project.

I've successfully read LAZ files using this new library. I haven't noticed any issues after the conversion to a 64bit library, but that doesn't mean there aren't any, especially given Martin's fancy bit twiddling.

I'm no software expert, but that's how I did it. Everything was done using the March 15, 2013 download of LASlib.

Good luck!

Evon
--
Evon Silvia  Geomatics Engineer


WSI Corvallis, OR WSI Portland, OR WSI Oakland, CA
517 SW 2nd St., Suite 400, Corvallis, OR 97333

Clarence Robas

unread,
Sep 9, 2014, 6:11:44 AM9/9/14
to last...@googlegroups.com, esi...@watershedsciences.com
I tried this on Microsoft Visual Studio 2013 and it worked. Thank you very much for this set of instructions. Now I can continue on my small-scale LiDAR project. (I used the latest LASlib. If I remember it right, I downloaded it last August.)

Evon Silvia

unread,
Sep 9, 2014, 2:16:23 PM9/9/14
to Clarence Robas, last...@googlegroups.com
Great! Glad to hear that this still works in VS2013, too. Here are a few more notes I made for myself since the initial post that others might find useful:

Disable benign warnings to make finding errors easier:
  • Go to Project Properties
  • Configuration Properties > C/C++ > Advanced > Disable Specific Warnings
  • Add 4800, 4996, 4267, 4244
  • Repeat for Release and Debug builds.
Also change the copy target for the lib files:
  • Go to Project Properties
  • Configuration Properties > Build Events > Post-Build Event
  • Change command line to the lib64 directory instead of lib
  • Create the lastools\LASlib\lib64 directory
  • Repeat for both Debug and Release, except for debug change the filename to LASlibD.lib.
Finally, add an extra line to the post-build steps to also copy the vc100.pdb debug objects. To do this, you must have separate lib directories for debug and release: in my case, lib64 and lib64D.

Evon
--
Evon Silvia PLS
Geomatics Specialist

Quantum Spatial
517 SW 2nd Street, Suite 400, Corvallis, OR 97333

Evon Silvia

unread,
Feb 26, 2016, 12:42:37 PM2/26/16
to Oscar Duran, LAStools - efficient tools for LiDAR processing
It's written for libcurl, but the principles are the same.

Also, make sure you follow the instructions in the comments for copying the DLL. Use DependencyWalker (http://dependencywalker.com/) to verify that you've put them in the correct location.

Evon

On Thu, Feb 25, 2016 at 10:00 AM, Oscar Duran <oedu...@gmail.com> wrote:
Hi Evon,

Thanks for your post. I have been looking for a guide like this on how to compile the library.

I in the step where you talk about connecting to the LASlib in the project. I am not sure how to add the new libraries to my project. Would you be able to help me with that?

Thank you.

Oscar D.

a.cottin

unread,
Mar 5, 2016, 6:50:01 PM3/5/16
to LAStools - efficient tools for LiDAR processing, oedu...@gmail.com
Hi Evon, Hi Group,

Thanks for the information, as it was useful to get the project compiling in Visual Studio 2015.

I wanted to add that I had to add the following define statement in lasinterval.hpp (line 55) line and lasindex.hpp (line 59) :

#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS

as the hash_table throw errors during compilation.

Note that I was only interested in building LASLib.lib and therefore not sure if this solve the problem for the whole solution.

Cheers.
Antoine
Reply all
Reply to author
Forward
0 new messages