简体   繁体   中英

C++ placing dll in relative path to exe

I built a small .exe application. Currently I take the compiled .exe file and all necessary .dll's and put them in one folder. So it looks like this: ( working )

appfolder/
    lib1.dll
    lib2.dll
    ...
    app.exe

I'd like to organize it and bring it in following form: ( not working )

appfolder/
    libs/
        lib1.dll
        lib2.dll
        ...
    app.exe

However, I do not find a way to make this work. I'm using VS2010 where I tried to add ".\\libs" to the Additional Include Directories (Project Properties > Configuration > C/C++).

I also read about LoadLibrary which seems to be not a solution to this problem...

Is that possible at all?

Maybe the SetDllDirectory function will work for you see here .

Besides this you can use LoadLibraryEx and GetProcAddress to do "lazy" loading.

Similar function also exist for Linux.

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