Статически связывая DLL в Windows

Вы могли также использовать свою фиксированную строку ширины в качестве строки формата как это:

char my_fixed_width_string_format[] = "need 10 chars starting here: %10s";
char my_fixed_width_string[40];
char string_to_print[] = "abcdefghijklmnop";
sprintf(my_fixed_width_string, my_fixed_width_string_format, string_to_print;
printf(my_fixed_width_string);

должен уступить

потребность 10 символов, запускающихся здесь: abcdefghij

6
задан 29 September 2009 в 05:22
поделиться

2 ответа

You can't statically link a DLL, only a LIB. DLLs are self contained and have static members and DllMain load/unload dependencies that means they cannot be split into containing functions and linked into a different executable.

You should create an installer that deploys all the appropriate dlls, as needed.

If you really think is that important and you cannot rely on your app installer you can create a wrapper that embeds the needed dlls (A, X, Y and Z) as resources and at runtime extracts them and write them to disk in the user profile temp folders, then loads the extracted dllA and defers all incoming function calls to the loaded dllA. Some of the sysinternals tools used similar techniques to extract x64 images of the application from the x86 image and relaunch themselves as 64bit processes w/o having to ship two separate exes.

7
ответ дан 9 December 2019 в 20:46
поделиться

Я не верю, что вы можете. Я не слышал об этом. Если у вас есть доступ для сборки других ваших DLL, вы можете создавать их как статические библиотеки, и они будут работать так, как вы хотите, но есть причина, по которой они называются динамическими библиотеками ссылок.

EDIT: ] Только что нашел эту ветку .

2
ответ дан 9 December 2019 в 20:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: