Using precompiled lib and header files in MSVS 2008

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Silvermaul
Posts: 31
Joined: Thu, 2010-09-02, 10:03

Using precompiled lib and header files in MSVS 2008

#1 Post by Silvermaul »

Hello all,

I am new to DICOM and to this forum. Though I have tried to solve my problem by readinng the install directions and the faq, unfortunately I have been unsuccesful and I have to resort to writing yet another "how to use dcmtk" thread.

I have been provided with the .lib and header files of version 3.5.4 for win32 environment. For my simple case I am trying to simply compile and run the following example found in the forums :

Code: Select all

#include <iostream>
#include "dcmimage.h"

//application entry point
int main()
{
	DicomImage *image = new DicomImage("test.dcm");
	if (image != NULL)
	{
		if (image->getStatus() == EIS_Normal)
		{
			if (image->isMonochrome())
			{
				image->setMinMaxWindow();
				Uint8 *pixelData = (Uint8 *)(image->getOutputData(8 /* bits */));
				if (pixelData != NULL)
				{
					/* do something useful with the pixel data */
				}
			}
		}
		else
		{
			cerr << "Error: cannot load DICOM image (" << DicomImage::getString(image->getStatus()) << ")" << endl;
		}
	}
	delete image;
	std::cout<<"Hello DICOM..."<<std::endl;
	return 0;
The first problem I encountered was that the compiler couldn't find the dcmimage.h header file. I solved that by adding "include" path to the standard project include directories.

Then I was getting linker erros so I assumed the linker couldn't find the required libraries. To solve this I went to the project properties, I added the path to the libraries and then I added all the .lib files in the additional dependencies properties settings.

The result was that the initial linker errors were gone, however I am stuck with the following 5 linker errors:

1>------ Rebuild All started: Project: DCModifier, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'DCModifier', configuration 'Debug|Win32'
1>Compiling...
1>main.cpp
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1> Creating library D:\Projects\DCModifier\DCModifier\Debug\DCModifier.lib and object D:\Projects\DCModifier\DCModifier\Debug\DCModifier.exp
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _WSACleanup@0 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _gethostbyname@4 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _gethostname@8 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _Netbios@4 referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z)
1>D:\Projects\DCModifier\DCModifier\Debug\DCModifier.exe : fatal error LNK1120: 5 unresolved externals

What is confusing to me is that visual studio tries to created a .lib out of my project. Perhaps I have something else wrong ?

In any case any help would be greatly appreciated since I am battling with this error for the past 5 hours to no avail! :cry:

Silvermaul
Posts: 31
Joined: Thu, 2010-09-02, 10:03

#2 Post by Silvermaul »

The problem was that I was not adding the netapi32.lib and the wsocks32.lib.

I found this after searching a little bit more in the forum. You can now lock this thread.

Thanks!

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#3 Post by Jörg Riesmeier »

Ok, that's fine. And for all other readers: Check FAQ #40 and FAQ #27.
The first problem I encountered was that the compiler couldn't find the dcmimage.h header file. I solved that by adding "include" path to the standard project include directories.
The latter is not required, just use the complete path as shown in the various examples: "dcmtk/dcmimgle/dcmimage.h"

Silvermaul
Posts: 31
Joined: Thu, 2010-09-02, 10:03

#4 Post by Silvermaul »

Code: Select all

Warning	1	warning LNK4099: PDB 'ofstd.pdb' was not found with 'D:\Projects\DCModifier\DCModifier\lib\ofstd.lib' or at 'd:\Projects\DCModifier\DCModifier\Debug\ofstd.pdb'; linking object as if no debug info	ofstd.lib	DCModifier
Whenever I compile my project I get this warning many many times. The program works fine but I don't like to have warnings whatsoever. Is there a way to remove it (other lowering the warnings level? ).

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest