1

http://www.red-gate.com/products/dotnet-development/smartassembly/

Is there a program like smartassembly for C++ that will remove all unneeded code from any linked DLL's (to reduce size) and pack them into a single EXE and then obfuscate it and compress it? to make one nice small secure EXE?

I love smartassembly for any .net program I make, wonder if there is something for C++.

THANKS!

Landin Martens
  • 3,283
  • 12
  • 43
  • 61

1 Answers1

5

Yes, such a tool is called a linker. You generally run it after you compile your application, although in most integrated development environments, this appears as a single step with a clever name like "build".

In other words, the hoops you have to jump through to remove unneeded code and "obfuscate" it for managed languages like C# are absolutely not necessary for C++. The linker will only link in functions that your code uses, and since everything is compiled down to binary, it's already as obfuscated as it is going to get.

Nothing is going to link in the contents of DLLs, though. The whole point of a DLL is that it is dynamically referenced by the executable, that's why it's called a "dynamic link library". If you want a code library that is statically linked in at compile time, you need to use a static library instead of a DLL.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • 2
    And if you want to compress the final executable, you can use something like [UPX](http://upx.sourceforge.net/). – jjlin Feb 24 '12 at 23:23
  • Well I want to use a library (pre build DLL's) but I wont use all the code in the DLL which is why I want to pack only code from the DLL that I use into the exe. – Landin Martens Feb 24 '12 at 23:24
  • @user: You need to obtain the source code for that library—that's generally how C++ development works. The only thing you could possibly do would be an utter hack: bundling the DLL inside of the EXE as an embedded resource, extracting it at runtime and utilizing it as a dependency, and then removing it. The madness is described [here](http://drdobbs.com/windows/184416443), but I don't at all recommend it. This is a good way to make antivirus programs go nuts and really serves no purpose. A better idea is to use a setup program that automatically installs all your app's dependencies. – Cody Gray - on strike Feb 24 '12 at 23:28
  • Well I want to built a Qt application, but don't want to have all those DLL files along with it, I want a single EXE design. – Landin Martens Feb 24 '12 at 23:40
  • @user: You're in luck! The source code for Qt is available, and static linking is even a supported configuration. You should ask a question about static linking the Qt framework into your application, if one hasn't already been asked. Start here in the [deployment notes](http://developer.qt.nokia.com/doc/qt-4.8/deployment.html). – Cody Gray - on strike Feb 24 '12 at 23:41
  • Thanks Cody Gray, i was not sure if it was allowed for me to do that with the source code. You are amazing :) – Landin Martens Feb 24 '12 at 23:42