Showing results for 
Search instead for 
Do you mean 
Reply

ITK linking error

[ Edited ]

Let me just say up front that I'm a complete n00b when it comes to ITK, so I thought it would be a simple matter to start with some preexisting code that's already been successfully compiled into a DLL, but even though I followed the Teamcenter help document about setting up Visual Studio 2010 SP1 for ITK projects, I'm running into a problem that I can't seem to track down. When I build the project I keep running into a single error during the linking step that states:

itk_main.obj : error LNK2019: unresolved external symbol ITK_user_main referenced in function "int __cdecl ms_exception_handling_wrapper(int,char * *)" (?ms_exception_handling_wrapper@@YAHHPEAPEAD@Z)

It seems like it's missing a dependency somewhere, or a library is out of date, but I don't see where. As a test, I created the example project outlined in the help files using one of the sample C code files and it compiled into an executable just fine.

 

Has anyone here seen this kind of problem and have a suggestion for how to fix it?

Arden Bedell | Teamcenter Wonk | Applied CAx, LLC
7 REPLIES

Re: ITK linking error

It appears that the setup for Visual Studio 2010 shown in Teamcenter 10.x help that I was following is really only appropriate for creating an executable, like a command-line utility, and not for the server extensions in the code I was trying to compile.

 

After reading further into the help files on ITK customization, which I'll admit I should have done more carefully to begin with, I discovered that there are several linking batch files supplied with the samples and one is for the type of server-side code I had. After setting the environment appropriately I was able to get the code to compile and link successfully.

 

I'll have to go back through the settings in the link batch files to see what differences there are for the various types of ITK programs I might want to write and see if they can be incorporated into a VS2010SP1 props file. It's just a lot easier to write and build within VS2010SP1 than to have to jump out of it and compile and link on the command line.

Arden Bedell | Teamcenter Wonk | Applied CAx, LLC

Re: ITK linking error

This may happens due to missing additional dependencies libraries

 

try below and pint to %TC_ROOT%

itk_main.obj;libsyss.lib;libpom.lib;libtcsso.lib;libae.lib;libappr.lib;libarchive.lib;libbackup.lib;libbom.lib;libcfm.lib;libconstants.lib;libcxpom.lib;libdmi.lib;libecm.lib;libeint.lib;libepm.lib;libfclasses.lib;libform.lib;libgms.lib;libgrm.lib;libtcinit.lib;libtc.lib;libtccore.lib;libtctrushape.lib;libinternal_exits.lib;libvalidation.lib;libitk.lib;liblov.lib;libme.lib;libmgc.lib;libobjio.lib;libpie.lib;libai.lib;libproperty.lib;libps.lib;libpublication.lib;libqry.lib;libclips.lib;libclipsutil.lib;librbf.lib;libce.lib;libres.lib;libsa.lib;libss.lib;libstep.lib;libsub_mgr.lib;libtextsrv.lib;libtie.lib;libnxmgr_im.lib;libaie.lib;libics.lib;libeintstub.lib;libsml.lib;libuser_exits.lib;librdv.lib;libcollabctx.lib;libmechatronics.lib;libtccoreext.lib;libusagewc.lib;libusage.lib;libcontmgmt.lib;libtc_utils.lib;libschmgt.lib;libschmgt_bridge.lib;libdocmgt.lib;libdocmgtapp.lib;libvm.lib;libadsfoundationdispatch.lib;libcm.lib;libcmdispatch.lib;libbase_utils.lib;libmld.lib;libfunctionality.lib;libmfg.lib;libmfgbvr.lib;libtcserverutil.lib;libcondvalidation.lib;libbooleanmath.lib;libconfigurator.lib;libfnd0booleansolve.lib;libsecore.lib;libFnd0formulamgmt.lib;%TC_ROOT%\lib\*.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;D:\Siemens\TcPMM\TC10\TC_ROOT\lib\*.lib

 

