Page 1 of 1

[SOLVED] Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-05T18:19:05-07:00
by dan9er
I've just successfully(?) compiled Magick++ for my Windows 10 system, and I'm getting errors like these when I try to compile my program that uses it:

Code: Select all

C:\Users\dan9e\Desktop\cartogrtist\cartogrtist\build>make
Scanning dependencies of target cartogrtist
[ 10%] Building CXX object CMakeFiles/cartogrtist.dir/src/block/block.cpp.obj
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/src/block/block.cpp:17:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/src/block/block.h:23:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\Magick++/Color.h:11:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\Magick++/Include.h:42:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/MagickCore.h:79:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/annotate.h:21:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/draw.h:21:
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(115,3): error: unknown type name 'ssize_t'
  ssize_t
  ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(133,3): error: unknown type name 'ssize_t'
  ssize_t
  ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(146,28): error: unknown type name 'ssize_t'
  GetGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                           ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(146,38): error: unknown type name 'ssize_t'
  GetGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                     ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(152,34): error: unknown type name 'ssize_t'
  ParseMetaGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                 ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(152,44): error: unknown type name 'ssize_t'
  ParseMetaGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
Compiled ImageMagick version is 7.0.8-67
VS Build Tools 2019 version is 16.3.2
Using GNU Make 3.81
Using LLVM clang-cl 8.0.1
Imported .lib file is called CORE_RL_Magick++.lib

Re: Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-05T18:33:17-07:00
by snibgo
What is included in your source code? I expect something like:

Code: Select all

#include <Magick++.h>
#include <string>
#include <iostream>
If you are directly including Color.h etc then that is the problem.

Re: Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-06T13:45:39-07:00
by dan9er
snibgo wrote: 2019-10-05T18:33:17-07:00 What is included in your source code? I expect something like:

Code: Select all

#include <Magick++.h>
#include <string>
#include <iostream>
If you are directly including Color.h etc then that is the problem.
I did that, still having the same issue:

Code: Select all

C:\Users\dan9e\Desktop\cartogrtist\cartogrtist\build>make
Scanning dependencies of target cartogrtist
[ 10%] Building CXX object CMakeFiles/cartogrtist.dir/src/block/block.cpp.obj
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/src/block/block.cpp:17:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/src/block/block.h:23:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\Magick++.h:10:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\Magick++/Include.h:42:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/MagickCore.h:79:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/annotate.h:21:
In file included from C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/draw.h:21:
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(115,3): error: unknown type name 'ssize_t'
  ssize_t
  ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(133,3): error: unknown type name 'ssize_t'
  ssize_t
  ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(146,28): error: unknown type name 'ssize_t'
  GetGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                           ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(146,38): error: unknown type name 'ssize_t'
  GetGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                     ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(152,34): error: unknown type name 'ssize_t'
  ParseMetaGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                 ^
C:/Users/dan9e/Desktop/cartogrtist/cartogrtist/include\MagickCore/geometry.h(152,44): error: unknown type name 'ssize_t'
  ParseMetaGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                           ^
Did I muck up something while compiling IM?

Re: Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-06T14:46:13-07:00
by snibgo
IM source code includes sample CPP programs. Do they build correctly?

Re: Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-06T18:59:42-07:00
by dan9er
snibgo wrote: 2019-10-06T14:46:13-07:00 IM source code includes sample CPP programs. Do they build correctly?
Just tried to compile demo.cpp, getting same crap:

Code: Select all

C:\Users\dan9e\Desktop\cartogrtist\ImageMagick-Windows\ImageMagick\Magick++\demo\demo\build>make -j8
[ 50%] Building CXX object CMakeFiles/demo.dir/src/demo.cpp.obj
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/src/demo.cpp:13:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\Magick++.h:10:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\Magick++/Include.h:42:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/MagickCore.h:79:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/annotate.h:21:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/draw.h:21:
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/geometry.h(115,3): error: unknown type name 'ssize_t'
  ssize_t
  ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/geometry.h(133,3): error: unknown type name 'ssize_t'
  ssize_t
  ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/geometry.h(146,28): error: unknown type name
      'ssize_t'
  GetGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                           ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/geometry.h(146,38): error: unknown type name
      'ssize_t'
  GetGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                     ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/geometry.h(152,34): error: unknown type name
      'ssize_t'
  ParseMetaGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                 ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/geometry.h(152,44): error: unknown type name
      'ssize_t'
  ParseMetaGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
                                           ^
