Where to "install" thirdparty libraries & header files to on Windows? - linux

Where do you store your thirdparty libraries and header files to when developing C/C++ on Windows?
When developing on Linux the package managers usally installs thirdparty libraries to /usr/lib and /usr/include. So I know where to look for.
I am just starting to develop on Windows and made the mistake to install libraries to C:\Program Files which is a bad idea due to UAC and permission lookdown on Windows 10.
Is there some kind of best practice? Thanks in advance

Usually to one of these locations:
Commercial tools might have an installer and if so the location is indeed often Program Files [ (x86) ]
Libraries built from source (for example zlib for compression) go wherever you have your root folder for C++ projects. Using Visual Studio you might have a C: > VS17 folder with one sub-folder for each solution and each partner library. You then reference the H and LIB files using relative paths like ../../other-libraryname/include so that they will work if you move the VS17 library to a new drive or change its name.
In both cases, when building a setup package for deploying to another PC, you typically include only DLL files and code statically linked into your own EXE, you don't include H or LIB files. The default installation location for the setup will be Program Files, but if your third-party library includes COM objects they might recommend installing them to the Windows system32 folder.

Related

OpenCV and CMake in Windows7: wrong include dir

I built my own OpenCV-2.4.10 libs for Windows 7 mingw:
1) download opencv-2.4.10 for Windows to f:\opencv-2.4.10\
2) cmake f:\opencv-2.4.10\source to f:\opencv-2.4.10\build\x86\mingw
3) generate f:\opencv-2.4.10\build\x86\mingw
4) mingw32-make f:\opencv-2.4.10\build\x86\mingw
When I create an eclipse project, I set the include dir to f:\opencv-2.4.10\build\include and lib dir to f:\opencv-2.4.10\build\x86\mingw\bin
Everything works fine. Now I want to process the same project on Windows and Ubuntu and I created a CMake project for this. Under Windows I can cmake my project but I can't compile because the include files can't be find. I found out, that in my CMake project the include dir is set to f:\opencv-2.4.10\source\include and not to f:\opencv-2.4.10\build\include, that has another directory structure.
Under Ubuntu the project is compiled and works. So I'm pretty sure, that the problem is with my OpenCV installation on Windows. What did I do wrong, since this is the proposed procedure by the opencv documentation?
f:\opencv-2.4.10\build\include
this holds the header files you want to include, it shouldn't matter if you are on windows or on Ubuntu

Creating executable for Qt projects

I have a Qt application that run on Linux. I want to have its executable such that it can operate on Windows too without Qt being installed. I have seen the older posts too regarding this but couldn't understand them. Please guide me step by step to create executable file.
I have placed all the necessary dlls alongside and was successful to run the executable. But to run it I need to go inside the folder and than do that.
How can I wrap my application, such that user has the set up for that, he installs it and then run that (usually we have for the S/ws). How can I do this for the Qt application?
Download the setup for Qt for Windows with MinGW compiler here.
Once you install Qt IDE on a Windows machine, make necessary changes to your project's .pro file and build your application.
Now copy the executable you created into a different folder and run a dependency check on it. You can use Dependency Walker which you can download from here. Copy the dlls shown in the Dependency walker and place it next to your application. You will find the required dlls in the Qt's bin folder in the installation directory. Path might be something like C:\Qt\Qt\\mingw\bin. You will also need to copy the gcc and mingw dlls into your application directory.
Next you will have to copy the required plugins into your application directory. You will need the platforms plugins, iconengines and imageformats if you are using icons, sqldrivers if your application connects to a database. Copy the directories of the required plugins into your application folder.
Once you copy all required libraries, you should be able to open the application. You can now distribute your application along with all these dynamic link libraries and plugins.
For more details you can refer this link.
You should place Qt DLLs along the release version of your executable. These are Qt5Core.dll, Qt5Gui.dll, Qt5Widgets.dll and possibly the ones for other modules that you have used. These dll files are in your installed Qt Directory in bin folder.
You should also place msvcr100.dll and msvcp100.dll in case you are using MSVS2010.
If you are using MinGW, place MINGWM10.DLL, LIBGCC_S_DW2-1.dll and LIBSTDC++-6.dll alongside the executable.
If you are using plugins you should place their dll in a folder named plugins beside your exe. In case of using icons and images you should ship their dlls like qico.dll and qsvg.dll in a folder named imageformats.
You should also put qwindows.dll in a folder named platforms alongside the executable.

What kind of libraries should my program install as system libraries?

I am building an audio processing application in Qt and an installer through Inno Setup. Recently, a co-worker testing the application had difficulty running it because "VCOMP100.DLL" was missing. We had been through a few versions already and had not gotten the error, but I will include it in the installer anyways. However, my version of vcomp100.dll was in my system files - did that mean I should install it there? And so I wondered:
What kinds of libraries should my installer try to install in the system directory? On one hand, duplicated data is wasted data, but on the other hand, I'm nervous about messing with system files. I have ~5 types of libraries:
Very basic C/C++ runtime libraries (msvcp100, msvcr100)
Unicode support libraries (icudt51, icuin51, icuuc51)
OpenGL as part of Qt (libEGL, libGLESv2)
Qt-specific libraries (Qt5Core, Qt5Gui, Qt5Widgets)
Sound processing libraries (soxr, libsndfile, portaudio)
Can you explain what to install where, but more importantly, why?
Do not install these files directly.
Use bundled installers from companies which produce that libraries.
For example instead of copying msvcp100, msvcr100 use Microsoft Visual C++ 2010 Redistributable Package (x86 or 64bit: http://www.microsoft.com/en-us/download/details.aspx?id=5555) to install VC++ runtime files.
There may be another dependencies in your libraries and this package install everything required.
The installers can be run silently and it is more user friendly. If the runtime is already installed there is no problem if it is overwritten.
Check these topics for more info:
How to make vcredist_x86 reinstall only if not yet installed?
InnoSetup - Check if visual studio 2010 crt redist is installed, if not then run installer
I suppose this should be the same for Qt.

InstallShield installs to SysWOW64 and not in System32

I'm creating a InstallShield 2012 Spring project, and I need to copy some jpg into System32 subfolder.
In Application Data/Files and Folders, I put that into [WindowsFolder]/System32/akrmf and when install, it copies to SysWOW64/akrmf on Windows 7
The installation project doesn't include any exe or dll, only text files and images.
I tried using [SystemFolder] and copies into SysWOW64 too.
Is there any way to force installation into System32/akrmf folder ?
Thanks
To target the true (64-bit) system folder with Windows Installer, your MSI needs to be a 64-bit package (see Targeting 64-bit Operating Systems). Unfortunately this prevents it from installing on 32-bit systems.
To do this with InstallScript, there are related approaches that do not require creating two separate packages, but you may find it easiest to create two different components where only one is selected for installation.

Independent qt application and dependency packing in windows and linux

I made an application for Linux using QtCreator. The application uses two external libraries, qextserialport and qwt. I want to deploy the app such that all libraries it depends on are deployed alongside the executable file.
When I made an application for Windows I just copied the .dll files into the app.exe folder, and it works. But how do I do this on Linux?
In Linux you can:
1) static-link the dependencies
or
2) pack dependencies windows-style and set environment variable LD_LIBRARY_PATH pointing to the subdirectory containing the dynamic libraries
[updated]
read man ld, may be you will have to compile static versions of the libraries if they are not compiled by default (look at this tutorial if you can't tell the difference).
Great comment by synthesizerpatel, if the library uses autoconf (a lot of linux software do), it has options like --enable-shared and --enable-static.

Resources