[Insight-users] Re : Re : issue with the file: cstddef - Qt and ITK and g++
Merlin Lenchanteur
tibouroxane at yahoo.fr
Thu May 6 17:00:21 EDT 2010
Hi,
First I apologize to have taken so long to get back to you on this issue, but I was busy on some things, and I wanted to find a way to reproduce the problem in a simple manner so you could also experience it.
I have been working on my spare time to reproduce the problem 'easily'. And I just got it tonight.
But before going on, let me reply to your question from your last reply: first question: "1) Are you observing this problem both in MinGW and in your
Ubuntu installation ?", the answer is yes.
To your second question: 2) Do you observe this problem when you use ITK without Qt ?, the answer is no.
And for the third: 3) Do you have anywhere in your code an statement: using namespace std; the answer is no.
To reproduce the problem I started from the QtITK example from the ITK Applications download (I'm sure you see the application I'm talking about).
So, I use CMake v2.8 to build it on my Ubuntu, and then, and compiled it. And it worked ! But, after inspecting the compile lines (by making the compilation verbose, i.e. CMAKE_VERBOSE_MAKEFILE), I saw that with the QtITK application, the directory /usr/local/include/itk3.18.0/Utilities/itksys was not in the include dependencies.
So, I took the CMakeLists.txt from the QtITK application, and I updated it to add the include directories such as:
--------------------- Begining of the CMakeLists.txt of QtITK application -------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)
PROJECT(QtITKExample)
SET( BUILD_OUTSIDE_INSIGHT_APPLICATIONS TRUE )
IF( BUILD_OUTSIDE_INSIGHT_APPLICATIONS )
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
INCLUDE_DIRECTORIES(/usr/local/include/itk-3.18.0/Utilities/itksys)
ELSE(ITK_FOUND)
MESSAGE(FATAL_ERROR
"Cannot build InsightApplications without ITK. Please set ITK_DIR.")
ENDIF(ITK_FOUND)
ENDIF( BUILD_OUTSIDE_INSIGHT_APPLICATIONS )
----------------------------------------------------------------------------------------
I just added "INCLUDE_DIRECTORIES(/usr/local/include/itk-3.18.0/Utilities/itksys)" so the QtITK application will include this directory as my real application does it (from which I found out this issue).
After re-configuring and re-generating with cmake, I ran "make", and my compilation problem has been reproduced ! (I will not copy/paste here the lengthy error messages that I got, because I'm quite confident that with the information I gave hereabove, you may be able to reproduce the problem and see the error for yourself).
I reproduced it the same way on my windows mingw's with gcc 3.4.5, and 4.4, and on my ubuntu is on gcc 4.4.3, and a debian gcc 4.4 (each time itk 3.18.0 has been used with Qt 4.6.2 - everything compiled and installed with the native compiler of the environment).
And, of course, if I use my workaround (renaming cstddef into cstddef.h of the Utilities/itksys directory), QtITK compiles again!
I still don't understand what's going on. If you need further information to reproduce the problem on your side, I'll be glad to help.
Thanks,
Chris
________________________________
De : Luis Ibanez <luis.ibanez at kitware.com>
À : Merlin Lenchanteur <tibouroxane at yahoo.fr>
Cc : insight-users at itk.org
Envoyé le : Mer 28 avril 2010, 6 h 06 min 30 s
Objet : Re: Re : [Insight-users] issue with the file: cstddef - Qt and ITK and g++
Hi Merlin,
Thanks for the additional information.
Just to clarify:
1) Are you observing this problem both in
MinGW and in your Ubuntu installation ?
2) Do you observe this problem when you
use ITK without Qt ?
For example, if you reconfigure ITK
to turn ON BUILD_EXAMPLES and
BUILD_TESTING, and then build the
ITK project.... do you get any compilation
errors (when using the original code).
3) Do you have anywhere in your code an
statement:
using namespace std;
??
Please let us know,
Thanks
Luis
--------------------------------------------------------------------------
On Tue, Apr 27, 2010 at 3:59 AM, Merlin Lenchanteur <tibouroxane at yahoo.fr> wrote:
Hello,
>
>First, thanks for your reply and your point of view.
>
>To reply to your question : " What is the value of this variable in your MinGW build ?" it is 1. And Yes, I do have a "cstddef" file in the include directory of Gcc under my MinGWs (gcc 3.4.5 and 4.4), and also in my Ubuntu 9.10 distribution in the directory you mentioned.
>
>With my workaround (renaming file Utilities \ itksys \ cstddef to Utilities \ itksys \ cstddef.h) I was able to move on in my development of my application in all platforms. So I did not take any more time to look further into this problem.
>>The thing that worries me the most is the fact to
> have to do this 'patch' every time I'll use a new version of itk or when I will recompiled/reinstalled it. I'll try one of those days to look into this problem again. Even though I'm quite confident with my path and include directories in my development configurations.
>
>Thanks,
>
>
>
>
>
________________________________
De : Luis Ibanez <luis.ibanez at kitware.com>
>À : Merlin Lenchanteur <tibouroxane at yahoo.fr>
>
>Cc : insight-users at itk.org
>Envoyé le : Jeu 22 avril 2010, 16 h 34 min 17 s
>Objet : Re: [Insight-users]
> issue with the file: cstddef - Qt and ITK and g++
>
>
>
>Hi Merlin,
>
>Thanks for your detailed email and for sharing this findings.
>
>
>Looking at the content of the cstddef might be enlightening:
>
>
>-------------------------------------------------------------------
>>#ifndef itksys_cstddef
>#define itksys_cstddef
>
>#include <itksys/Configure.hxx>
>
>/* Avoid warnings in MSVC standard headers. */
>#ifdef _MSC_VER
># pragma warning (push, 1)
># pragma warning (disable: 4702)
>>
># pragma warning (disable: 4786)
>#endif
>
>/* Include the real header. */
>#if itksys_CXX_HAS_CSTDDEF
># include <cstddef>
>#else
># include <stddef.h>
>#endif
>
>#ifdef _MSC_VER
># pragma warning(pop)
>>
>#endif
>
>#endif
>
>-------------------------------------------------------
>
>
>The primary suspect for the conflict that you are observing
>is the variable:
>
> itksys_CXX_HAS_CSTDDEF
>
>this variable get set during the configuration process
>via try-compiles.
>
>and decides whether this file is going to redirect
>the include to:
>
> # include <cstddef>
>or to
>
> # include <stddef.h>
>
>
>The value is set in the file
>
> Configure.hxx
>
>(in the binary directory Utilities/itksys)
>
>
>In a Visual Studio 9 configuration, this variable is set to
>
> Configure.hxx: #define itksys_CXX_HAS_CSTDDEF 1
>
>in a Ubuntu Linux 9.10 gcc 4.4 configuration, it gets set to
>
> Configure.hxx: #define itksys_CXX_HAS_CSTDDEF 1
>
>
>So, the question is:
>
> What is the value of this variable
> in your MinGW build ?
>
>and... do you have a "cstddef" file in the include directory
>of Gcc under MinGW ?
>
>As a reference,
>In Ubuntu Linux, with gcc 4.4 this file is at:
>
> /usr/include/c++/4.4/cstddef
>
>
>
> Please let us know what you find,
>
>
> Thanks
>
>
> Luis
>
>
>------------------------------------------------
>
>On Tue, Apr 20, 2010 at 3:00 PM, Merlin Lenchanteur <tibouroxane at yahoo.fr> wrote:
>
>>>
>>Hello,
>>
>>>>I just wanted to point out what could seems a very small detail at
>> first, but in the end, I spent quite a few hours (even days) to find it
>> out.
>>
>>>>My environments are the following:
>>>>First:
>>>>Win32 - XP Pro
>>>>Qt 4.6.2 (opensource edition)
>>>>ITK 3.12 and 3.16
>>>>Mingw 3.4.5 and 4.4.0
>>
>>>>Second:
>>>>Ubuntu 9.10 (Karmic Koala) 32 bits
>>>>Qt 4.6.2 (opensource edition)
>>>>ITK 3.18
>>>>compiler: gnu 4.4.1
>>
>>>>On both configuration: CMake v2.8
>>
>>>>I wanted to use Qt and ITK together in my applications and with mingw
>>3.4.5 (and now 4.4) for Win32 or gnu 4.4.1 for Linux. But when
>>compiling, I had weird errors about std::size_t not found. Typical errors when we are missing includes or dependencies.
>>>>I tried with Win32 using microsoft visual studio, but there was no
>>problem. It only appears with the g++ compiler.
>>
>>
>>>>Step to reproduce the problem:
>>>>Prerequisite: Qt and ITK correctly set up.
>>>>Write a simple main.cpp program which include qapplication.h (for example).
>>>>Create a makefile which contains Qt and all ITK dependencies and
>>includes ( don't forget Utilities\itksys - it's there that the problem
>>lies).
>>>>Run make --> error
>>>>If you remove all the ITK dependencies and includes, the make succeeds
>>(but then we can not use ITK :(!!).
>>
>>
>>>>How I solved it:
>>>>The problem is in the install directory of ITK.
>>>>To build and install ITK, I used CMake. In the settings, I remove
>>threading (because I don't need it). The CMake part and the build of ITK
>> runs smoothly.
>>>>Then I run "make install". So far, so good; everything is installed in
>>my install directory (I thought).
>>
>>>>In fact, the filename cstddef does not contain the '.h' extension in the
>>directory
>>>>"install \ include \ InsightToolkit \ Utilities \ itksys".
>>>>I changed this (renamed cstddef to cstddef.h), and then, everything went
>> well for me from that point on.
>>
>>>>Is there any particular reason for this file not to have the .h
>>extension as all its friends next to it in the directory? or is this a
>>bug ?
>>
>>>>I spent quite a long time to find this out, by first rechecking my code
>>(before going to a simple study case), redownloading and recompiling Qt
>>and ITK, changing compilers version and so on.
>>
>>>>If my current fix (the fact to add the extension '.h' to the cstddef filename) is not
>>recommended, please, let me know, but if you could help me fix
>>my problem then, I'll take any suggestions.
>>
>>Anyway, my proposed fix might help somebody.
>>
>>>>good day,
>>
>>
>>
>>_____________________________________
>>>>Powered by www.kitware.com
>>
>>>>Visit other Kitware open-source projects at
>>http://www.kitware.com/opensource/opensource.html
>>
>>>>Kitware offers ITK Training Courses, for more information visit:
>>http://www.kitware.com/products/protraining.html
>>
>>>>Please keep messages on-topic and check the ITK FAQ at:
>>http://www.itk.org/Wiki/ITK_FAQ
>>
>>>>Follow this link to subscribe/unsubscribe:
>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100506/6d6a9ba3/attachment-0001.htm>
More information about the Insight-users
mailing list