I would like to use CGAL from Code Blocks. I am using Ubuntu 12.04.
I have installed CGAL packages. Now how could I create a CGAL project.
Any help shall be greatly appreciated.
Printable View
I would like to use CGAL from Code Blocks. I am using Ubuntu 12.04.
I have installed CGAL packages. Now how could I create a CGAL project.
Any help shall be greatly appreciated.
>I have installed CGAL packages.
Make sure you've installed the development packages too.
After that it is a matter of including the correct headers and telling your compiler (or rather linker) to link against the installed libraries.
In codeblocks, that is done by putting the library package name in miscellaneous linker settings.
Note that this applies to most development libraries in general.
Thanks. But how shall I browse and add the library in CodeBlocks.
I am confused about the path, name etc.
Ideally, (i.e ..you've installed everything from the package manager or manually used ldconfig correctly), you don't worry about the path....as it'd be in one of the default paths, like ("/lib","/usr/lib","/usr/local/lib")..etc.
For the name:
If the library file is named "libXYZ.so" or "libXYZ.a", the linker flag to gcc will look like "-lXYZ". (ell, not i).
Thanks. I shall try! :)
I am trying with the following code.
From Ubuntu I got the following from terminal.Code:#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point_2;
int main()
{
Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5), Point_2(4,1) };
Point_2 result[5];
Point_2 *ptr = CGAL::convex_hull_2( points, points+5, result );
std::cout << ptr - result << " points on the convex hull" << std::endl;
return 0;
}
In the linker section in code blocks I have tried using '-lcgal8' and also '-lCGAL8'.Code:anirban@anirban-Studio-1555:~$ sudo dpkg -L libCGAL8
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libcgal8
/usr/share/doc/libcgal8/copyright
/usr/share/doc/libcgal8/changelog.Debian.gz
/usr/share/doc/libcgal8/README.Debian
/usr/lib
/usr/lib/libCGAL.so.8.0.0
/usr/lib/libCGAL_ImageIO.so.8.0.0
/usr/lib/libCGAL_Qt4.so.8.0.0
/usr/lib/libCGAL_Core.so.8.0.0
/usr/lib/libCGAL_Qt4.so.8
/usr/lib/libCGAL.so.8
/usr/lib/libCGAL_Core.so.8
/usr/lib/libCGAL_ImageIO.so.8
In both cases, I get following message.
ButCode:ld cannot find -lcgal8
works, and I get the following messages.Code:-lCGAL
Code:obj/Debug/main.o||In function `Gmpq_rep':|
/usr/include/CGAL/GMP/Gmpq_type.h|50|undefined reference to `__gmpq_init'|
obj/Debug/main.o||In function `~Gmpq_rep':|
/usr/include/CGAL/GMP/Gmpq_type.h|51|undefined reference to `__gmpq_clear'|
obj/Debug/main.o||In function `Gmpq':|
/usr/include/CGAL/GMP/Gmpq_type.h|132|undefined reference to `__gmpq_set_d'|
obj/Debug/main.o||In function `CGAL::Gmpq::operator==(CGAL::Gmpq const&) const':|
/usr/include/CGAL/GMP/Gmpq_type.h|193|undefined reference to `__gmpq_equal'|
obj/Debug/main.o||In function `CGAL::Gmpq::operator<(CGAL::Gmpq const&) const':|
/usr/include/CGAL/GMP/Gmpq_type.h|194|undefined reference to `__gmpq_cmp'|
obj/Debug/main.o||In function `CGAL::Gmpq::operator-=(CGAL::Gmpq const&)':|
/usr/include/CGAL/GMP/Gmpq_type.h|286|undefined reference to `__gmpq_sub'|
obj/Debug/main.o||In function `CGAL::Gmpq::operator*=(CGAL::Gmpq const&)':|
/usr/include/CGAL/GMP/Gmpq_type.h|296|undefined reference to `__gmpq_mul'|
||=== Build finished: 7 errors, 0 warnings (0 minutes, 4 seconds) ===|
Try "-lCGAL".
Yes you are right.
I wish if you could help exactly on the linking. :(
Thanks though for helping so much.
Finally it seems to work from Code Blocks. We need to include the following flags.
Code:-lCGAL -lgmp -frounding-math