65.9K
CodeProject is changing. Read more.
Home

Link order and mixed-mode DLLs

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Jan 26, 2012

CPOL
viewsIcon

19245

When linking a mixture of mixed-mode and unmanaged DLLs to an unmanaged C++ executable, the link order can affect how the program runs.

I recently added a mixed-mode C++/CLI DLL to an existing unmanaged C++ project which also included two unmanaged C++ DLLs, and found that the application file would crash very early on, before it had even reached any user code. After pulling out what little remains of my hair, I found that the order the DLLs' .lib files are linked to the executable affects whether or not it will crash. Basically, if you have an unmanaged and a mixed-mode DLL linked to the same executable, the mixed-mode DLL's .lib file must be linked first, or the application will crash. Just a short tip, but hopefully it'll be useful to someone!