comp.lang.ada
 help / color / mirror / Atom feed
From: alby.gamper@gmail.com
Subject: Re: Problem Building Ada Interface To ImageMagick 7
Date: Tue, 26 Jun 2018 02:26:45 -0700 (PDT)
Date: 2018-06-26T02:26:45-07:00	[thread overview]
Message-ID: <8808f0da-a96b-456b-b827-f2aae18fc8f4@googlegroups.com> (raw)
In-Reply-To: <f4c544c8-bbdf-48da-a27a-7611b880537d@googlegroups.com>

On Tuesday, June 26, 2018 at 6:28:57 PM UTC+10, Roger wrote:
> OSX 10.13.5
> GNAT community 2018
> XCode 9.4.1
> 
> ImageMagic Libraries:
> libMagick++-7.Q16HDRI
> libMagickCore-7.Q16HDRI
> 
> I have been developing some Ada Interfaces To ImageMagick 7 but have come to a problem that I need help with.
> I built the ImageMagick libraries with:
> CC=clang CXX="clang++ -std=c++11 -stdlib=libc++ -g -O0"  CFLAGS="-g -O0" CXXFLAGS="-g -O0" ./configure --prefix=/opt --with-quantum-depth=16 --disable-dependency-tracking --without-perl
> I enabled debugging (-g) to allow me to track through the ImageMagick code , C++ in particular which I find almost impossible to reverse engineer from the source alone.
> My C++ capabilities are very limited.
> 
> The following code works OK under XCode but crashes (segmentation fault) under GNAT.
> 
> #include <string>
> #include <stdio.h>
> #include "/opt/include/ImageMagick-7/Magick++.h"
> #include "Image.h"
> 
> using namespace Magick;
> 
> int main()
> {
>   Image   anImage;
> 
>   ssize_t  max_length = 0;
>   ssize_t  foo_len;
>   ssize_t  copied_str_len = 0;
>   ssize_t  buff_len = 4096;
>   size_t   rows = 0;
>   std::string foo("12345678901234567890\n12345678901234567890");
>   std::string bf = "";
>   char bar[buff_len];
> 
>   max_length=sizeof(foo) - 1;
>   foo_len=foo.length();
>   printf ("foo length %zd bytes.\n", foo_len);
> 
>   printf ( "Maximum length: %zd\n", max_length);
>   printf ("Rows: %zd\n", rows);
>   try {bf = anImage.baseFilename();}
>   catch (Error& my_error) {printf ("%s", my_error.what());}
>   catch (...) {printf ("Unhandled error\n");}
>   printf ("Rows: %zd\n", rows);
>     printf ("baseFilename: %s\n", anImage.baseFilename().c_str());
> 
>   printf ("Copied string length: %zd\n", copied_str_len);
>   printf ("bar: \n%s\n", bar);
> }
> 
> Under GNAT GPS it produces:
> foo length 41 bytes.
> Maximum length: 7
> Rows: 0
> [2018-06-26 18:02:10] process terminated successfully, elapsed time: 00.73s
> So it appears to terminate after the first  printf ("Rows: %zd\n", rows);
> That is, it terminates during the call to  anImage.baseFilename();
> 
> When I run the executable from the terminal:
> foo length 41 bytes.
> Maximum length: 7
> Rows: 0
> Segmentation fault: 11
> 
> Running the same code under XCode produces.
> 
> foo length 41 bytes.
> Maximum length: 23
> Rows: 0
> Rows: 0
> baseFilename: 
> Copied string length: 0
> bar: 
> 
> Program ended with exit code: 0
>  The code above is a cut down version of my test code.
> The complete version works under XCode.
> 
>  The problem seems to concern C++ string processing.
> A problem that one of my build attempts reported  appeared to concern the string Swap function being unable to handle null parameters.
> Unfortunately, I can't recall how I got that information.
> 
> I have tried numerous methods to solve this problem but am unable to. It seems that GNAT is using a different C++ compiler to XCode but I've had no success trying to remedy that idea.
> 
> Positive advice on how to proceed will be greatly appreciated.

Hi Roger

GNAT uses the GCC "C/C++" compiler or more specifically GNAT is actually part of GCC (GNU compiler collection"). GNAT community edition 2018 uses gcc version 7.3

As far as I am aware XCode uses the LLVM/CLANG C/C++ compiler

Alex

  reply	other threads:[~2018-06-26  9:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-26  8:28 Problem Building Ada Interface To ImageMagick 7 Roger
2018-06-26  9:26 ` alby.gamper [this message]
2018-06-26 11:58   ` Roger
2018-06-26 12:35     ` alby.gamper
2018-06-26 13:43       ` Roger
2018-06-27  2:08         ` Roger
2018-06-26 18:58   ` Jacob Sparre Andersen
2018-06-30  1:25   ` Roger
2018-06-26  9:34 ` gautier_niouzes
2018-06-26 11:51   ` Roger
2018-06-26 13:13   ` Roger
2018-06-26 16:28     ` gautier_niouzes
2018-06-26 17:47       ` Roger
2018-06-26 18:14       ` Roger
2018-06-26 18:38         ` gautier_niouzes
2018-06-27  2:11           ` Roger
2018-06-27  4:55             ` gautier_niouzes
2018-06-27  7:07               ` Roger
2018-06-27  7:28                 ` gautier_niouzes
2018-06-27  8:05                   ` Roger
2018-06-27  7:04           ` Dmitry A. Kazakov
2018-06-27  7:12             ` Roger
2018-06-27  9:59             ` gautier_niouzes
2018-06-27 12:34     ` Stephen Leake
2018-06-27 12:41       ` Roger
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox