dcmtk 3.5.4 compilation on Mac 10.8.2

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
pkotre
Posts: 11
Joined: Tue, 2011-04-19, 14:09

dcmtk 3.5.4 compilation on Mac 10.8.2

#1 Post by pkotre »

Dear all,

I am facing a strange linker error problem while loading file using dcmfileformat.loadFile api.

>>>Linker error
Undefined symbols for architecture i386:
"DcmFileFormat::loadFile(char const*, E_TransferSyntax, E_GrpLenEncoding, unsigned long, E_FileReadMode)", referenced from:
_main in ccbDOspo.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
<<<
Could you pls help me out.


My Source code :
>>>
#include <dcmtk/config/osconfig.h>
#include <iostream>

#include <vector>

#include <string>

#include <stdlib.h>

#include <math.h>



// UNIX specific includes
#include <assert.h>
#undef verfiy

using namespace std;


/*DCMTK Header Files*/

#include "dcmtk/dcmdata/dcvrpn.h"

#include "dcmtk/dcmjpeg/djdecode.h" /* for dcmjpeg decoders */

#include "dcmtk/dcmjpeg/djencode.h" /* for dcmjpeg encoders */

#include "dcmtk/dcmdata/dcrledrg.h" /* for rle decoders */

#include "dcmtk/dcmjpeg/djrplol.h" /* for DJ_RPLossless */

#include "dcmtk/dcmjpeg/djrploss.h" /* for DJ_RPLossy */

#include "dcmtk/dcmjpeg/dipijpeg.h" /* for dcmimage JPEG plugin */

#include "dcmtk/dcmimage/diregist.h" /* include to support color images */

#include "dcmtk/dcmdata/dcfilefo.h"

int main()
{

DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
return 0;
}

<<<

>>>my build cmd and output.
$g++ test.cpp -I/var/root/MSDEV/svn_ext/external/prebuilt-binaries/dcmtk/3.5.4/MACOS/testbuild/include/dcmtk/3.5.4/include -DHAVE_CONFIG_H -arch i386 -L/var/root/MSDEV/svn_ext/external/prebuilt-binaries/dcmtk/3.5.4/MACOS/testbuild/lib/release/dcmtk/3.5.4 -ldcmjpeg -ldcmimgle -ldcmimage -lijg8 -lijg12 -lijg16 -ldcmdata -lofstd -lz

Undefined symbols for architecture i386:
"DcmFileFormat::loadFile(char const*, E_TransferSyntax, E_GrpLenEncoding, unsigned long, E_FileReadMode)", referenced from:
_main in ccbDOspo.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

<<<
>>> My lipo -info o/p
$pwd
/var/root/MSDEV/svn_ext/external/prebuilt-binaries/dcmtk/3.5.4/MACOS/testbuild/lib/release/dcmtk/3.5.4

$lipo -info *a
input file libdcmdata.a is not a fat file
input file libdcmdsig.a is not a fat file
input file libdcmimage.a is not a fat file
input file libdcmimgle.a is not a fat file
input file libdcmjpeg.a is not a fat file
input file libdcmnet.a is not a fat file
input file libdcmpstat.a is not a fat file
input file libdcmqrdb.a is not a fat file
input file libdcmsr.a is not a fat file
input file libdcmtls.a is not a fat file
input file libdcmwlm.a is not a fat file
input file libijg12.a is not a fat file
input file libijg16.a is not a fat file
input file libijg8.a is not a fat file
input file libofstd.a is not a fat file
Non-fat file: libdcmdata.a is architecture: i386
Non-fat file: libdcmdsig.a is architecture: i386
Non-fat file: libdcmimage.a is architecture: i386
Non-fat file: libdcmimgle.a is architecture: i386
Non-fat file: libdcmjpeg.a is architecture: i386
Non-fat file: libdcmnet.a is architecture: i386
Non-fat file: libdcmpstat.a is architecture: i386
Non-fat file: libdcmqrdb.a is architecture: i386
Non-fat file: libdcmsr.a is architecture: i386
Non-fat file: libdcmtls.a is architecture: i386
Non-fat file: libdcmwlm.a is architecture: i386
Non-fat file: libijg12.a is architecture: i386
Non-fat file: libijg16.a is architecture: i386
Non-fat file: libijg8.a is architecture: i386
Non-fat file: libofstd.a is architecture: i386

