Jump to content

Portability of C++ EXE/DLL


FaridAgl
 Share

Recommended Posts

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.

Link to comment
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.

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.
Link to comment
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.

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...