Compiling dcm2xml as a Single Project on W2K with MC++6

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

Compiling dcm2xml as a Single Project on W2K with MC++6

#1 Post by dave »

I have successfully compiled the ALL_BUILD set of projects within DCMTK using MC++6, but now want just to build dcm2xml as a separate project. Even with all necessary header files added to a new project for this purpose, there a number of link errors that occur.

I notice that, within the DCMTK downloaded source code, dcm2xml has 2 shortcuts to files appearing between the Source Code and External Dependencies folders in the file view for this project. They are dcmdata and ofstd. Can someone tell me how to insert these shortcuts (to directories, it seems) into my new project. My assumption is that these might solve the link errors I'm getting.

Thanks very much,

dave

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#2 Post by Thomas Wilkens »

What you call a "shortcut to directories" is actually a "dependency": dcm2xml makes use of functions in dcmdata and ofstd, hence it is dependent on dcmdata and ofstd. When dcmdata and ofstd are compiled, the compiler result are the two libraries (containing machine executable code) dcmdata.lib and ofstd.lib. Since dcm2xml makes use of code in ofstd and dcmdata, it has to link against these two libraries. And that is exactly what you have to tell the compiler. In order to do so, make the following changes:

1. make sure "dcm2xml" is your active project (printed in bold letters) in MSVC6
2. go "Projects" -> "Dependencies" (a small window opens)
3. select "dcm2xml" in the combobox in the upper left corner of the window (this should actually already be selected)
4. in the list box in the lower left corner of the window, select/pick dcmdata and ofstd.
5. go "OK"
6. re-compile

It should work now.

dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

#3 Post by dave »

Thanks for your reply, Thomas. I followed your example and was able to add dcmdata and ofstd as subprojects and dependencies to dcm2xml. However, now I get these errors:

Compiling...
dcm2xml.cpp
Linking...
LIBCMTD.lib(osfinfo.obj) : error LNK2005: __alloc_osfhnd already defined in LIBCD.lib(osfinfo.obj)
LIBCMTD.lib(osfinfo.obj) : error LNK2005: __set_osfhnd already defined in LIBCD.lib(osfinfo.obj)
LIBCMTD.lib(osfinfo.obj) : error LNK2005: __free_osfhnd already defined in LIBCD.lib(osfinfo.obj)
LIBCMTD.lib(osfinfo.obj) : error LNK2005: __get_osfhandle already defined in LIBCD.lib(osfinfo.obj)
LIBCMTD.lib(osfinfo.obj) : error LNK2005: __open_osfhandle already defined in LIBCD.lib(osfinfo.obj)
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _WSACleanup@0
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _gethostbyname@4
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _gethostname@8
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _WSAStartup@8
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _Netbios@4
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflateInit2_
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflateInit_
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflateEnd
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflate
dcmdata.lib(dcostrmz.obj) : error LNK2001: unresolved external symbol _deflateInit2_
dcmdata.lib(dcostrmz.obj) : error LNK2001: unresolved external symbol _deflateEnd
dcmdata.lib(dcostrmz.obj) : error LNK2001: unresolved external symbol _deflate
Debug/Dicom2XML.exe : fatal error LNK1120: 12 unresolved externals
Error executing link.exe.

Dicom2XML.exe - 18 error(s), 1 warning(s)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Likely my environment is still not set up correctly.
Open to suggestions.
Thanks,

dave

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#4 Post by Thomas Wilkens »

Regarding the LNK2001 error, see FAQ #27 (last paragraph, you have to add netapi32.lib and wsock32.lib in the Project/Properties/Linker tab/General category/Library modules entry field). Regarding the LNK2005 error, see FAQ #26.

dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

#5 Post by dave »

almost there... Damn Hurricane Rita!

dependencies dcmdata and ofstd compile and link ok.

--------------------Configuration: Dicom2XML - Win32 Release--------------------
Linking...
Start Pass1
LINK : warning LNK4001: no object files specified; libraries used
Searching Libraries
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\kernel32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\user32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\gdi32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\winspool.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\comdlg32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\advapi32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\shell32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\ole32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\oleaut32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\uuid.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\odbc32.lib:
Searching C:\Program Files\Microsoft Visual Studio\VC98\LIB\odbccp32.lib:
Searching .\dcmdata\libsrc\Release\dcmdata.lib:
Searching .\ofstd\libsrc\Release\ofstd.lib:
Done Searching Libraries
End Pass1
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
Release/Dicom2XML.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Dicom2XML.exe - 2 error(s), 1 warning(s)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Googled "_mainCRTStartup", says 'main' can't be found.

Confused now...

dave

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#6 Post by Thomas Wilkens »

Make sure the file which contains your main()-routine is included in the project you are compiling. The linker error at the top indicates that you dont even have one file contained in the project you are compiling, if that is really the case, let me tell you that this does not make any sense.

I assume you know what the main()-routine is about, dont you?

dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

#7 Post by dave »

Yes, I know what a main routine is. But I have not written one. I've assumed, perhaps incorrectly, that all code necesary to compile and link dcm2xml.exe as a separate project is already in the DCMTK. Is this not the case?

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#8 Post by Thomas Wilkens »

All code you need for dcm2xml is indeed contained in DCMTK. However, you apparently forgot to insert dcmdata/apps/dcm2xml.cc into your "separate project". This file contains the main()-routine for dcm2xml.

dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

#9 Post by dave »

Thanks for all the suggestions, Thomas. I'm not sure exactly what I've done to get this error, but dcm2xml.cxx has certainly been inserted into the project.

I think that I will start again from the beginning, making use of your input.

I'll post back when I get a chance to work on this again.

Thanks very much,

dave

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest