简体   繁体   中英

Build C++ dll for Release and Debug

So I'm getting into c++ and I recently built a logger class ie print any type to the screen and/or to a log file. I built it as a dll and the output files are

console.h
console.lib
console.dll

I then imported these files as additional includes to another project and it works, only in debug mode (in which it was built) I wish for it to work regardless of build config. How can I accomplish this. An example, I recently used the GLFW library and can build in both how was it compiled for this to work.

If I correctly understood you're trying to link same version of your lib/dll with both debug and release configs of your app.

In general case you need two versions of your lib/dll files, debug and release, and link with the one that matches your application configuration, so for debug config of you app link with debug config of your lib/dll, and release with release.

The most possible problem of using mixed configs (like debug dll with release exe) is allocating memory in one domain and releasing it in another.

EDIT:

To elaborate, the problem can be allocating memory in your DLL and releasing it in your EXE, or vise versa. This doesn't work, at least with VS C-Runtime. For more details, see: https://stackoverflow.com/a/45806858/453271

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM