Obj-C LLVM compiler starts complaining after build (for iOS)

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
eshwar.ramesh
Posts: 15
Joined: Tue, 2012-08-07, 08:30

Obj-C LLVM compiler starts complaining after build (for iOS)

#1 Post by eshwar.ramesh »

So,

1. I seem to have compiled DCMTK 3.6.0 correctly.
2. Created a new Xcode (4.3.2) project
3. Given the correct file paths for headers and libraries
4. Linked libraries to the binary.

All is well I thought.

Now, I get complaints from the Apple LLVM Compiler about a certain "<cstddef> file not found" from inside "ofstdinc.h"
(-> Encapsulation of old style vs. ISO C++ style standard includes). I receive errors from those "USE_STD_CXX_INCLUDES".

I tried commenting out those <cassert>, <cstddef> style includes (wherever the compiler seemed to have an issue with the standard ISO C++ style (I think) includes), thinking that the alternative old style includes should work.

But it spirals into other errors that I do not understand. So I have uncommented those and restored initial state.
It says "Lexical or Preprocessor Issue" - cstddef file not found.

Any clues as to what is going on?

Michael Onken
DCMTK Developer
Posts: 2072
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Obj-C LLVM compiler starts complaining after build (for

#2 Post by Michael Onken »

Hi,

do you including "dcmtk/config/osconfig.h" before any other DCMTK header? This is worth trying.

Also, it seems from your post that USE_STD_CXX_INCLUDES is defined. Did you also define it when compiling DCMTK? Per default, it should be set to OFF if not explicitly enabled in DCMTK.

Best,
Michael

eshwar.ramesh
Posts: 15
Joined: Tue, 2012-08-07, 08:30

Re: Obj-C LLVM compiler starts complaining after build (for

#3 Post by eshwar.ramesh »

Michael Onken wrote:do you including "dcmtk/config/osconfig.h" before any other DCMTK header? This is worth trying.
Yes I put it before any other DCMTK header.
Michael Onken wrote:Also, it seems from your post that USE_STD_CXX_INCLUDES is defined. Did you also define it when compiling DCMTK? Per default, it should be set to OFF if not explicitly enabled in DCMTK.
I haven't explicitly enabled any such thing while choosing build options in CMake, because I haven't come across any such option.

The DCMTK options I get are :-
DCMTK_WITH_DOXYGEN -> OFF
DCMTK_WITH_OPENSSL -> OFF
DCMTK_WITH_PNG -> ON
DCMTK_WITH_PRIVATE_TAGS -> ON
DCMTK_WITH_THREADS -> ON
DCMTK_WITH_TIFF -> OFF
DCMTK_WITH_XML -> OFF
DCMTK_WITH_ZLIB -> ON

Also, I am able to type some keywords from the toolkit and it is recognized by the Xcode IDE, like DcmFileFormat, OFCondition etc., Now I am getting a Lexical or Preprocessor issue, "<cassert> file not found" header when I included this :-

#include <dcmtk/config/osconfig.h>
#include <dcmtk/dcmdata/dcfilefo.h>

eshwar.ramesh
Posts: 15
Joined: Tue, 2012-08-07, 08:30

Re: Obj-C LLVM compiler starts complaining after build (for

#4 Post by eshwar.ramesh »

Update : In the osconfig.h file, "#define USE_STD_CXX_INCLUDES" was defined. I tried commenting that out. And it gives me an error from ofstream.h, saying that "iostream.h" is not found. So, should I recompile the whole dcmtk again? Or is there any other solution?

eshwar.ramesh
Posts: 15
Joined: Tue, 2012-08-07, 08:30

Re: Obj-C LLVM compiler starts complaining after build (for

#5 Post by eshwar.ramesh »

Any ideas how I can disable ANSI_STDLIB? I tried adding a manual condition DCMTK_WITH_ANSI_STDLIB (BOOL) set to OFF and well CMake won't accept manual conditions.

Michael Onken
DCMTK Developer
Posts: 2072
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Obj-C LLVM compiler starts complaining after build (for

#6 Post by Michael Onken »

Hi,

sorry, forget about the USE_STD_CXX_INCLUDES -- I confused it with another define (not all can be set from the visible CMake configuration). Leave USE_STD_CXX_INCLUDES in DCMTK compilation as is.

I wonder whether the "<cstddef> file not found" is the first error that pops up?

EDIT: I guess it is not necessary to fiddle around with ANSI_STDLIB, must be something more simple.

Best,
Michael

eshwar.ramesh
Posts: 15
Joined: Tue, 2012-08-07, 08:30

Re: Obj-C LLVM compiler starts complaining after build (for

#7 Post by eshwar.ramesh »

ViewController.m

Code: Select all

#import "ViewController.h"
/* Check my headers for this file */
#include <dcmtk/config/osconfig.h>
#include <dcmtk/dcmdata/dcfilefo.h>
#include <dcmtk/dcmdata/dcdeftag.h>


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    NSString *dcmFilename = @"/Something something";
    
    DcmFileFormat fileFormat;
    OFCondition loadStatus = fileFormat.loadFile([dcmFilename UTF8String]);
    if(loadStatus.good())
    {
        OFString patientName;
        OFCondition findStatus = fileFormat.getDataset()->findAndGetOFString(DCM_PatientName, patientName);
        if (findStatus.good()) {
            NSString *name = [NSString stringWithUTF8String:patientName.c_str()];
            NSLog(@">>%@ patient name is = [%@]", dcmFilename, name);
        }
    }
    else {
        NSLog(@"Failed to load %@!", dcmFilename);
    }

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

@end

The above is my ViewController.m code. <cassert> file not found is the first error from ofstdinc.h.

Michael Onken
DCMTK Developer
Posts: 2072
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Obj-C LLVM compiler starts complaining after build (for

#8 Post by Michael Onken »

Hm, that's weird since there are various other headers before cassert. But ok, maybe that is the first one actually included by one of the DCMTK headers you use. I am a little helpless, also I do not have any experience with using DCMTK code from objective C (however, should work of course).

Another stupid guess: It is important that you install DCMTK after compilation, i.e. run the INSTALL target (should be possible from XCode?). You can set the install prefix directory before during CMake run. So you end up with a directory on your system where you have something like dcmtk/bin, dcmtk/include, dcmtk/lib and a few more. If you use the code tree to include your files from, you may include the unconfigured osconfig.h that comes with the DCMTK code tree /config/include/dcmtk/config/osconfig.h.

Michael

eshwar.ramesh
Posts: 15
Joined: Tue, 2012-08-07, 08:30

Re: Obj-C LLVM compiler starts complaining after build (for

#9 Post by eshwar.ramesh »

Hello, as suggested in a lot of places, I tried naming that source file ViewController.m -> ViewController.mm and got past the compiler complaints.

Now when building and running, the thread stops at DcmDataDictionary saying "EXC_BAD_ACCESS". Anything I should know about the DcmDataDictionary?

EDIT : I am currently reading this -> http://support.dcmtk.org/docs/file_datadict.html

Michael Onken
DCMTK Developer
Posts: 2072
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Obj-C LLVM compiler starts complaining after build (for

#10 Post by Michael Onken »

Hi,

the error seems to be specific for iOS/Objective C compiles. From googling it looks like a memory allocation/initialization problem. All things to be said about the dictionary are in the text you referenced above. It is a global object and thus it is constructed only once. Make sure you lock the dictionary every time a thread accesses the dictionary, i.e. embraces your dictionary access always with dcmDataDict.rdlock(); and dcmDataDict.unlock(); as you can find it throughout the DCMTK.

Global objects are always a pain in the back since you cannot rely on construction order. We solved problems about this before where the relation between global error constants (OFConditions), loggers and the dictionary have been leading to problems on a few systems. I hope this is not another issue popping up ;)

Best,
Michael

eshwar.ramesh
Posts: 15
Joined: Tue, 2012-08-07, 08:30

Re: Obj-C LLVM compiler starts complaining after build (for

#11 Post by eshwar.ramesh »

Hello,

After making ViewController.m, ViewController.mm and passing the compiler errors, I am receiving this error.

Technically the thread execution of the program "pauses" with an EXC_BAD_ACCESS, and I have no clue what's happening.

Code: Select all

"log4cplus::_clear_tostringstream(std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >&)"
inside strhelp.cc.

Code: Select all

void _clear_tostringstream (tostringstream & os)
{
    os.clear(); // ON THIS LINE

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest