• XSS.stack #1 – первый литературный журнал от юзеров форума

How to compile C++ right?

GGHTC

RAM
Забанен
Регистрация
30.04.2023
Сообщения
127
Реакции
8
Пожалуйста, обратите внимание, что пользователь заблокирован
Hi, I am coding in C++ right now and I tested the exe on a windows Machine without visual studio installed. Now my exe says DLLs, not found etc. How can I Compile my c++ script so it runs on every pc, without any things installed?

I use windows.h
 
You can disable CRT, https://exchangetuts.com/compile-c-without-crt-1640370964247463. but remember, if you disable CRT, then you lose many standard functions, and most likely you will get errors like "undefined symbol memcpy". You'll have to implement these functions yourself. Also, unexpected errors may occur related to disabling CRT.
 
The easiest way is to static link runtime library. (Project properties -> C/C++ -> Code Generation -> Runtime Library -> MT for release mode (Set MTd for debug mode)
Another way which is usually used by malware developer is to disable CRT linkage.
It effectively decreases the PE size also removes the dependencies but you might face undefined symbol error message when using CRT library methods in your code.
You can fix that with linking against msvcrt.dll.
 
Пожалуйста, обратите внимание, что пользователь заблокирован
The easiest way is to static link runtime library. (Project properties -> C/C++ -> Code Generation -> Runtime Library -> MT for release mode (Set MTd for debug mode)
Another way which is usually used by malware developer is to disable CRT linkage.
It effectively decreases the PE size also removes the dependencies but you might face undefined symbol error message when using CRT library methods in your code.
You can fix that with linking against msvcrt.dll.
Thank you really much!!!
 
Пожалуйста, обратите внимание, что пользователь заблокирован
To create a C++ executable that can run on any Windows PC without requiring additional installations, you can consider these options:

1. **Static Linking:** One way to make your executable more self-contained is to statically link the necessary libraries into your binary. This means that the libraries are included within your executable, reducing the need for external DLLs. You can configure this in your project settings or use compiler flags like `-static-libgcc` and `-static-libstdc++` when using GCC or MinGW.

2. **Minimize Dependencies:** Minimize the use of external libraries in your project whenever possible. This reduces the chances of DLL dependency issues.

3. **Bundle DLLs:** If there are specific DLLs that your program depends on and you can't statically link them, you can bundle them with your application. Place the required DLLs in the same directory as your executable, and it should find them there when run.

4. **Dependency Walker:** Use tools like Dependency Walker to identify which DLLs your application depends on. This can help you ensure you've bundled all necessary DLLs.

5. **CMake and CPack:** If you're using CMake as your build system, you can use CPack to create installer packages that include all necessary DLLs.

Remember that some system DLLs might still be required, and these should be present on most Windows systems. It's essential to test your application on different Windows versions to ensure compatibility.

By following these steps, you can create a C++ executable that is more self-contained and can run on Windows PCs without requiring additional installations.
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх