tags:

views:

80

answers:

4

Like the msvcr70/msvcr80/msvcr90.dll, what's the code like to instruct the linker to link to one of them dynamically?

Or has that anything to do with c/c++,but cmake?

+1  A: 

The specific examples you give happen to be DLLs that are usually linked through manifests and the side-by-side, at least when building applications (with the correct project settings) from Visual Studio. Why are you trying to instruct the compiler to link them by code?

The most often-used way to link to a particular DLL is when you have the lib for the DLL available, and then to use the pragma

 #pragma comment(lib, "<library name>")
MadKeithV
Can you elaborate how is the manifest composed?
A: 

eh, surely you want to first understand DLLs/linking... http://www.infernodevelopment.com/how-create-dll-c-using-run-time-dynamic-linking

the question as written is not answerable

Note: not sure what you mean with Cmake, but you can easily specify link libraries in your CMakeLists.txt file... the exception being the DLLs you note, because they are platform-dependent. You'd need something in the CMake script to check versions of MSVC.

Why would you want to link to an older run-time though, Vista onward come with the VC9 run-time, and if someone is using XP you can just give them the 'redistributable package' for VS2008/2010...

peter karasev
Also,can you elaborate how to make `cmake` use the 'redistributable package' for VS2008/2010 ?
Cmake by itself wouldn't need the redistributable pack when you build, but you could have CMake use an external tool like 'nullsoft scriptable install system' to form an installer for a user. Example: search for 'opencv', download the installer and source... you can try to recreate the installer with cmake + source.
peter karasev
+1  A: 

You specify a .lib file when you link, and the matching .dll will be used at run time, so (for example) if you want to use msvcr70.dll, you'll want to link with msvcr70.lib.

Jerry Coffin
A: 

In general, the C/C++ runtime you link against is dependent to the version of VisualStudio you are using. (msvcr80.dll -> VS2005, msvcr90.dll -> VS2008 etc.)

Some deeper insight on how this works and some tricks to work araoud this you can read up in this blog post.

Frank Bollack