There are more errors, but they all involve ssize_t. >=20 errors, since make just stops trying after that. If you want I could pastebin the full log with -ferror-limit=0.

CMakeLists.txt:

Code: Select all

cmake_minimum_required(VERSION 3.15)
project(demo)

# compile with C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# set some stuff for Magick++ so it doesn't yell warnings at us
add_compile_definitions(MAGICKCORE_HDRI_ENABLE=0 MAGICKCORE_QUANTUM_DEPTH=8)

# create the executable
add_executable(demo ${CMAKE_SOURCE_DIR}/src/demo.cpp)

# set directories for libraries and includes
target_include_directories(demo PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_directories(demo PRIVATE ${CMAKE_SOURCE_DIR}/lib)

# link libraries to executable
target_link_libraries(demo ${CMAKE_SOURCE_DIR}/lib/CORE_RL_Magick++_.lib)
Relevant file tree:

Code: Select all

ImageMagick-Windows\ImageMagick\Magick++\demo
|   analyze.cpp
|   button.cpp
|   demos.tap
|   detrans.cpp
|   flip.cpp
|   gravity.cpp
|   piddle.cpp
|   shapes.cpp
|   smile_anim.miff
|   tile.miff
|   zoom.cpp
|
\---demo
    |   CMakeLists.txt
    |
    +---build
    |   |   CMakeCache.txt
    |   |   cmake_install.cmake
    |   |   Makefile
    |   |   model.miff
    |   |   smile.miff
    |   |
    |   \---CMakeFiles
    |       [CMake's stuff...]
    |
    +---include
    |   |   Magick++.h
    |   |
    |   +---Magick++
    |   |       [.h files...]
    |   |
    |   +---MagickCore
    |   |       [.h files...]
    |   |
    |   \---MagickWand
    |           [.h files...]
    |
    +---lib
    |       CORE_RL_Magick++_.lib
    |       CORE_RL_MagickCore_.lib
    |       CORE_RL_MagickWand_.lib
    |
    \---src
            demo.cpp

Re: Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-06T20:36:02-07:00
by snibgo
Okay, so the problem isn't in the source code, but in the building method. Sorry, I know nothing about the tools you use. Perhaps there is a flag to make the compiler POSIX-compliant, or something.

Re: Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-07T03:02:35-07:00
by magick
The Windows configure script auto-generates magick-baseconfig.h. It includes a define for ssize_t as follows:

Code: Select all

#if !defined(ssize_t) && !defined(__MINGW32__)
#if defined(_WIN64)
typedef __int64 ssize_t;
#else
typedef long ssize_t;
#endif
#endif

Re: Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-08T13:28:24-07:00
by dan9er
magick wrote: 2019-10-07T03:02:35-07:00 The Windows configure script auto-generates magick-baseconfig.h. It includes a define for ssize_t as follows:

Code: Select all

#if !defined(ssize_t) && !defined(__MINGW32__)
#if defined(_WIN64)
typedef __int64 ssize_t;
#else
typedef long ssize_t;
#endif
#endif
Well... I was using the .h files from my Unix machine. I assumed the includes are the same across platforms. I was mistaken. I've replaced the .h files in the demo/demo/include folder with the Windows ones I generated when compiling IM, and now it's no longer complaining about ssize_t!

Now it's giving warnings about redefined preprocessor variables and deprecated Windows Kit methods:

Code: Select all

C:\Users\dan9e\Desktop\cartogrtist\ImageMagick-Windows\ImageMagick\Magick++\demo\demo\build>make
Scanning dependencies of target demo
[ 50%] Building CXX object CMakeFiles/demo.dir/src/demo.cpp.obj
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/src/demo.cpp:13:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\Magick++.h:10:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\Magick++/Include.h:14:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/magick-config.h:25:
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/magick-baseconfig.h(61,9): warning:
      'MAGICKCORE_QUANTUM_DEPTH' macro redefined [-Wmacro-redefined]
#define MAGICKCORE_QUANTUM_DEPTH 16
        ^
<command line>(5,9): note: previous definition is here
#define MAGICKCORE_QUANTUM_DEPTH 8
        ^
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/src/demo.cpp:13:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\Magick++.h:10:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\Magick++/Include.h:14:
In file included from C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/magick-config.h:25:
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/include\MagickCore/magick-baseconfig.h(66,9): warning:
      'MAGICKCORE_HDRI_ENABLE' macro redefined [-Wmacro-redefined]
#define MAGICKCORE_HDRI_ENABLE 1
        ^
<command line>(4,9): note: previous definition is here
#define MAGICKCORE_HDRI_ENABLE 0
        ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/src/demo.cpp(31,8): warning: 'getenv' is deprecated: This function or
      variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
      [-Wdeprecated-declarations]
    if(getenv("SRCDIR") != 0)
       ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\stdlib.h(1190,20): note: 'getenv' has been explicitly marked deprecated here
    _Check_return_ _CRT_INSECURE_DEPRECATE(_dupenv_s)
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(309,55): note: expanded from macro
      '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(299,47): note: expanded from macro
      '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/src/demo.cpp(32,16): warning: 'getenv' is deprecated: This function or
      variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
      [-Wdeprecated-declarations]
      srcdir = getenv("SRCDIR");
               ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\stdlib.h(1190,20): note: 'getenv' has been explicitly marked deprecated here
    _Check_return_ _CRT_INSECURE_DEPRECATE(_dupenv_s)
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(309,55): note: expanded from macro
      '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(299,47): note: expanded from macro
      '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/src/demo.cpp(85,11): warning: 'getenv' is deprecated: This function or
      variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
      [-Wdeprecated-declarations]
      if (getenv("MAGICK_FONT") != 0)
          ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\stdlib.h(1190,20): note: 'getenv' has been explicitly marked deprecated here
    _Check_return_ _CRT_INSECURE_DEPRECATE(_dupenv_s)
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(309,55): note: expanded from macro
      '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(299,47): note: expanded from macro
      '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
C:/Users/dan9e/Desktop/cartogrtist/ImageMagick-Windows/ImageMagick/Magick++/demo/demo/src/demo.cpp(86,29): warning: 'getenv' is deprecated: This function or
      variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
      [-Wdeprecated-declarations]
        example.font(string(getenv("MAGICK_FONT")));
                            ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\stdlib.h(1190,20): note: 'getenv' has been explicitly marked deprecated here
    _Check_return_ _CRT_INSECURE_DEPRECATE(_dupenv_s)
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(309,55): note: expanded from macro
      '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include\vcruntime.h(299,47): note: expanded from macro
      '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
6 warnings generated.
About the variable redefinitions, you might remember I've set those in my CMakeLists.txt:
dan9er wrote: 2019-10-06T18:59:42-07:00

Code: Select all

# set some stuff for Magick++ so it doesn't yell warnings at us
add_compile_definitions(MAGICKCORE_HDRI_ENABLE=0 MAGICKCORE_QUANTUM_DEPTH=8)
I don't know why IM is overriding them. Is this a Windows quirk?
I think the getenv stuff is the demo program's fault though. It should probably be changed to _dupenv_s...

Yet another issue is that the linker, well, pukes at me about unresolved external symbols. However, I'm getting a similar issue to that on my Linux machine as well so I'll leave it to it's own thread.

Re: [SOLVED] Error when using Magick++: unknown type name 'ssize_t'

Posted: 2019-10-11T14:13:55-07:00
by dan9er
Seeing my bump got removed, I'm just going to mark the thread as solved and make a a new thread for my new problem.

Thank you magick & snibgo.