Re: ITK linking error

I just got this to successfully link in VS2010SP1 with a little help from Ken Chu at GTAC and a little help from the Internet. It turns out that the example properties file that is shown in Teamcenter's customization help is almost correct for compiling and linking a DLL. What needs to change is:

  1. Remove the reference to itk_main.obj from the list of additional dependencies, and
  2. Set Project Properties -> Configuration Properties -> General -> Configuration Type to "Dynamic Library (dll)" from the defailt "Application (exe)".

Thanks

Arden Bedell | Teamcenter Wonk | Applied CAx, LLC

Re: ITK linking error

Hello there, Could you please help me with the same issue here. I believe I have added all the libraries necessary for the user_exits_library file to run, but still getting the below error.

I have seen in one of the posts about having several linking batch files supplied with the samples. In my case, I have only one link_user_exits file, which I am running it currently trying to fix the error.

Can anyone please help me fixing this error.

 

error LNK2019: unresolved external symbol "__declspec(dl
limport) public: __cdecl std::basic_string<char,struct std::char_traits<char>,cl
ass std::allocator<char> >::basic_string<char,struct std::char_traits<char>,clas
s std::allocator<char> >(class std::basic_string<char,struct std::char_traits<ch
ar>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_tra
its@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV01@@Z) referenced in function "public
: __cdecl std::logic_error::logic_error(class std::basic_string<char,struct std:
:char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@Q
EAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)

Re: ITK linking error

[ Edited ]

There are three types of DLLs - user exits (not used/recommended anymore), server exits  (not used/recommended anymore), and custom exists (preferred).

 

If you don't see compile.bat and link_custom_exits.bat you may have incomplete installation or you may need to copy sample directory from installation disk.

 

depending upon how your custom code was written, you will have configure your build scripts.

 

Further, the error that you see suggests that you may not have visual studio installed properly (or may not be the right version)

---

Thanks and Regards

Yogesh Fegade

Re: ITK linking error

Here are the files you should see in the sample folder, along with a bunch of subfolders:

sample
|   compile.bat
|   extract_objects.bat
|   launchPV_MIMEtype_w2k.reg
|   linkitk.bat
|   link_custom_exits.bat
|   link_server_exits.bat
|   link_user_exits.bat
|   mapping_tester.exe

If you don't have those files, the extraction failed for some reason.

 

With regard to the properties required to compile an ITK DLL in Visual Studio 2010, here's the file I used:

 

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
    <_PropertySheetDisplayName>itk_general_dll</_PropertySheetDisplayName>
    <IncludePath>.\;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <ClCompile>
	  <!-- Replace "TCROOT" with the path to where Teamcenter is installed -->
      <AdditionalIncludeDirectories>TCROOT\include;TCROOT\include_cpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>NT40;POMDLL;CRTAPI1=_cdecl;CRTAPI2=cdecl;_WIN64;WIN64;WIN64_LEAN_AND_MEAN;WNT;BYPASS_FLEX;_INTEL=1;IPLIB=none;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
    </ClCompile>
    <Link>
      <AdditionalOptions>/ignore:4099 /ignore:4199 %(AdditionalOptions)</AdditionalOptions>
     <AdditionalDependencies>libsyss.lib;libpom.lib;libtcsso.lib;libae.lib;libappr.lib;libarchive.lib;libbackup.lib;libbom.lib;libcfm.lib;libconstants.lib;libcxpom.lib;libdmi.lib;libecm.lib;libeint.lib;libepm.lib;libfclasses.lib;libform.lib;libgms.lib;libgrm.lib;libtcinit.lib;libtc.lib;libtccore.lib;libtctrushape.lib;libinternal_exits.lib;libvalidation.lib;libitk.lib;liblov.lib;libme.lib;libmgc.lib;libobjio.lib;libpie.lib;libai.lib;libproperty.lib;libps.lib;libpublication.lib;libqry.lib;libclips.lib;libclipsutil.lib;librbf.lib;libce.lib;libres.lib;libsa.lib;libss.lib;libstep.lib;libsub_mgr.lib;libtextsrv.lib;libtie.lib;libnxmgr_im.lib;libaie.lib;libics.lib;libeintstub.lib;libsml.lib;libuser_exits.lib;librdv.lib;libcollabctx.lib;libmechatronics.lib;libtccoreext.lib;libusagewc.lib;libusage.lib;libcontmgmt.lib;libtc_utils.lib;libschmgt.lib;libschmgt_bridge.lib;libdocmgt.lib;libdocmgtapp.lib;libvm.lib;libadsfoundationdispatch.lib;libcm.lib;libcmdispatch.lib;libbase_utils.lib;libmld.lib;libfunctionality.lib;libmfg.lib;libmfgbvr.lib;libtcserverutil.lib;libcondvalidation.lib;libbooleanmath.lib;libconfigurator.lib;libfnd0booleansolve.lib;libsecore.lib;libFnd0formulamgmt.lib</AdditionalDependencies>
      <AdditionalLibraryDirectories>TCROOT\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
      <DelayLoadDLLs>libtcsso.dll;libict.dll;libae.dll;libappr.dll;libarchive.dll;libbackup.dll;libbom.dll;libcfm.dll;libdmi.dll;libecm.dll;libeint.dll;libepm.dll;libform.dll;libgrm.dll;libtccore.dll;libtctrushape.dll;libinternal_exits.dll;libitk.dll;libvalidation.dll;liblov.dll;libme.dll;libmechatronics.dll;libmgc.dll;libobjio.dll;libproperty.dll;libps.dll;libpublication.dll;libqry.dll;libres.dll;libstep.dll;libsub_mgr.dll;libtccoreext.dll;libnxmgr_im.dll;libpie.dll;libai.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
      <SubSystem>Console</SubSystem>
      <TargetMachine>MachineX64</TargetMachine>
      <IgnoreAllDefaultLibraries>
      </IgnoreAllDefaultLibraries>
    </Link>
    <Midl>
      <TargetEnvironment>X64</TargetEnvironment>
    </Midl>
  </ItemDefinitionGroup>
</Project>

This properties file is for a 64bit DLL, and as noted in the comment, you'll have to replace "TCROOT" with the path to your Teamcenter installation. Copy into a file and save it as "itk_general_dll.prop" and place it in your VS2010 project folder.

 

The last issue I ran into was to correctly configure the VS2010 project as a DLL and not an application (.exe). To do that, go to Project Properties (RMB the project in the Solutions pane and select Properties from the context menu) -> Configuration Properties -> General -> Configuration Type.

 

 

Make sure the type is set to "Dynamic Library (.dll)".

Arden Bedell | Teamcenter Wonk | Applied CAx, LLC

ITK linking error

Hi ,

 

I have a problem linking an ITK sample batch program.

 

I have compiled the program successfully. However when i do a linking I'm getting the following error.

#./sample/linkitk -o sample2 sample.o

Executable file will be: sample2

Linking against files : sample.o

/bin/ld: warning libicudata341.so, needed by /home/tcuser/shared/lib/libuser_exits.so, not found (try using -rpath or -rpath-link)

/bin/ld: /home/tcuser/shared/lib/itk_main.o: undefined reference to symbol '_ZTVN10__cxxabiv117__class_type_infoE@@CXXABI_1.3'

/bin/ld:note: '_ZTVN10__cxxabiv117__class_type_infoE@@CXXABI_1.3' is defined in /lib64/libstdc++.so.6:could not read symbols:Invalid operation

collect2:error: Id returned 1 exit status

 

I've copied the TC libraries and inculde files to my Linux machine. There is no Teamcenter installation other than these libraries and other files copied and I have set all teh environment variables required.

Here by attaching my linkitk script.