Re: CGAL & Ruby

211 views
Skip to first unread message

Sebastien Loriot (GeometryFactory)

unread,
Jun 1, 2012, 4:49:58 AM6/1/12
to cgal-bindi...@googlegroups.com, noel...@gmail.com
On 06/01/2012 10:37 AM, Noel Warren wrote:
> Well, I decided to go off and try Rice. Please bare in mind that I am
> not a professional programmer and I guess the bindings project scared me
> off (all that Cmake is intimidating!). What I have developed so far is
> here http://code.google.com/p/rgal/ . But I still feel the project
> should work alongside the bindings project. I see Patrick Surry is
> working on Nefs. If he were to get it up and running I'd be willing to
> make a serious effort at porting it all to Ruby (Remember, no Cmake
> experience and limmited c++ know-how).
>
To me it's a bad to restart another project from scratch (for
maintenance purpose essentially). But I fully understand that you want
something that works and you have limited time.

> How would I get started? The python folder seems to only worry about
> iterators. How many Cmake files would I have to edit? Think others
> might need it?
>
The first step is just to write a macro so that you can compile in Ruby.
If you look at the file cmake/Modules/SWIG_CGAL_Macros.cmake, I think
you just need to copy-paste ADD_SWIG_CGAL_PYTHON_MODULE and create
ADD_SWIG_CGAL_RUBY_MODULE.

Then in the main CMakeLists.txt
you must add
option( BUILD_RUBY "Build Ruby bindings" ON )
and copy-paste-adapt the two blocks
if (${BUILD_PYTHON})
....
endif()

and

if (PYTHONLIBS_FOUND)
...
endif()

Then open SWIG_CGAL/Kernel/CMakeLists.txt and add the line for Ruby.

I think that's it. You need special code for iterators if you want to
make an advance use.

Sebastien

> 2012/5/18 Sebastien Loriot (GeometryFactory) <slori...@gmail.com
> <mailto:slori...@gmail.com>>
>
> Hi,
>
> you should try to use the CGAL bindings.
> The first step is to modify the cmake script (CMakeLists.txt)
> to make swig generating ruby files.
>
> IIRC, on the SWIG website you'll have information about how to
> compile using SWIG for Ruby,
>
> Please use the list
> http://groups.google.com/__group/cgal-bindings-discuss
> <http://groups.google.com/group/cgal-bindings-discuss>
> if you have any question.
>
> Best regards,
>
> Sebastien.
>
>
>
> On 05/15/2012 04:26 PM, Noel Warren wrote:
>
> Hi there Sebastien
> My name is Noel and am subscribed to the CGAL mailing list. I am
> interested in porting (wrapping, binding or whatever you call
> it) CGAL
> so I can use it in Ruby. I was planning to do it with Rice
> <http://rice.rubyforge.org/>, mainly because it looks really
> easy. I've
>
> even booked https://code.google.com/p/__rgal/
> <https://code.google.com/p/rgal/>. I sent an email about this
> to Philipp Moller to make sure I wasn't setting myself up for a fall
> (I'm not exactly a c++ expert) and told me about you the
> cgal-bindings
> project.
>
> It would seem you have much or most of the work done for me(I
> need to
> use polyhera, nefs, planes, minkowski summs and perhaps envelopes).
> Reading the rice documentation however, it all seems a lot
> safer and
> idiot proof. Because I have never wrapped classes before I was
> hoping
> you could give me some advice. Would you recommend using
> cgal-bindings
> or using Rice to wrap my ruby classes.
>
> If I were to use Rice, I was thinking of changing my classes
> a little
> to make them a bit more ruby like. For instance I don't really
> see a
> need for an Polyhedron_incremental_builder class when you could just
> incorporate it into one of the Polyhedon's methods...
>
> P = Polyhedron.build___incrementally(pointArray, faceArray)
>
> I also find wierd that fact that Polyhedra are constants.
> You can
> modify them. Surely they should be variables. The fact I don't
> understand why makes me think I probably just don't understand C++
>
> Anyway, please let me know if i'm out of my depth or if I've said
> something really stupid. Cheers!
>
>
>

Noel Warren

unread,
Jun 1, 2012, 5:19:26 AM6/1/12
to cgal-bindi...@googlegroups.com
Well that was frustratingly simple.  Serves me right for not having asked "How do I get started?".  How many hours did I spend on Rice?  So, the whole thing compiled well and created 7 .so files in the lib directory.  When I try to require them from the ruby console I get an undefined symbol error

require 'libCGAL_Kernel_cpp.so'
LoadError: ./libCGAL_Kernel_cpp.so: undefined symbol: Init_libCGAL_Kernel_cpp - ./libCGAL_Kernel_cpp.so
from ./libCGAL_Kernel_cpp.so
from (irb):2
from :0

With rice I got this error when the name of my external c function didn't match the name of my cpp file perfectly.  Doubt that is the case here.  Any ideas?

2012/6/1 Sebastien Loriot (GeometryFactory) <slori...@gmail.com>

Noel Warren

unread,
Jun 1, 2012, 5:47:57 AM6/1/12
to cgal-bindi...@googlegroups.com
Ignore previous email.  Ruby not found by Cmake.  Time for a little investigating!

2012/6/1 Noel Warren <noel...@gmail.com>
Message has been deleted
Message has been deleted
Message has been deleted

Noel Warren

unread,
Jun 1, 2012, 6:43:00 AM6/1/12
to cgal-bindi...@googlegroups.com
OK...  here is some interesting stuff.  Upon running Cmake I get a million warnings about gmp and an interesting name conflict (I think)...

CMake Warning at cmake/Modules/SWIG_CGAL_Macros.cmake:17 (add_library):
  Cannot generate a safe linker search path for target CGAL_Kernel_cpp
  because files in some directories may conflict with libraries in implicit
  directories:

    link library [libgmp.so] in /usr/lib may be hidden by files in:
      /usr/local/lib

What's even more interesting is the fact my make fails because of some python stuff even though I have python set to off

[ 76%] Swig source
Unable to open file /CGAL/CGAL_Kernel.py: Permission denied
make[2]: *** [SWIG_CGAL/Kernel/CGAL_KernelPYTHON_wrap.cxx] Error 1
make[1]: *** [SWIG_CGAL/Kernel/CMakeFiles/_CGAL_Kernel.dir/all] Error 2
make: *** [all] Error 2

Sebastien Loriot (GeometryFactory)

unread,
Jun 1, 2012, 6:56:52 AM6/1/12
to cgal-bindi...@googlegroups.com
On 06/01/2012 12:43 PM, Noel Warren wrote:
> OK... here is some interesting stuff. Upon running Cmake I get a million
> warnings about gmp and an interesting name conflict (I think)...
>
> CMake Warning at cmake/Modules/SWIG_CGAL_Macros.cmake:17 (add_library):
> Cannot generate a safe linker search path for target CGAL_Kernel_cpp
> because files in some directories may conflict with libraries in implicit
> directories:
>
> link library [libgmp.so] in /usr/lib may be hidden by files in:
> /usr/local/lib
>
> What's even more interesting is the fact my make fails because of some
> python stuff even though I have python set to off
>
Did you let some python stuff during copy-paste stage?

Sebastien.

Noel Warren

unread,
Jun 1, 2012, 6:57:40 AM6/1/12
to cgal-bindi...@googlegroups.com
Back to where I started.  Everthing is compiling fine (Only warnings about gmp possibly not being found) but when I require a .so file...

LoadError: ./lib/libCGAL_Triangulation_3_cpp.so: undefined symbol: Init_libCGAL_Triangulation_3_cpp - ./lib/libCGAL_Triangulation_3_cpp.so
from ./lib/libCGAL_Triangulation_3_cpp.so

Someone?

Noel Warren

unread,
Jun 1, 2012, 7:00:27 AM6/1/12
to cgal-bindi...@googlegroups.com
Nope.  The error with the python file had to do with permissions.  "sudo make" did the trick.  I still don't understand why it needed a python file though.  Oh well.

Patrick Surry

unread,
Jun 1, 2012, 7:06:43 AM6/1/12
to cgal-bindi...@googlegroups.com
You didn't give a lot of context for where the error message is coming from - is that during the build process?

How is your CGAL installation set up, maybe the base CGAL libraries are not on your LD_LIBRARY_PATH (or whatever equivalent on your system)?

Cheers,
Patrick

Noel Warren

unread,
Jun 1, 2012, 7:32:03 AM6/1/12
to cgal-bindi...@googlegroups.com
OK...
Here is what I've done
in SWIG_CGAL_Macros.cmake I have added the following

MACRO(ADD_SWIG_CGAL_RUBY_MODULE packagename)
  SET (MODULENAME "CGAL_${packagename}")
  SET (INTERFACE_FILES  "CGAL_${packagename}.i")
  
  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
  INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../include)

  #recover cpp files to be compiled
  EXTRACT_CPP_AND_LIB_FILES(${ARGN})

  SET_SOURCE_FILES_PROPERTIES(${INTERFACE_FILES} PROPERTIES CPLUSPLUS ON)

  #Build bindings for ruby
  if(RUBY_FOUND)
    INCLUDE_DIRECTORIES(${RUBY_INCLUDE_PATH})
    SET (CMAKE_SWIG_OUTDIR "${RUBY_OUTDIR_PREFIX}/CGAL")
    SET(CMAKE_SWIG_FLAGS  -DSWIG_CGAL_${packagename}_MODULE)
    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${RUBY_OUTDIR_PREFIX}/CGAL")
    SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${RUBY_OUTDIR_PREFIX}/CGAL")
    SET(CMAKE_MODULE_OUTPUT_DIRECTORY "${RUBY_OUTDIR_PREFIX}/CGAL")
    SWIG_ADD_MODULE(${MODULENAME} python ${INTERFACE_FILES} ${object_files})
    SWIG_LINK_LIBRARIES(${MODULENAME} ${libstolinkwith} ${RUBY_LIBRARY})
  endif()
ENDMACRO(ADD_SWIG_CGAL_RUBY_MODULE)

Then in the main CMakeLists.txt I add 

option( BUILD_RUBY "Build Ruby bindings" ON )

and also

if (${BUILD_RUBY})
      FIND_PACKAGE(Ruby)
      if (NOT RUBY_FOUND)  
        message(WARNING "Ruby has not been found, CGAL-bindings for Ruby will not be generated.")
      endif()
    else()  
      message(STATUS "BUILD_RUBY is set to OFF: no CGAL-bindings for Ruby will be generated.")
    endif()

Last but not least SWIG_CGAL/Kernel/CMakeLists.txt

ADD_SWIG_CGAL_RUBY_MODULE(Kernel CGAL_Kernel_cpp)

then cmake .
then sudo make
then make

To test, I just start the interactive console and require 'lib/libCGAL_Kernel_cpp.so' which fails because of some symbol error.

Where I am at the moment:  I have removed gmp from /usr/local/lib to stop it interfering with the copy in /usr/lib.  My CMake now runs smoothly but compilation fails.  Again requiring something to do with python.  Wierd.  Here is the output...

noel@vistii1:~/git/cgal-bindings$ cmake .
-- Build type: Release
-- USING CXXFLAGS = ' -frounding-math -O3 -DNDEBUG'
-- USING EXEFLAGS = '  '
-- Targetting Unix Makefiles
-- Using /usr/bin/c++ compiler.
-- Release mode with g++: using -fno-strict-aliasing flags
-- BUILD_PYTHON is set to OFF: no CGAL-bindings for Python will be generated.
-- BUILD_JAVA is set to OFF: no CGAL-bindings for Java will be generated.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/noel/git/cgal-bindings
noel@vistii1:~/git/cgal-bindings$ sudo make
[sudo] password for noel: 
[ 73%] Built target CGAL_Kernel_cpp
[ 76%] Building CXX object SWIG_CGAL/Kernel/CMakeFiles/_CGAL_Kernel.dir/CGAL_KernelPYTHON_wrap.cxx.o
/home/noel/git/cgal-bindings/SWIG_CGAL/Kernel/CGAL_KernelPYTHON_wrap.cxx:149:20: fatal error: Python.h: No such file or directory
compilation terminated.
make[2]: *** [SWIG_CGAL/Kernel/CMakeFiles/_CGAL_Kernel.dir/CGAL_KernelPYTHON_wrap.cxx.o] Error 1
make[1]: *** [SWIG_CGAL/Kernel/CMakeFiles/_CGAL_Kernel.dir/all] Error 2
make: *** [all] Error 2






2012/6/1 Patrick Surry <patric...@gmail.com>

Sebastien Loriot (GeometryFactory)

unread,
Jun 1, 2012, 8:05:42 AM6/1/12
to cgal-bindi...@googlegroups.com
On 06/01/2012 01:32 PM, Noel Warren wrote:
> SWIG_ADD_MODULE(${MODULENAME} python ${INTERFACE_FILES}
> ${object_files})
Here is a mistake.

Sebastien.

Noel Warren

unread,
Jun 1, 2012, 10:37:58 AM6/1/12
to cgal-bindi...@googlegroups.com
Missed that one!  Ok. Cmake looks good and make compiles OK as long as I do "sudo make".  Alas, still the same symbol error when I require the .so file.

irb(main):001:0> require 'libCGAL_Kernel_cpp.so'
LoadError: ./libCGAL_Kernel_cpp.so: undefined symbol: Init_libCGAL_Kernel_cpp - ./libCGAL_Kernel_cpp.so
from ./libCGAL_Kernel_cpp.so
from (irb):1
from :0

Patrick Surry

unread,
Jun 1, 2012, 2:15:25 PM6/1/12
to cgal-bindi...@googlegroups.com
Admittedly I have no idea how SWIG is building stuff, but shouldn't you be using the output wrappers for your scripting language in SWIG_CGAL/build-<language>/CGAL instead of importing the SWIG_CGAL/lib libraries directly?  That's how it's working with Python fro example.

FWIW, my libCGAL_Kernel_cpp has no symbol Init_libCGAL_Kernel_cpp and my python and java bindings work fine.

Patrick

Noel Warren

unread,
Jun 1, 2012, 7:29:40 PM6/1/12
to cgal-bindi...@googlegroups.com
OK.  Staring to get closer.  I'm starting to get some idea of how this all works.  Thanks for all your patience.  The "build-ruby" folder had not been created but It now does get made by the make.  Anyways this does contain a "__init__.rb" file but that's just empty.  I think the problem might lie in my main CMakesList in the if_found part.  Any ideas anyone?  I really have no clue as to what it should look like.  I just mimicked the python one...

if (RUBY_FOUND)
      SET (RUBY_OUTDIR_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/build-ruby" CACHE PATH "RUBY specific files output directory prefix: the CGAL directory will contain Ruby generated files and libraries.")
      configure_file(SWIG_CGAL/files/__init__.py "${RUBY_OUTDIR_PREFIX}/CGAL/__init__.rb"  COPYONLY)
      LINK_DIRECTORIES("${RUBY_OUTDIR_PREFIX}/CGAL")
      MESSAGE(STATUS "Found Ruby libs.")
      MESSAGE(STATUS "CGAL-SWIG Ruby files and libraries will be written in ${RUBY_OUTDIR_PREFIX}/CGAL.")
    endif()


2012/6/1 Patrick Surry <patric...@gmail.com>

Patrick Surry

unread,
Jun 1, 2012, 8:24:24 PM6/1/12
to cgal-bindi...@googlegroups.com
I don't think you'll need that configure_file line - that's just copying a blank __init__.py file which is a python-specific thing.

You might try removing all the cmake-generated stuff (CMakeCache.txt etc), then running your cmake again, and doing "make VERBOSE=1" to get more output from your make process.  Particularly to see if it is running the swig -ruby CGAL_Kernel.i ... step and where the output is going.

Cheers,
Patrick

Noel Warren

unread,
Jun 2, 2012, 3:23:48 AM6/2/12
to cgal-bindi...@googlegroups.com
Yes, I also tried it without that line as it looked the most suspicious.  As for the CMakeCache, I delete it every time.  Isn't there a "make clean" equivalent for cmake?  Here is the relevant output from the make

[ 76%] Swig source
cd /home/noel/git/cgal-bindings/SWIG_CGAL/Kernel && /usr/bin/cmake -E make_directory /home/noel/git/cgal-bindings/build-ruby/CGAL
cd /home/noel/git/cgal-bindings/SWIG_CGAL/Kernel && /usr/bin/swig -ruby -DSWIG_CGAL_Kernel_MODULE -outdir /home/noel/git/cgal-bindings/build-ruby/CGAL -c++ -I/home/noel/git/cgal-bindings/SWIG_CGAL/Kernel/../include -I/usr/include -I/usr/local/include -I/home/noel/git/cgal-bindings -I/home/noel/git/cgal-bindings/SWIG_CGAL/Kernel -I/usr/lib/ruby/1.8/x86_64-linux -o /home/noel/git/cgal-bindings/SWIG_CGAL/Kernel/CGAL_KernelRUBY_wrap.cxx /home/noel/git/cgal-bindings/SWIG_CGAL/Kernel/CGAL_Kernel.i

So it looks fine.  At least to me.  In the main directory a folder is created "build-ruby" but it only contains a .so file that gives the same symbol link error previously mentioned.

On another note, I love the "make -j 4" command I spotted on the bindings page.

Patrick Surry

unread,
Jun 2, 2012, 11:14:00 AM6/2/12
to cgal-bindi...@googlegroups.com
Hmm.  Maybe it's an issue witht he structure of the CGAL_Kernel.i file?   I notice there's a constant "SWIG_CGAL_NON_SUPPORTED_TARGET_LANGUAGE" defined in SWIG_CGAL/common.i that only deals with Python and Java, maybe it needs SWIGRUBY added?  That might require some additional macro setup I'm guessing.   

It does sound like it's creating CGAL_KernelRUBY_wrap.cxx if it's building the shared library; maybe that's all that's required for a Ruby library?

Patrick

Patrick Surry

unread,
Jun 2, 2012, 11:19:55 AM6/2/12
to cgal-bindi...@googlegroups.com
BTW, the only thing I can find that's anything Init_libCGAL_Kernel_cpp in my Python/Java bindings are symbols that swig is generating in the _wrap.cxx file by some internal macro:

SWIG_CGAL/Kernel/CGAL_KernelPYTHON_wrap.cxx:#  define SWIG_init    PyInit__CGAL_Kernel
SWIG_CGAL/Kernel/CGAL_KernelPYTHON_wrap.cxx:#  define SWIG_init    init_CGAL_Kernel
SWIG_CGAL/Kernel/CGAL_KernelPYTHON_wrap.cxx:SWIG_init(void) {

Maybe your ruby wrapper has something similar, and there's something going wrong in the macro setup?

Cheers,
Patrick

Noel Warren

unread,
Jun 2, 2012, 1:29:52 PM6/2/12
to cgal-bindi...@googlegroups.com
I came across this...

It certainly looks like it may be the issue but am unsure of how to proceed.  Following the article, what should the following line look like?  Should I apply the patch in the link?  How do I apply a patch?

SWIG_ADD_MODULE(${MODULENAME} ruby ${INTERFACE_FILES} ${object_files})

Patrick Surry

unread,
Jun 2, 2012, 2:02:00 PM6/2/12
to cgal-bindi...@googlegroups.com
It sounds like that patch it just going to rename your output lib to, say, cgal_kernel.so instead of libcgal_kernel.so to match the ruby module naming convention.  Does ruby let you import it if you rename manually (or via a symbolic link to it)?

Patrick

Patrick Surry  |  W: (617) 457 5230  |  M: (857) 919 1700  

Noel Warren

unread,
Jun 2, 2012, 2:49:06 PM6/2/12
to cgal-bindi...@googlegroups.com
noel@vistii1:~/git/cgal-bindings/build-ruby/CGAL$ mv libCGAL_Kernel.so CGAL_Kernel.so
noel@vistii1:~/git/cgal-bindings/build-ruby/CGAL$ irb
irb(main):001:0> require 'CGAL_Kernel.so'
=> true

Looking good!

2012/6/2 Patrick Surry <patric...@gmail.com>

Noel Warren

unread,
Jun 2, 2012, 5:10:34 PM6/2/12
to cgal-bindi...@googlegroups.com
Odd.  There must be something I'm missing.

noel@vistii1:~/git/cgal-bindings/build-ruby/CGAL$ irb
irb(main):001:0> require 'CGAL_Kernel.so'
=> true
irb(main):002:0> Kernel.class
=> Module
irb(main):003:0> Kernel.methods - Module.new.methods
=> ["exit!", "chomp!", "fail", "print", "binding", "split", "Array", "format", "chop", "iterator?", "catch", "readlines", "trap", "getc", "caller", "putc", "proc", "chomp", "block_given?", "throw", "p", "sub!", "loop", "syscall", "trace_var", "exec", "Integer", "callcc", "puts", "load", "exit", "srand", "lambda", "global_variables", "gsub!", "untrace_var", "open", "`", "system", "Float", "method_missing", "sub", "abort", "gets", "require", "rand", "test", "warn", "eval", "local_variables", "chop!", "scan", "raise", "printf", "set_trace_func", "fork", "select", "sleep", "String", "at_exit", "readline", "sprintf", "gsub", "__method__"]

So the Kernel module is there but it doesn't seem like I can really do anything with it.  I can't really get past that.  There is no CGAL module.  Does this mean I'm gonna have to edit one of those i files?

2012/6/2 Noel Warren <noel...@gmail.com>

Patrick Surry

unread,
Jun 2, 2012, 5:25:35 PM6/2/12
to cgal-bindi...@googlegroups.com
I suspect you'll need at least some reference to SWIGRUBY in SWIG_CGAL/common.i, like it talks about SWIGPYTHON and SWIGJAVA (I think those are automatically #define'd by swig -ruby etc)

But SWIG seems pretty straightforward in how it produces methods in the target scripting language from the cxx file - have you looked in your ruby version of the kernel wrap_cxx file it built to see what's in there?

BTW, along with the cmake clean thing, I often find it doesn't seem to rebuild the wrap cxx file when I think it should, so I ended up in a habit of deleting it explicitly before making.   But you're getting past my understanding of SWIG, and I don't know anything about ruby...

Cheers,
Patrick

Noel Warren

unread,
Jun 2, 2012, 6:44:52 PM6/2/12
to cgal-bindi...@googlegroups.com
Well, thanks for everything!  You've been a tremendous help.  I hope you get those 3D Nefs wrapped, I'll also be needing the 3D minkowski sum method, so I might probe you with a few more questions in a couple of weeks.  I'm off to bed.  Its 1 in the morning here.

Thanks again.  I'll let you know how I get on.

2012/6/2 Patrick Surry <patric...@gmail.com>

Sebastien Loriot (GeometryFactory)

unread,
Jun 4, 2012, 1:44:02 AM6/4/12
to cgal-bindi...@googlegroups.com
On 06/02/2012 02:24 AM, Patrick Surry wrote:
> I don't think you'll need that configure_file line - that's just copying
> a blank __init__.py file which is a python-specific thing.
Right this is python specific and not needed for ruby I guess.

Sebastien.
> <mailto:patric...@gmail.com>>

Sebastien Loriot (GeometryFactory)

unread,
Jun 4, 2012, 1:51:30 AM6/4/12
to cgal-bindi...@googlegroups.com
On 06/02/2012 11:25 PM, Patrick Surry wrote:
> I suspect you'll need at least some reference to SWIGRUBY in
> SWIG_CGAL/common.i, like it talks about SWIGPYTHON and SWIGJAVA (I think
> those are automatically #define'd by swig -ruby etc)
For starting this is not necessary. This is only needed for advanced
features like iterators to be better supported. For all languages,
everything should work directly but not the faster it would with
dedicated code.

you should create a clone so that we can try it.


Sebastien.
> 2012/6/2 Noel Warren <noel...@gmail.com <mailto:noel...@gmail.com>>
>
> noel@vistii1:~/git/cgal-bindings/build-ruby/CGAL$ mv
> libCGAL_Kernel.so CGAL_Kernel.so
> noel@vistii1:~/git/cgal-bindings/build-ruby/CGAL$ irb
> irb(main):001:0> require 'CGAL_Kernel.so'
> => true
>
> Looking good!
>
> 2012/6/2 Patrick Surry <patric...@gmail.com
> <mailto:patric...@gmail.com>>
>
> It sounds like that patch it just going to rename your
> output lib to, say, cgal_kernel.so instead of
> libcgal_kernel.so to match the ruby module naming
> convention. Does ruby let you import it if you rename
> manually (or via a symbolic link to it)?
>
> Patrick
>
> Patrick Surry | W: (617) 457 5230
> <tel:%28617%29%20457%205230> | M: (857) 919 1700
> <tel:%28857%29%20919%201700>
>
> On Jun 2, 2012, at 1:29 PM, Noel Warren <noel...@gmail.com

Noel Warren

unread,
Jun 4, 2012, 3:19:58 AM6/4/12
to cgal-bindi...@googlegroups.com
I don't have too much experience with git and I haven't cloned the main repo.  What I have done is push to a separate repo...

I assume that makes no difference.  As I said to Patrick, it all seems to compile ok and a .so file is created in my build-ruby/CGAL directory.  There was the small SWIG issue of the file name but this was solved by applying this patch.  Alternatively you can just manually remove the first three chars of the .so file.  Nonetheless, when I require the file inside ruby a kinda "empty" Kernel module is exposed with no interesting constants, classes or methods.  I think I'm still doing something wrong but am at a loss as to what it is.

Please let me know as I am ever more interested in getting this working under Ruby.

2012/6/4 Sebastien Loriot (GeometryFactory) <slori...@gmail.com>
       <mailto:patrick.surry@gmail.com>>

Noel Warren

unread,
Jun 4, 2012, 2:01:12 PM6/4/12
to cgal-bindi...@googlegroups.com
Well, I'm getting awfully close to being at the end of my tether.  Now, for some inexplicable reason, my bindings project just won't compile.
[  3%] Building CXX object SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/Point_2.cpp.o
In file included from /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/typedefs.h:11:0,
                 from /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/Point_2.h:12,
                 from /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/Point_2.cpp:10:
/home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/decl.h:11:28: fatal error: boost/config.hpp: No such file or directory
compilation terminated.
make[2]: *** [SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/Point_2.cpp.o] Error 1
make[1]: *** [SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/all] Error 2
make: *** [all] Error 2

I can't for the life of me think what I could have done to provoke this, seeing as I'm sure I haven't touched a single file since I got it to compile.  I'm really starting to feel out of my depth.  Anyone?  I think I'm gonna go for a clean install one of these days.  OS, CGAL... the lot!


2012/6/4 Noel Warren <noel...@gmail.com>

Sebastien Loriot (GeometryFactory)

unread,
Jun 4, 2012, 2:15:55 PM6/4/12
to cgal-bindi...@googlegroups.com
On 06/04/2012 08:01 PM, Noel Warren wrote:
> Well, I'm getting awfully close to being at the end of my tether. Now,
> for some inexplicable reason, my bindings project just won't compile.
> [ 3%] Building CXX object
> SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/Point_2.cpp.o
> In file included from
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/typedefs.h:11:0,
> from
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/Point_2.h:12,
> from
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/Point_2.cpp:10:
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/decl.h:11:28: fatal
> error: boost/config.hpp: No such file or directory
> compilation terminated.
> make[2]: ***
> [SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/Point_2.cpp.o] Error 1
> make[1]: *** [SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/all] Error 2
> make: *** [all] Error 2
>
> I can't for the life of me think what I could have done to provoke this,
> seeing as I'm sure I haven't touched a single file since I got it to
> compile. I'm really starting to feel out of my depth. Anyone? I think
> I'm gonna go for a clean install one of these days. OS, CGAL... the lot!
Looks like you are missing a boost header. Did you update your machine
or touch anything?
If not, was it in a standard include path? (not /usr/include for
example) If yes then it might has been removed from the include folders
(but this would be strange).

Sebastien.


>
>
> 2012/6/4 Noel Warren <noel...@gmail.com <mailto:noel...@gmail.com>>
>
> I don't have too much experience with git and I haven't cloned the
> main repo. What I have done is push to a separate repo...
> https://bitbucket.org/noelwarr/cgal-bindings-ruby
>
> I assume that makes no difference. As I said to Patrick, it all
> seems to compile ok and a .so file is created in my build-ruby/CGAL
> directory. There was the small SWIG issue of the file name but this
> was solved by applying this patch
> <http://www.cmake.org/Bug/bug_relationship_graph.php?bug_id=12184&graph=relation>.
> Alternatively you can just manually remove the first three chars
> of the .so file. Nonetheless, when I require the file inside ruby a
> kinda "empty" Kernel module is exposed with no interesting
> constants, classes or methods. I think I'm still doing something
> wrong but am at a loss as to what it is.
>
> Please let me know as I am ever more interested in getting this
> working under Ruby.
>
> 2012/6/4 Sebastien Loriot (GeometryFactory) <slori...@gmail.com
> <mailto:slori...@gmail.com>>
> <mailto:noel...@gmail.com <mailto:noel...@gmail.com>>> wrote:
>
> Odd. There must be something I'm missing.
>
> noel@vistii1:~/git/cgal-__bindings/build-ruby/CGAL$ irb
> <mailto:noel...@gmail.com> <mailto:noel...@gmail.com
> <mailto:noel...@gmail.com>>>
>
>
> noel@vistii1:~/git/cgal-__bindings/build-ruby/CGAL$ mv
> libCGAL_Kernel.so CGAL_Kernel.so
> noel@vistii1:~/git/cgal-__bindings/build-ruby/CGAL$ irb
> irb(main):001:0> require 'CGAL_Kernel.so'
> => true
>
> Looking good!
>
> 2012/6/2 Patrick Surry <patric...@gmail.com
> <mailto:patric...@gmail.com>
> <mailto:patrick.surry@gmail.__com
> <mailto:patric...@gmail.com>>>
>
>
> It sounds like that patch it just going to
> rename your
> output lib to, say, cgal_kernel.so instead of
> libcgal_kernel.so to match the ruby module naming
> convention. Does ruby let you import it if you
> rename
> manually (or via a symbolic link to it)?
>
> Patrick
>
> Patrick Surry | W: (617) 457 5230
> <tel:%28617%29%20457%205230>
> <tel:%28617%29%20457%205230> | M: (857) 919 1700
> <tel:%28857%29%20919%201700>
> <tel:%28857%29%20919%201700>
>
>
> On Jun 2, 2012, at 1:29 PM, Noel Warren
> <noel...@gmail.com <mailto:noel...@gmail.com>
> <mailto:noel...@gmail.com <mailto:noel...@gmail.com>>> wrote:
>
> I came across this...
> http://www.cmake.org/Bug/bug___relationship_graph.php?bug_id=__12184&graph=relation
> <http://www.cmake.org/Bug/bug_relationship_graph.php?bug_id=12184&graph=relation>
> <http://www.cmake.org/Bug/bug___relationship_graph.php?bug_id=__12184&graph=relation

Noel Warren

unread,
Jun 4, 2012, 2:16:43 PM6/4/12
to cgal-bindi...@googlegroups.com
OK, so it seems that upon removing wine, boost AND gmp AND mpfr were all removed too.  Surprised wine depended on so much.  Anyway, compiling well again.  Still same doubts about how to access the relevant CGAL classes and methods.

2012/6/4 Noel Warren <noel...@gmail.com>

Sebastien Loriot (GeometryFactory)

unread,
Jun 5, 2012, 8:40:48 AM6/5/12
to cgal-bindi...@googlegroups.com
I had a quick look and it seems to work.

cd build-ruby/CGAL
irb

irb(main):001:0> require "CGAL_Kernel"
=> true
irb(main):011:0> p = CGAL_Kernel::Point_2.new(1,1)
=> #<CGAL_Kernel::Point_2:0x7fd3dfa70de0>
irb(main):013:0> p1 = CGAL_Kernel::Point_2.new(1,1)
=> #<CGAL_Kernel::Point_2:0x7fd3dfa66340>
irb(main):020:0> print p.x()," ", p.y(), "\n"
1.0 1.0
=> nil
irb(main):021:0> CGAL_Kernel::squared_distance(p,p1)
=> 0.0
irb(main):022:0> v1=CGAL_Kernel::Vector_2.new(p,p1)
=> #<CGAL_Kernel::Vector_2:0x7fd3dfa9ee98>
irb(main):023:0> print v1.x()
0.0=> nil

What I don't know is how ruby modules are usually organized.
Putting the .so in a CGAL directory is not needed here I think.



Sebastien.




On 06/04/2012 08:16 PM, Noel Warren wrote:
> OK, so it seems that upon removing wine, boost AND gmp AND mpfr were all
> removed too. Surprised wine depended on so much. Anyway, compiling
> well again. Still same doubts about how to access the relevant CGAL
> classes and methods.
>
> 2012/6/4 Noel Warren <noel...@gmail.com <mailto:noel...@gmail.com>>
>
> Well, I'm getting awfully close to being at the end of my tether.
> Now, for some inexplicable reason, my bindings project just won't
> compile.
> [ 3%] Building CXX object
> SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/Point_2.cpp.o
> In file included from
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/typedefs.h:11:0,
> from
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/Point_2.h:12,
> from
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/Point_2.cpp:10:
> /home/noel/git/cgal-bindings-ruby/SWIG_CGAL/Kernel/decl.h:11:28:
> fatal error: boost/config.hpp: No such file or directory
> compilation terminated.
> make[2]: ***
> [SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/Point_2.cpp.o] Error 1
> make[1]: *** [SWIG_CGAL/Kernel/CMakeFiles/CGAL_Kernel_cpp.dir/all]
> Error 2
> make: *** [all] Error 2
>
> I can't for the life of me think what I could have done to provoke
> this, seeing as I'm sure I haven't touched a single file since I got
> it to compile. I'm really starting to feel out of my depth.
> Anyone? I think I'm gonna go for a clean install one of these
> days. OS, CGAL... the lot!
>
>
> 2012/6/4 Noel Warren <noel...@gmail.com <mailto:noel...@gmail.com>>
>
> I don't have too much experience with git and I haven't cloned
> the main repo. What I have done is push to a separate repo...
> https://bitbucket.org/noelwarr/cgal-bindings-ruby
>
> I assume that makes no difference. As I said to Patrick, it all
> seems to compile ok and a .so file is created in my
> build-ruby/CGAL directory. There was the small SWIG issue of
> the file name but this was solved by applying this patch
> <http://www.cmake.org/Bug/bug_relationship_graph.php?bug_id=12184&graph=relation>.
> Alternatively you can just manually remove the first three
> chars of the .so file. Nonetheless, when I require the file
> inside ruby a kinda "empty" Kernel module is exposed with no
> interesting constants, classes or methods. I think I'm still
> doing something wrong but am at a loss as to what it is.
>
> Please let me know as I am ever more interested in getting this
> working under Ruby.
>
> 2012/6/4 Sebastien Loriot (GeometryFactory)
> <slori...@gmail.com <mailto:slori...@gmail.com>>
> <mailto:noel...@gmail.com <mailto:noel...@gmail.com>>>
> wrote:
>
> Odd. There must be something I'm missing.
>
> noel@vistii1:~/git/cgal-__bindings/build-ruby/CGAL$ irb
> <mailto:noel...@gmail.com> <mailto:noel...@gmail.com
> <mailto:noel...@gmail.com>>>
>
>
>
> noel@vistii1:~/git/cgal-__bindings/build-ruby/CGAL$ mv
> libCGAL_Kernel.so CGAL_Kernel.so
>
> noel@vistii1:~/git/cgal-__bindings/build-ruby/CGAL$ irb
> irb(main):001:0> require 'CGAL_Kernel.so'
> => true
>
> Looking good!
>
> 2012/6/2 Patrick Surry <patric...@gmail.com
> <mailto:patric...@gmail.com>
> <mailto:patrick.surry@gmail.__com
> <mailto:patric...@gmail.com>>>
>
>
> It sounds like that patch it just going to
> rename your
> output lib to, say, cgal_kernel.so instead of
> libcgal_kernel.so to match the ruby module
> naming
> convention. Does ruby let you import it if
> you rename
> manually (or via a symbolic link to it)?
>
> Patrick
>
> Patrick Surry | W: (617) 457 5230
> <tel:%28617%29%20457%205230>
> <tel:%28617%29%20457%205230> | M: (857) 919 1700
> <tel:%28857%29%20919%201700>
> <tel:%28857%29%20919%201700>
>
>
> On Jun 2, 2012, at 1:29 PM, Noel Warren
> <noel...@gmail.com <mailto:noel...@gmail.com>
> <mailto:noel...@gmail.com <mailto:noel...@gmail.com>>>
> wrote:
>
> I came across this...

Noel Warren

unread,
Jun 5, 2012, 9:30:04 AM6/5/12
to cgal-bindi...@googlegroups.com
Sebastien, thank you!!!
  You know when you become too obfuscated with something, you can't see the bigger picture?  The "CGAL_Kernel" module has everything indeed.  I had become fixated on the fact the "Kernel" module doesn't have the relevant classes and methods.  As it turns out, the reason it doesn't is because the "Kernel" module is an integral part of Ruby.
  Thanks ever so much for your patience, Sebastien and Patrick!  I'm sure I'll have more questions but I think they won't be the kind that involve copying and pasting error messages.  I feel like I'm back in my comfort zone :)

2012/6/5 Sebastien Loriot (GeometryFactory) <slori...@gmail.com>
               <mailto:patrick.surry@gmail.com>
               <mailto:patrick.surry@gmail.__com

               <mailto:patrick.surry@gmail.com>>>

MOHAMED AMINE Omrani

unread,
Jan 20, 2014, 12:39:37 PM1/20/14
to cgal-bindi...@googlegroups.com, noel...@gmail.com
Help Please !!!

-> compiling python/SatWrapper_wrap.o
/bin/sh: 1: python-config: not found
python/SatWrapper_wrap.cxx:149:20: fatal error: Python.h: No such file or directory
compilation terminated.
make[1]: *** [python/SatWrapper_wrap.o] Error 1
make[1]: Leaving directory `/media/40B87BAAB87B9CDA/ROCAME-ETUDE/DOCTORAT/outils/python/Numberjack-master/Numberjack-master/solvers/sat'
make: *** [sat_lib] Error 2

Reply all
Reply to author
Forward
0 new messages