Sign in to follow this  
Followers 0
FaridAgl

Portability of C++ EXE/DLL

17 posts in this topic

Regarding to thread's title, does "msvcrt.dll" exists on every version of Microsoft Windows?

What about the "msvcr100.dll"?

How much portable a C++ application or compiled dll can be?

I noticed when I'm using Microsoft Visual C++ (2010), in every target machine the Microsoft Visual C++ 2010 Redistributable Package should be installed. Could I compile the project some how that it doesn't need this? Or is there any other compiler for this reason?

Some information would be great,

Thanks in advance.

Share this post


Link to post
Share on other sites



There is a way to statically link the runtime: Project Settings -> Code Gen -> C++ -> Runtime -> Multithreaded (not multithreaded dll)

Share this post


Link to post
Share on other sites

Thanks, do you mean this one?

If yes, I have tried this before, still says (On a fresh copy of Windows XP SP3):

By some searchs around the web, I found some interesting information.

I have used Dependency Walker to detect which Dlls are linked to my application.

If I compile the app with MSVC++ it needs msvcr100.dll, if put this dll in the same folder as the app exe, then it will use it instead of searching the system32 for it.

If I use Code::Blocks for compiling my application, it needs msvcrt.dll which I think it's available in Windows by default.

Share this post


Link to post
Share on other sites

I read Mat's reply as if he means the first selection "Multi-threaded (/MT)"

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If I compile the app with MSVC++ it needs msvcr100.dll, if put this dll in the same folder as the app exe, then it will use it instead of searching the system32 for it.

This page. First go to "Search Order for Desktop Applications", then find the list under "If SafeDllSearchMode is enabled ... ". The list is the search order for Dlls, like you said, application directory is searched first. That's pretty useful, and also quite dangerous.

Share this post


Link to post
Share on other sites

lol, this happened to me to, I made a dll that would be used in an autoit script, and I'm getting a lot of feed back from people saying that msvcrt100.dll is missing etc.

I think that was the name, apparantly it's needed for the string search functions I'm using.

how can I make my dll indipendant from these things? I'm also compiling as multi-threaded.

Share this post


Link to post
Share on other sites

Mat, thank you friend, also water for making Mat's post clear.

By compiling with Multi-threaded (/MT), it has no dependency.

But, really, what's the different? I have noticed the file size increased about 30kb, why? Does it includes the required DLLs now?

Share this post


Link to post
Share on other sites

Something like that. Of course it doesn't include DLLs, but something like that.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

So, if it's that easy, why compiling on MT is not the default option? What's behind the scene? Does it makes any change in how the complied project will behave?

I just got a little confused, want to know and understand.

Share this post


Link to post
Share on other sites

So, if it's that easy, why compiling on MT is not the default option? What's behind the scene? Does it makes any change in how the complied project will behave?

I just got a little confused, want to know and understand.

The exe will be smaller with dynamic linking. There can be certain problems with static linking, such as multiple dlls has to include the same crt and leads to bigger code sizes.

also, you can't delete memory inbetween modules since they use different heaps


Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Share this post


Link to post
Share on other sites

So, in my situation (Creating a DLL with some exported functions that will be called from AutoIt) it shouldn't be a big deal, is that all or am I missing something else?

Also the file size isn't so important in what I'm trying to do, as I said it's only 1 DLL, 20 ~ 30 KB extra file size wouldn't be annoying.

Share this post


Link to post
Share on other sites

So, in my situation (Creating a DLL with some exported functions that will be called from AutoIt) it shouldn't be a big deal, is that all or am I missing something else?

Also the file size isn't so important in what I'm trying to do, as I said it's only 1 DLL, 20 ~ 30 KB extra file size wouldn't be annoying.

Yeah you'll probably be better off with static linking :)

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

EDIT:(the following nervous rant has been solved)

I changed a project to that setting and it's destroyed it, it wont even compile anymore.

It says all sorts of includes are missing amongst other things.

IntelliSense: identifier "DWORD" is undefined

IntelliSense: identifier "u_char" is undefined

IntelliSense: identifier "LPVOID" is undefined

etc...

IntelliSense: declaration is incompatible with "long WINAPI" (declared at line 152 of "c:blahAutoIt3.h")

IntelliSense: this declaration has no storage class or type specified

The list goes on, when I changed it back to "Multi-threaded Debug DLL (/MDd)" the problem remains.

What a fking headache :(

EDIT:

And furthermore, I must have backed up my project incorrectly (copied project folder to another location before making the change) because it destroyed original too.

Nightmare, weeks of work down the shit pan, seriously think thoroughly about what you are doing before making such a change to your project

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

1>libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW

1>project.obj : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __thiscall std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::operator[](unsigned int)const " (??A?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@I@Z)

1>libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW

1>libcpmtd.lib(cin.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW

1>libcpmtd.lib(cout.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW

1>libcpmtd.lib(xdebug.obj) : error LNK2001: unresolved external symbol __free_dbg

1>libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __free_dbg

1>project.obj : error LNK2019: unresolved external symbol __free_dbg referenced in function "private: void __thiscall std::_Yarn<char>::_Tidy(void)" (?_Tidy@?$_Yarn@D@std@@AAEXXZ)

1>libcpmtd.lib(cin.obj) : error LNK2001: unresolved external symbol __free_dbg

1>libcpmtd.lib(cout.obj) : error LNK2001: unresolved external symbol __free_dbg

1>libcpmtd.lib(locale0.obj) : error LNK2001: unresolved external symbol __free_dbg

1>libcpmtd.lib(locale0.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "public: class std::_Yarn<char> & __thiscall std::_Yarn<char>::operator=(char const *)" (??4?$_Yarn@D@std@@QAEAAV01@PBD@Z)

1>libcpmtd.lib(xdebug.obj) : error LNK2001: unresolved external symbol __malloc_dbg

1>libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __malloc_dbg

1>libcpmtd.lib(_tolower.obj) : error LNK2019: unresolved external symbol __calloc_dbg referenced in function __Getctype

1>C:\Documents and Settings\JOHN\Documents\CODE\project\project\Debug\project.exe : fatal error LNK1120: 4 unresolved externals

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Well panic is over and I'm happy to report that I somehow recovered it, but only by desperately farting about with the project settings with a 'nothing to lose' attitude.

Makes me realize I need to find out a lot more about how visual studio IDE works.

For example, some third party libraries I am using, the header files were in the project folder before disaster struck, but they are now missing.

They show up in the solution but cannot be accessed because VS cannot find the file, except the project still compiles and runs, I just don't get it.

Anyway I'm off to change my trousers :)

EDIT:

I seen a file I have not noticed before in debug folder, entitled "project.ilk", (incremental linker file) I think that sucked up the missing header files.

So when my scare occurred, did I inadvertently statically link that library I wonder.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0