$nm -a libdcmdata.a | grep loadFile
00001104 T __ZN10DcmDataset8loadFileEPKc16E_TransferSyntax16E_GrpLenEncodingj
000030e8 S __ZN10DcmDataset8loadFileEPKc16E_TransferSyntax16E_GrpLenEncodingj.eh
000026b4 T __ZN13DcmFileFormat8loadFileEPKc16E_TransferSyntax16E_GrpLenEncodingj14E_FileReadMode
00004e24 S __ZN13DcmFileFormat8loadFileEPKc16E_TransferSyntax16E_GrpLenEncodingj14E_FileReadMode.eh
U __ZN13DcmFileFormat8loadFileEPKc16E_TransferSyntax16E_GrpLenEncodingj14E_FileReadMode

<<<


>>>my system info
$uname -a
Darwin mac-dev2 12.2.1 Darwin Kernel Version 12.2.1: Thu Oct 18 12:13:47 PDT 2012; root:xnu-2050.20.9~1/RELEASE_X86_64 x86_64

$gcc -v

gcc version 4.2.1 ( Based on Apple Inc. Build 5648) (LLVM build 2336.11.00)

<<<

thanks and regards
pkotre.

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmtk 3.5.4 compilation on Mac 10.8.2

#2 Post by J. Riesmeier »

Do you have multiple versions of the DCMTK libraries installed on your system (e.g. in /usr or whatever MacOS X uses)?

Did you already check the verbose output of the linker in order to see whether the correct libraries are linked?

Btw, why are you using DCMTK 3.5.4, which is almost 8 years old?

pkotre
Posts: 11
Joined: Tue, 2011-04-19, 14:09

Re: dcmtk 3.5.4 compilation on Mac 10.8.2

#3 Post by pkotre »

Riesmeier,

Thank you very much for the reply.

Previousely this setup was on mac 10.6.x and running perfectly.

Now that system was crashed. I am setting up new fresh system. So only one dcmtk library which I have built previousely.

Example program is to test the linking properly. I am using headers and libs from previous system.

Linker out also did not help me much.

How can I proceed further?

Btw, I am trying to rebuild the 3.5.4 on new system.

thanks and regards
pkotre.

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmtk 3.5.4 compilation on Mac 10.8.2

#4 Post by J. Riesmeier »

Btw, I am trying to rebuild the 3.5.4 on new system.
This is also what I would recommend (after you gave me the details of your system change).

pkotre
Posts: 11
Joined: Tue, 2011-04-19, 14:09

Re: dcmtk 3.5.4 compilation on Mac 10.8.2

#5 Post by pkotre »

Hi J. Riesmeier,

Thank you very much for your replies and help.

I have solved this problem.


I am listing down the steps for compilation for every ones benefit ( including me :) )

Steps:
======
1) Unzip fresh dcmtk3.5.4 to a directory (say /var/dcmtk354)
2) cd /var/dcmtk354
2) find . -name configure -exec chmod a+x {} \;
3) Edit config/Makefile.def
3.1) add -fPIC in CXXflags in config/Makefile.def
3.2) add ARCH=i386
3.3) GLOBALDEFS = -DHAVE_CONFIG_H -D_DARWIN_C_SOURCE ( This is required to remove this-> dependency in calling functions: viewtopic.php?f=3&t=3458)
4) Change compilers CC/CPP to XCode compilers from /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/
4.1) CC=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2
4.2) CPP=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/llvm-g++-4.2
5) autoconf ( If autoconf is not installed then install as in https://gist.github.com/jellybeansoup/4192307)
6) make

Thats it.

Thanks again.

Thanks and regards
pkotre.

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmtk 3.5.4 compilation on Mac 10.8.2

#6 Post by J. Riesmeier »

Thanks for posting this! Btw, it would certainly be much easier if you would use the current release (3.6.0) or even snapshot (3.6.1) version. Also step 2 (the second one) wouldn't be needed if you would use the tar.gz package...

pkotre
Posts: 11
Joined: Tue, 2011-04-19, 14:09

Re: dcmtk 3.5.4 compilation on Mac 10.8.2

#7 Post by pkotre »

Thanks!

You are right. 2nd step is rendundant in *tar.gz packages.

I will move to either 3.6.0 or 3.6.1 snapshot in near future.

Once again thanks for your inputs :)

Thanks and regards
pkotre.

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmtk 3.5.4 compilation on Mac 10.8.2

#8 Post by J. Riesmeier »

Also, I don't think that step 5 (autoconf installation) is really needed.

I can't say anything about the other items since I don't use Mac computers.

Btw, the ./configure step seems to be missing in your above list :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest