cmake set exe library path - windows

I have cmake app which build an window exe. On windows os.
add_executable(app ${app_SRC})
SET_TARGET_PROPERTIES(app PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")
target_include_directories(app PRIVATE ${wxWidgets_INCLUDE_DIRS})
target_link_libraries(app ${wxWidgets_LIBRARIES})
It build app.exe success. But when I run app.exe. The error dialog show:
Can't find wxbase314ud_vc_custom.dll.
How can I config the dll path?
I know I can copy the dlls to the exe folder, but is there any other way to do this in CMakeLists.txt?

Related

Why do I have to copy mingw DLLs manually when using windeployqt?

Just downloaded Qt Creator and compiled my application.
I am using windeployqt on the command line since I did not find any option in Qt creator itself.
When I use it on my binary I still have to copy DLLs like libgcc_s_seh-1.dll, libstdc++-6.dll and libwinpthread-1.dll from my Qt installation directory C:\Qt\6.2.2\mingw_64\bin into my deployment directory or otherwise I cannot start the .exe file.
The same happens if I am trying to start it in my target build directory without the Qt Creator.
Shouldn't windeployqt or the Qt Creator copy those DLLs into the build and deployment directory, so you can run the .exe properly?!

Linker Error When Changing Visual Studio Output to System32

For a research, I'm developing a Proxy DLL for nvcuda.dll (NVIDIA CUDA runtime) which resides in System32. To ease up debugging I change linker output to System32, however, I receive
LINK : fatal error LNK1104: cannot open file 'C:\Windows\System32\nvcuda.dll'
Here are the solutions I have tried:
Disabled the UAC.
Took ownership of System32 folder.
Ran the program as admin.
There are no white-spaces in the path to the file and no other program uses the DLL (it can be removed and renamed manually). The linker works fine for any other location, am I missing something?
EDIT:
An interesting observation is that I am able to build the same solution using msbuild as follows:
msbuild nvcuda.sln /p:Configuration=Debug /p:Platform=x64

C++ Program compiled with QT does not find automatically QT dlls in Windows

I have succesfully compiled a QT program for windows. I can not directly run the program in the build directory. The Dependency Walker shows that the paths to Qt5Gui.dll Qt5Widgets.dll Qt5Core.dll are not found. I am copying the dlls to the build directory and the program runs as expected. My question is how can I avoid copying the dlls in the build directory. Is there an option that I should add to the CMakeLists.txt to help in this situation ? I am using windows 10.

VS2010 can never find my DLLs

I've tried all day to get VS2010 to run my program. I can only get the program to find the DLLs if I copy and paste them into the same folder as the output exe.
I have listed the folders containing the DLLs I need included under Linker > General. But running the program still gives me errors such as:
"The program can't start because tbb_debug.dll is missing from your computer. Try reinstalling the program to fix this problem."
What can be going wrong? I am trying to include 2 packages which have VS2010 DLL binaries; TBB (Intel package) and Open-CV (Which comes with both DLLs and LIB files). For the lib files I am also setting them as linker inputs, though the TBB package does not come with vs2010 lib files.
I am entering full paths in the Linker settings, such as: "C:\opencv\build\common\tbb\ia32\vc10", where each folder contains DLL files.
The linker is only looking for .lib files, which "point" the executable to the adresses of the functions in the dll. It has nothing to do where your executable will find the DLLs.
You need to have the DLL either in the directory of the exe - this is default search path, and is the simplest solution.
It gets slightly more complicated if you have different versions of DLLs installed which require side-by-side configuration. Then you need a manifest which tells your exe where to look for the dlls. Then you give the dll to the windows SxS cache.

How to package stand alone exe inside Visual Studio Installer maker?

Im currently using Visual Studio Installer to package my dll program. How to include stand alone executable program inside my installer project? Since my dll is using the exe(s) in order to run.
Note: For my development platform, I already have the exe(s) inside my c:\ directory. So I would like my installer to also copy the exe(s) to c: drive of other user's platform when they run my installer.
Add the required exe during making the installer to the Application Folder.
Then change all the path that points to those required exe(s) so that it points to the exe(s) in the Application Folder. Shown below:
Instead of "C:\directory\file.exe" to Application.StartupPath & "\file.exe"
Application.StartupPath returns the path of the executable file that started the application.
So if you app is installed in "C:\Program Files\MyApp\program.exe" this would return "C:\Program Files\MyApp"
I hope this helps.

Resources