[Insight-users] Error when compiling HelloWorld.

Luis Ibanez luis.ibanez@kitware.com
Thu, 01 May 2003 11:13:44 -0400


Hi Hugo,


This problem is unrelated to ITK, it is just the
way in which VC++ manages versions.

When you compile your code, VC++ will put it in
a different directory depending on what of build
mode you are using.

If you look at the binary directory you will find
subdirectories (created by VC++) with names like


Release
Debug
RelMinSize

....and so on.

The problem with this is that when you create
a library in Debug mode, and try to use use it
from a program that you are building in Release
mode, the link process of your program will look
for the library in the directory where no library
has been created.

You have basically two options:


1) After building your library move it to a
   standard place. like /home/hugo/lib
   of c:\myFiles\lib

   then add this directory to the CMakeList file
   of your program


or


2) Build everything for Debug, (libraries and
   executable) or everything for Release.
   Never mix compilation modes.



Note that (2) is the right way to do things.

When you mix compilation modes, you may find
errors at run time since some basic structures
of C++ change of size when created in debug mode.


So:  Please don't mix compilation modes.


Regards,


  Luis


----------------------------
Hon-Cheng Wong wrote:
> Dear Luis, and all ITK users:
>         Under Windows 2000, I built ITK1.2.0  in *ALL_BUILD - Win32 
> Release*
> under MSVS 6.0 (SP5) (ITK.dsw was generated using CMake 1.66). 
> Everything runs
> smooth and there are only 3 warnings during the compilation process.
>  
>         I used CMake to generate the HelloWorld.dsw. (I had put the 
> HelloWorld.cxx and
> CMakeLists.txt in the HelloWorld source directory, I used an in-source 
> build, the ITK_DIR
> was pointed to my ITK binary directory.) And then I was trying 
> to build it, but there was
> 1 error in it as follow:
>         
> --------------------Configuration: HelloWorld - Win32 
> Debug--------------------
> Compiling...
> HelloWorld.cxx
> Linking...
> LINK : fatal error LNK1104: cannot open file "ITKCommon.lib"
> Error executing link.exe.
>  
> ALL_BUILD - 1 error(s), 0 warning(s)
>  
>           However, on another computer, I built ITK 1.2.0 in *ALL-BUILD 
> - Win32 Debug*
> under MSVS 6.0 (SP5). Everything runs smooth and there are 163 warnings 
> during the compilation
> process. But I could build HelloWorld.cxx successfully in this computer.
>  
>          Being a ITK user (not developer), I would like to know what are 
> the differeces between 
> ITK *Win32 -* *Release* and *Win32 - Debug* version. And what version 
> for the ITK user is
> recommended? And how to solve the problem in the Win32 - Release version 
> I met?
>  
> I put my CMakeCache.txt  in the HelloWorld binary directory here 
> (*refers to the *
> *unsuccessful **case (using ITK Win32 - Release) I met*.) 
>  
> # This is the CMakeCache file.
> # For build in directory: f:/ITK User Guide/Chapter2/HelloWorld
> # You can edit this file to change values found and used by cmake.
> # If you do not want to change any of the values, simply exit the editor.
> # If you do want to change a value, simply edit, save, and exit the editor.
> # The syntax for the file is as follows:
> # KEY:TYPE=VALUE
> # KEY is the name of a varible in the cache.
> # TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
> # VALUE is the current value for the KEY.
>  
> ########################
> # EXTERNAL cache entries
> ########################
>  
> //Path to a program.
> CMAKE_AR:FILEPATH=CMAKE_AR-NOTFOUND
>  
> //For backwards compatibility, what version of CMake commands and
> // syntax should this version of CMake allow.
> CMAKE_BACKWARDS_COMPATIBILITY:STRING=1.6
>  
> //C++ compiler
> CMAKE_CXX_COMPILER:STRING=cl
>  
> //Flags used by the compiler during all build types.
> CMAKE_CXX_FLAGS:STRING=  /W3 /Zm1000 /GX /GR
>  
> //Flags used by the compiler during debug builds.
> CMAKE_CXX_FLAGS_DEBUG:STRING=/MDd /Zi /Od /GZ
>  
> //Flags used by the compiler during release minsize builds.
> CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MD /O1
>  
> //Flags used by the compiler during release builds (/MD /Ob1 /Oi
> // /Ot /Oy /Gs will produce slightly less optimized but smaller
> // files).
> CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2
>  
> //Flags used by the compiler during Release with Debug Info builds.
> //
> CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2
>  
> //C compiler
> CMAKE_C_COMPILER:STRING=cl
>  
> //Flags for C compiler.
> CMAKE_C_FLAGS:STRING=  /W3 /Zm1000
>  
> //Flags used by the compiler during debug builds.
> CMAKE_C_FLAGS_DEBUG:STRING=/MDd /Zi /Od /GZ
>  
> //Flags used by the compiler during release minsize builds.
> CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1
>  
> //Flags used by the compiler during release builds (/MD /Ob1 /Oi
> // /Ot /Oy /Gs will produce slightly less optimized but smaller
> // files).
> CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2
>  
> //Flags used by the compiler during Release with Debug Info builds.
> //
> CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2
>  
> //Flags used by the linker.
> CMAKE_EXE_LINKER_FLAGS:STRING=/STACK:10000000 /machine:I386 /INCREMENTAL:YES
>  
> //Flags used by the linker during debug builds.
> CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /pdbtype:sept
>  
> //Flags used by the linker during release minsize builds.
> CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
>  
> //Flags used by the linker during release builds.
> CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
>  
> //Flags used by the linker during Release with Debug Info builds.
> //
> CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /pdbtype:sept
>  
> //Install path prefix, prepended onto install directories.
> CMAKE_INSTALL_PREFIX:PATH=/usr/local
>  
> //make program
> CMAKE_MAKE_PROGRAM:FILEPATH=C:/PROGRA~1/MICROS~2/Common/MSDev98/Bin/msdev.com
>  
> //Flags used by the linker during the creation of modules.
> CMAKE_MODULE_LINKER_FLAGS:STRING=
>  
> //Flags used by the linker during debug builds.
> CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
>  
> //Flags used by the linker during release minsize builds.
> CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
>  
> //Flags used by the linker during release builds.
> CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
>  
> //Flags used by the linker during Release with Debug Info builds.
> //
> CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /pdbtype:sept
>  
> //Flags used by the linker during the creation of dll's.
> CMAKE_SHARED_LINKER_FLAGS:STRING=/STACK:10000000 /machine:I386 
> /INCREMENTAL:YES
>  
> //Flags used by the linker during debug builds.
> CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=/debug /pdbtype:sept
>  
> //Flags used by the linker during release minsize builds.
> CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
>  
> //Flags used by the linker during release builds.
> CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
>  
> //Flags used by the linker during Release with Debug Info builds.
> //
> CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /pdbtype:sept
>  
> //If set, runtime paths are not added when using shared libraries.
> //
> CMAKE_SKIP_RPATH:BOOL=NO
>  
> //Libraries linked by defalut with all applications.
> CMAKE_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib 
> winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
> oleaut32.lib uuid.lib odbc32.lib odbccp32.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
>  
> //If this value is on, makefiles will be generated without the
> // .SILENT directive, and all commands will be echoed to the console
> // during the make.  This is useful for debugging only.
> CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
>  
> //Single output directory for building all executables.
> EXECUTABLE_OUTPUT_PATH:PATH=
>  
> //Value Computed by CMake
> HelloWorld_BINARY_DIR:STATIC=F:/ITK User Guide/Chapter2/HelloWorld
>  
> //Value Computed by CMake
> HelloWorld_SOURCE_DIR:STATIC=F:/ITK User Guide/Chapter2/HelloWorld
>  
> //The directory containing ITKConfig.cmake.  This is either the
> // root of the build tree, or PREFIX/lib/InsightToolkit for an
> // installation.
> ITK_DIR:PATH=F:/ITK1.2.0
>  
> //Single output directory for building all libraries.
> LIBRARY_OUTPUT_PATH:PATH=
>  
> 
> ########################
> # INTERNAL cache entries
> ########################
>  
> //Advanced flag for variable: CMAKE_AR
> CMAKE_AR-ADVANCED:INTERNAL=1
> //What is the target build tool cmake is generating for.
> CMAKE_BUILD_TOOL:INTERNAL=C:/PROGRA~1/MICROS~2/Common/MSDev98/Bin/msdev.com
> //This is the directory where this CMakeCahe.txt was created
> CMAKE_CACHEFILE_DIR:INTERNAL=f:/ITK User Guide/Chapter2/HelloWorld
> //Major version of cmake used to create the current loaded cache
> //
> CMAKE_CACHE_MAJOR_VERSION:INTERNAL=1
> //Minor version of cmake used to create the current loaded cache
> //
> CMAKE_CACHE_MINOR_VERSION:INTERNAL=6
> //Major version of cmake used to create the current loaded cache
> //
> CMAKE_CACHE_RELEASE_VERSION:INTERNAL=patch 6
> //Path to CMake executable.
> CMAKE_COMMAND:INTERNAL=F:/CMake1.66/bin/cmake.exe
> //Advanced flag for variable: CMAKE_CXX_COMPILER
> CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
> //Result of TRY_COMPILE
> CMAKE_CXX_COMPILER_WORKS:INTERNAL=TRUE
> //Advanced flag for variable: CMAKE_CXX_FLAGS
> CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_CXX_FLAGS_DEBUG
> CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_CXX_FLAGS_MINSIZEREL
> CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_CXX_FLAGS_RELEASE
> CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
> CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_C_COMPILER
> CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
> //Result of TRY_COMPILE
> CMAKE_C_COMPILER_WORKS:INTERNAL=TRUE
> //Advanced flag for variable: CMAKE_C_FLAGS
> CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_C_FLAGS_DEBUG
> CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_C_FLAGS_MINSIZEREL
> CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_C_FLAGS_RELEASE
> CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
> CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
> //Path to cache edit program executable.
> CMAKE_EDIT_COMMAND:INTERNAL=F:/CMake1.66/bin/CMakeSetup.exe
> //Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS
> CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
> CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
> //
> CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
> CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
> //
> CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
> //Name of generator.
> CMAKE_GENERATOR:INTERNAL=Visual Studio 6
> //Start directory with the top level CMakeLists.txt file for this
> // project
> CMAKE_HOME_DIRECTORY:INTERNAL=F:/ITK User Guide/Chapter2/HelloWorld
> //Advanced flag for variable: CMAKE_INSTALL_PREFIX
> CMAKE_INSTALL_PREFIX-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_MAKE_PROGRAM
> CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS
> CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
> CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
> //
> CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
> //
> CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
> //
> CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
> //noop for ranlib
> CMAKE_RANLIB:INTERNAL=:
> //Path to CMake installation.
> CMAKE_ROOT:INTERNAL=F:/CMake1.66
> //Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS
> CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
> CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
> //
> CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
> //
> CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
> //
> CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_SKIP_RPATH
> CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_STANDARD_LIBRARIES
> CMAKE_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
> //Advanced flag for variable: CMAKE_VERBOSE_MAKEFILE
> CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
> //Path to an executable
> HelloWorld_CMAKE_PATH:INTERNAL=F:/ITK User Guide/Chapter2/HelloWorld
>  
> Thank you very much in advance!!
>  
> Regards,
> Hugo
>  
> Hon-Cheng Wong, Hugo
> Faculty of Information Technology,
> Macau University of Science and Technology,
> Macau, China
>  
>  
> 
> 
>