Like Tree1Likes
  • 1 Post By manasij7479

CGAL in Ubuntu 12.04

This is a discussion on CGAL in Ubuntu 12.04 within the Tech Board forums, part of the Community Boards category; I would like to use CGAL from Code Blocks. I am using Ubuntu 12.04. I have installed CGAL packages. Now ...

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278

    CGAL in Ubuntu 12.04

    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.

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    >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.
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Thanks. But how shall I browse and add the library in CodeBlocks.
    I am confused about the path, name etc.

  4. #4
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    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).
    anirban likes this.
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  5. #5
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Thanks. I shall try!

  6. #6
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    I am trying with the following code.

    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;
    }
    From Ubuntu I got the following from terminal.

    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 the linker section in code blocks I have tried using '-lcgal8' and also '-lCGAL8'.
    In both cases, I get following message.

    Code:
    ld  cannot find -lcgal8
    But
    Code:
    -lCGAL
    works, and I get the following messages.

    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) ===|

  7. #7
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    Try "-lCGAL".
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  8. #8
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Quote Originally Posted by manasij7479 View Post
    Try "-lCGAL".
    Well, that is what I have tried and I got the above coded error messages.

  9. #9
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    Quote Originally Posted by anirban View Post
    Well, that is what I have tried and I got the above coded error messages.
    Sorry.. didn't see the final part of your post.
    It appears that you should link some more libraries, probably gmp, from the linker messages .
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  10. #10
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Yes you are right.
    I wish if you could help exactly on the linking.
    Thanks though for helping so much.

  11. #11
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Finally it seems to work from Code Blocks. We need to include the following flags.

    Code:
    -lCGAL -lgmp -frounding-math

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Something other than Ubuntu
    By Annonymous in forum Tech Board
    Replies: 16
    Last Post: 10-24-2011, 07:07 PM
  2. Ubuntu
    By GReaper in forum Tech Board
    Replies: 8
    Last Post: 09-06-2010, 11:46 PM
  3. 32 bit to 64 bit Ubuntu
    By Akkernight in forum Tech Board
    Replies: 15
    Last Post: 11-17-2008, 03:14 AM
  4. Ubuntu fan noise
    By Stonehambey in forum Tech Board
    Replies: 10
    Last Post: 09-06-2008, 01:28 PM
  5. CGAL question
    By disruptivetech in forum C++ Programming
    Replies: 0
    Last Post: 04-28-2008, 12:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21