Creating Self-Contained Application

  • Thread starter Thread starter jeffrey.bigham
  • Start date Start date
J

jeffrey.bigham

Hello,

I have a relatively simple application that I'm trying to migrate from
VS2003 to VS2005. The problem I'm having is that after compiling with
VS2005, it won't run on any system that doesn't have VS2005 installed.
I'm sure there are just some libraries that get installed with VS2005
that don't exist (or at least the correct version doesn't exist) on
these systems.

This is just a small demo program and I don't want to go to the trouble
of creating a whole installation application. Is there a way to create
a copy-to-install application in VS2005? How do I statically link all
of the libraries that I need? It doesn't matter if the filesize blows
up.

Thanks!
Jeff
 
you can statically link to the runtime libraries by rightclicking on your
project,
selecting configuration properties -> C++ -> code generation and then set
runtime libraries to multithreaded.
that will cause static linkage.

kind regards,
Bruno.
 
Thanks Bruno.

I did this. To get it to work I had to add the compiler directive
/NODEFAULTLIB:libcmt.lib because otherwise it would complain about
multiply-defined functions.

After doing so the compiled program won't run on any systems. It
complains that the C Runtime is being accessed incorrectly. Do you
have any idea why this would be?

Also, someone suggested that I might be able to just specify an earlier
version of the libraries that this program uses, which would let it
load older ones if they are available. Perhaps this would be a better
option than statically linking everything that is required. Can this
be done and, if so, how?

Thanks!
Jeff
 
Thanks Bruno.

I did this. To get it to work I had to add the compiler directive
/NODEFAULTLIB:libcmt.lib because otherwise it would complain about
multiply-defined functions.

After doing so the compiled program won't run on any systems. It
complains that the C Runtime is being accessed incorrectly. Do you
have any idea why this would be?

It's because you specifically excluded that static crt (libcmt.lib) from
your link. You had multiply defined symbols because you were linking a set
of modules that were compiled with a mix of compiler settings. You should
be compiling everything with /MT (or /MTd) and nothing with /MD (or /MDd).
You can use

dumpbin /directives your_obj_or_lib_file

to discover the default library directives embedded in the files you're
trying to link. If you have a file that has a defaultlib:msvcrt.lib that
you cannont recompile but need to link, then you can add
/nodefaultlib:msvcrt to your link to suppress the DLL runtime library.
Also, someone suggested that I might be able to just specify an
earlier version of the libraries that this program uses, which would
let it load older ones if they are available. Perhaps this would be
a better option than statically linking everything that is required.
Can this be done and, if so, how?

You might be able to, but you're on your own - there's no support for
compiling with VC8 and linking with VC7 runtime libraries (for example).

-cd
 
Back
Top