[Insight-users] linking errors

Mark Roden mmroden at gmail.com
Tue Nov 3 14:20:37 EST 2009


Hi all,

I'm trying to use the following code, which is more or less entirely
copied from page 300 of the 2.4 manual:


#include "stdAfx.h"
#include "CTSeriesReader.h"
#include <string>

#include "itkImageFileReader.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"


typedef itk::Image< signed short, 3 > CTImage;
typedef itk::Image< signed short, 3 >::Pointer CTPointer;
typedef itk::ImageSeriesReader<CTImage> CTReader;

CTPointer CTSeriesReader::Produce3DDicomStack(const std::string&
inDirectoryName) {


	CTPointer theReturn = CTImage::New();

	//code is borrowed verbatim from ~page 300 of v2.4 of the itk code manual
	CTReader::Pointer reader = CTReader::New();

	typedef itk::GDCMImageIO ImageIOType;
	ImageIOType::Pointer dicomIO = ImageIOType::New();
	reader->SetImageIO(dicomIO);

	typedef itk::GDCMSeriesFileNames NamesGeneratorType;
	NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
	nameGenerator->SetUseSeriesDetails(true);
	nameGenerator->SetDirectory(inDirectoryName);

	typedef std::vector < std::string > SeriesIdContainer;
	const SeriesIdContainer& seriesUID = nameGenerator->GetSeriesUIDs();
	SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
	SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
	try {//apparently, iterating through the series UIDs can cause
crashes, so let's just throw that into a try/catch
		while(seriesItr!=seriesEnd)
		{
			std::cout<<seriesItr->c_str()<<std::endl;
			seriesItr++;
		}
	}
	catch(itk::ExceptionObject &ex){
		std::cout<<ex<<std::endl;
		return theReturn;//nothing in it yet
	}

	std::string seriesIdentifier = seriesUID.begin()->c_str();

	typedef std::vector<std::string> FileNamesContainer;
	FileNamesContainer fileNames = nameGenerator->GetFileNames(seriesIdentifier);

	reader->SetFileNames(fileNames);
	try
	{
		reader->Update();
	}
	catch(itk::ExceptionObject &ex)
	{
		std::cout<<ex<<std::endl;
		return theReturn;
	}

	return reader->GetOutput();
}

problem is, I'm getting these linker errors:

1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol __imp__UuidCreate at 4 referenced in function "private: static
bool __cdecl gdcm::Util::GenerateUUID(unsigned char *)"
(?GenerateUUID at Util@gdcm@@CA_NPAE at Z)
1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol _gethostbyname at 4 referenced in function "private: static class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > __cdecl gdcm::Util::GetIPAddress(void)"
(?GetIPAddress at Util@gdcm@@CA?AV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@XZ)
1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol _gethostname at 8 referenced in function "private: static class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > __cdecl gdcm::Util::GetIPAddress(void)"
(?GetIPAddress at Util@gdcm@@CA?AV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@XZ)
1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol _WSACleanup at 0 referenced in function "private: static class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > __cdecl gdcm::Util::GetIPAddress(void)"
(?GetIPAddress at Util@gdcm@@CA?AV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@XZ)
1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol _WSAStartup at 8 referenced in function "private: static class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > __cdecl gdcm::Util::GetIPAddress(void)"
(?GetIPAddress at Util@gdcm@@CA?AV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@XZ)
1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol _SnmpUtilVarBindFree at 4 referenced in function "int __cdecl
gdcm::GetMacAddrSys(unsigned char *)" (?GetMacAddrSys at gdcm@@YAHPAE at Z)
1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol _SnmpUtilOidNCmp at 12 referenced in function "int __cdecl
gdcm::GetMacAddrSys(unsigned char *)" (?GetMacAddrSys at gdcm@@YAHPAE at Z)
1>itkgdcm.lib(gdcmUtil.obj) : error LNK2019: unresolved external
symbol _SnmpUtilOidCpy at 8 referenced in function "int __cdecl
gdcm::GetMacAddrSys(unsigned char *)" (?GetMacAddrSys at gdcm@@YAHPAE at Z)
1>C:\Users\Mark\src\ITKTests\ITKTestProject\Debug\ITKTestProject.exe :
fatal error LNK1120: 8 unresolved externals

This happens on release or debug builds.

I'm using itk from the svn trunk with the flat header build.  I've
included all libraries into the same sln file as this file, and all
the itk header files.  Everything compiles.  I've also tried including
the gdcmutil.obj (56k) into the build, but that doesn't work.

What can I do to fix this problem?  Should I replace the gdcm 2.0 with
gdcm 2.1 libraries, or is this a build problem rather than a source
problem?

Thanks,
Mark


More information about the Insight-users mailing list