Skip to Content.
Sympa Menu

cgal-discuss - HOWTO setup Visual Studio 2005 (v.8) to use CGAL

Subject: CGAL users discussion list

List archive

HOWTO setup Visual Studio 2005 (v.8) to use CGAL


Chronological Thread 
  • From: Keith Ealanta <>
  • To:
  • Subject: HOWTO setup Visual Studio 2005 (v.8) to use CGAL
  • Date: Sat, 09 Dec 2006 18:14:23 +1100

Oh, bad form, replying to my own email.
Still, here is my first draft on how to get to the point of one of the examples compiling.
Please feel free to correct any mistakes or omissions, and to post it on as and where needed for other users.

------------------------------------------------------------------------
Setting up CGAL for Visual Studio 2005

Be warned: This is not written by an expert. It is merely a summary of my experiences of getting to the point of getting one of the examples to compile.

For reference I'm running on Windows XP pro on a Dell inspiron 8600 laptop.
My personal goal is to use CGAL to provide boolean operations on polygons for an application I'm developing.
I'm developing in vb.net with CGAL being bound in through a C++ class library. I make no claim that this is efficient. I'm doing it becaue I like the ability to protype code under vb (particularly graphical interfaces). In time I hope to convert the vb side to Qt based C++.

Anyway, onto the setup.

Firstly we need to install CGAL. This is mostly straight forward. Don't worry about the warnings about being unable to find the msvc7 config file. We'll perform these changes manually.
Reboot your computer to pickup the value for $(CGALROOT)

I'm assuming you have installled Boost already. If not get it from boost.org and install it.

Now, With CGAL and Boost installed, open Visual Studio 2005.
From the menu select Tools|Options to open the Visual Studio Options Dialog
In the dialog, select Projects and Solutions|VC++ Directories
Select to show directories for Include Files.
Add the following entries...

$(CGALROOT)\include\CGAL\config\msvc7
$(CGALROOT)\include
$(CGALROOT)\auxiliary\gmp\include
$(CGALROOT)\auxiliary\taucs\include
$(CGALROOT)\auxiliary\zlib\include

and also add this if boost isn't already in your include paths.

c:\Program Files\Libraries\boost_1_33_1

Now select to show directories for Library Files
and add these entries

$(CGALROOT)\lib
$(CGALROOT)\auxiliary\gmp\lib
$(CGALROOT)\auxiliary\taucs\lib
$(CGALROOT)\auxiliary\zlib\lib

Now we are ready to recompile the libraries
1. Create an new blank solution in the folder C:\Program Files\Libraries\CGAL-3.2.1\src
(By the way, correct all the paths you see here match yours. I'm installing all my libraries into a folder c:/Program Files/Libraries, so they may well not be same as you use.)

2. Add to it two projects. CGAL and Core (As I said above, no Qt till we can have Qt4)
C:\Program Files\Libraries\CGAL-3.2.1\src\CGAL\cgallib.vcproj
C:\Program Files\Libraries\CGAL-3.2.1\src\core\Core.vcproj

As you add these they will need to be updated to VS2005. All the default settings worked for me.

3. Now time to set up the builds.
We are going to set up 2 different versions of each library, a debug and a release version.
Firstly lets set the build targets.
Select cgalib
From project properties, select Librarian and change output file to
../../lib/msvc8_debug/CGAL.lib for Configuration = Debug and
../../lib/msvc8_release/CGAL.lib for Configuration = Release
While we're here, in Configuration = Debug goto "C/C++ | Code Generation" and change Runtime Library to Multi-threaded Debug DLL (/MDd)
Now to "C/C++ | Preprocessor" Add ;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0 to Preprocessor Definitions for both Debug and Release
Close project properties and select core
From project properties, select Librarian and change output file to
../../lib/msvc8_debug/core++.lib for Configuration = Debug and
../../lib/msvc8_release/core++.lib for Configuration = Release
While we're here, in Configuration = Debug goto "C/C++ | Code Generation" and change Runtime Library to Multi-threaded Debug DLL (/MDd)
Now to "C/C++ | Preprocessor" Add ;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0 to Preprocessor Definitions for both Debug and Release

Now unless I've missed something the libraries should be ready to build.
Select Build | Batch Build. Select all four projects and tell it to build.

Now we are finally ready to build one of the examples.
I'm going to go for Nef_2 (well I did ssay I was looking for boolean operations)

Go to C:\Program Files\Libraries\CGAL-3.2.1\examples\Nef_2
Open simple_intersection.vcproj
It will convert it to 2005

Under project properties set the following...
change msvc7 in Linker|General|Additional Library Directories to msvc8_debug for debug and msvc8_release for release
In "C/C++ | Preprocessor" Add ;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0 to Preprocessor Definitions for both Debug and Release
Finally for Configuration = Debug goto "C/C++ | Code Generation" and change Runtime Library to Multi-threaded Debug DLL (/MDd)

Now you are ready to build and test the app.
For me this worked correctly. If it doesn't for you, I suggest posting to the mailing list with questions and modifying these instructions to fill in any blanks.

Thanks to all the folks behind these libraries

Keith Ealanta
-----------------------------------------------------------------------

Keith Ealanta wrote:
Bingo!.

Well done. That fixed it immediately.
It looks like I'm ready to start developing.
I'm going to write a brief howto for vs2005 to help others get to this point. I'll post it here so others can correct my errors.

Thankyou all.

Keith

Hongbo Fu wrote:
Wrong setting of runtime library (under projection properties | C/C++
| Code Generation) often leads to such errors.
You can check if multi-threaded debug dll (/MDd) is used for the debug mode.

On 12/8/06, Keith Ealanta
<>
wrote:
Andreas Fabri wrote:
>

wrote:
>> Can anyone give me any advice on how to set-up Visual Studio 2005 to
>> use CGAL.
>> I'm sure if I can hack at it for a while I can get it to happen, but
>> hopefully someone out-there has already done this and can make it easy
>> for me.
>>
>> Ideally, can someone post a nice zipped up minimal project that
>> compiles VS8?
>>
>> Yours hopefully,
>>
>> Keith Ealanta
>>
>>
>
>
> For VC++ you should install CGAL with the selfextracting archive and not
> use the tar.gz
>
> The cgal.lib is precompiled with VC7. In order to recompile go in
> the directoy CGAL-3.2./src/CGAL, open the vcprof file and click
> on rebuild. The same for Core, and CGALQt, if you need them (and
> have Qt 3 for Windows).
>
> In the examples and demo directory, you find the .vcproj files.
> That is clicking on it and clicking on build solution, should do it.
>
> There is one thing that needs attention for VC8. Visual 8 now comes
> with the
> Dinkumware STL implementation. You currently have to disable two
> checking features
> of this STL In the IDE go to Project-> ...
> properties->C/C++->Preprocessor and
> add _SECURE_SCL=0 _HAS_ITERATOR_DEBUGGING=0 to "Preprocessor Definitions".
>
> The first define avoids warnings, the second one assertions at runtime.
> Whereas the first one concerns a non portable "improvement" of the STL
> which makes it less "S" (which after all stands for Standard), we work
> on the second one.
>
> best regards,
>
> andreas
>
Thanks heaps for this.
Once I'm all done I might try to throw together a quick howto you could
put up somewhere.

One issue I'm having. I built the libraries (release and debug versions)
When I compile a debug version of one of the examples I get the linker
warning... (in this case I was building the Nef_2 Simple_Intersection
example)

simple_intersection.obj : error LNK2019: unresolved external symbol
__imp___CrtDbgReportW referenced in function "public: class
std::list<class CGAL::Extended_segment<class CGAL::Gmpz>,class
std::allocator<class CGAL::Extended_segment<class CGAL::Gmpz> >
>::_Const_iterator<1> & __thiscall std::list<class
CGAL::Extended_segment<class CGAL::Gmpz>,class std::allocator<class
CGAL::Extended_segment<class CGAL::Gmpz> >
>::_Const_iterator<1>::operator--(void)"
(??F?$_Const_iterator@$00@?$list@V?$Extended_segment@VGmpz@CGAL@@@CGAL@@V?$allocator@V?$Extended_segment@VGmpz@CGAL@@@CGAL@@@std@@@std@@QAEAAV012@XZ)


I don't get this when I build in release, but of course that rather
limits my debugging. Am I just doing something dumb or is there some
other detail I've missed?

Again, many thanks,

Keith Ealanta









Archive powered by MHonArc 2.6.16.

Top of Page