Compile libupnp on windows - c++

I'm trying to compile libupnp-1.6.17 on windows with VS2008, but hundreds syntax errors occured. I download source code from http://sourceforge.net/projects/pupnp/
anyone tell me how to compile libupnp on windows?

WINDOWS BUILD
In order to build libupnp under Windows the pthreads-w32 package is required.
You can download a self-extracting ZIP file from the following location:
ftp://sources.redhat.com/pub/pthreads-win32/pthreads-w32-2-7-0-release.exe
or possibly newer versions if available.
Execute the self-extracting archive and copy the Pre-build.2 folder to the
top level source folder.
Rename Pre-build.2 to pthreads.
Open the provided workspace build\libupnp.dsw with Visual C++ 6.0 and select
Build->Build libupnp.dll (F7)
In the build directory there are also VC8, VC9 and VC10 folders containing
solution files for Visual Studio 2005/2008/2010 respectively.
If you use newer versions to build libupnp, eg Visual Studio 2003 or later,
then you need to rebuild the pthreads package so it uses the same VC runtime
as libupnp to prevent cross boundary runtime problems
(see http://msdn.microsoft.com/en-us/library/ms235460%28v=VS.100%29.aspx).
Just replace the files in the Pre-build.2 folder (renamed to pthreads as
mentioned above) with the newly build versions.
If you also use a newer version of pthreads-win32 then you should also
replace the header files in that directory structure (obviously).
For building a static library instead of a DLL and for using the static
pthreads-w32 library following switches need to be defined additionally:
UPNP_STATIC_LIB - for creating a statically linkable UPnP-library
PTW32_STATIC_LIB - for using the static pthreads32 library

Related

What files are necessary for clang to function?

I have built clang from source on windows using visual studio 2022. My configuration is MinSizeRel and my platform is x64. I am trying to cut down clang so it is functional but does not take up much storage.
Firstly, after building it, there are two folders, bin and lib. Is the lib folder necessary? Can I remove it with no consequences?
Secondly, I am using clang for only C++ so are there any files I can remove from the bin folder? clang-cl.exe seems pretty useless for C++.

How to link opencv and other dll files to output exe of visual studio 2013

I am new with visual studio, opencv.
I am using visual studio 2013, opencv and c++ for my project.
I configured (copied path) the opencv and other library to my computer environment system.
After run the project in visual studio, normally, there will be an exe file in the project.
I can copy the exe file in the project folder and copy to other place in my computer and it will run normally.
This is because my computer environment systems are configured with opencv and other library.
I want to do the same thing with other computers BUT I do not want to manually configure each computer with opencv and other libraries.
Are there any ways that I can do to link everythings all in exe file after run the project in visual studio 2013 so that I can run the exe without depend on the path of libaries and opencv?
EDITED
I use opencv installer opencv2.4.7.exe
In the current VS2013 my project, i configured my project and opencv installer as this link
http://www.anlak.com/using-opencv-2-4-x-with-visual-studio-2010-tutorial/
question : Can i use the library in folder C:\opencv\build\x64\vc11\staticlib come from the opencv installer no need create my own library from source opencv?
question : In case i need to generate new library from opencv source (http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html) or use lib in static folder of opencv installer, if i want to include it all to exe files, do i need to create new project and reconfigure?
Thank you.
First you need to rebuild openCV to generate static libraries instead of dynamically linked ones. This way all code that your application uses is thrown together in one single exe-file (which will probably be significantly bigger). This exe-file you can move to other computers and they should still work there, provided they have an architecture that is at least compatible with yours. So if you build it on an x86 perconal computer (32-bit), it should basically work on any other personal computer. If you build it on a x64 computer (AMD 64-bit), it will only run on other x64 machines. At least this is true assuming both systems use the same syscall API (Windows NT, POSIX...).
For openCV you do this by setting the BUILD_SHARED_LIBS build flag to false (see OpenCV as a static library (cmake options), the following line is taken from there):
cmake -DBUILD_SHARED_LIBS=OFF ..
Once you have done this, you will see that the openCV folder looks very similar to the one you have now, except that in your 'lib' folder there will now be .lib-files instead of .dll files (at least if you are working on Windows, which I assume you do since you are using Visual Studio).
Next step is to go to your project settings and set your linker to link with the static libraries instead of the dynamically ones. If you have used openCV's local method for linking, you can go to project settings -> linker -> input -> Addtional dependencies. There you change the extension of all the openCV libraries from .dll to .lib.
Now you should be able to rebuild your application and the resulting exe-file should have all dependent libraries contained in it.

Visual Studio - find out why Visual Studio tries to link to class X? [duplicate]

This is what I have done:
Download the 1.54 zip file from the boost website
Extracted/copied it to C:\Program Files (x86)\Boost
Inside Visual Studio I have set the include libraries to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\
(This seems to work fine for getting the compiler to accept the libraries)
Now the bit i'm having problems with- linker:
Inside Visual Studio I have set the linker include directories to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\libs\
When I compile my project I get:
fatal error LNK1104: cannot open file 'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT Have built the boost binaries using the answer below. However I now have these files:
libboost_date_time-vc110-1_54.lib
libboost_date_time-vc110-gd-1_54.lib
libboost_date_time-vc110-mt-1_54.lib
libboost_date_time-vc110-mt-gd-1_54.lib
libboost_date_time-vc110-mt-s-1_54.lib
libboost_date_time-vc110-mt-sgd-1_54.lib
libboost_date_time-vc110-s-1_54.lib
libboost_date_time-vc110-sgd-1_54.lib
but still no
'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT: Think I have found the problem:
http://lists.boost.org/Archives/boost/2004/08/70114.php
OK, here's the problem: originally we had one Intel toolset:
"intel-win32" which created the library suffix "iw" (note no version
number!), and this is what the auto-link header currently searches
for.
However people have started adding versioned Intel toolsets, which
means that we now produce an ad-hoc mixture of library names, some
with compiler-version suffixes and some without, the autolink code
could handle either form, but as it's not psychic it can't handle
both :-(
Solution is to #define BOOST_ALL_NO_LIB
On a 64bit system you should build boost in Program Files, not Program Files(x86) the boost automatic library include does not handle the redirection correctly. Alternatively you can manually manage the library inclusion... but I would highly recommend against it.
Also a reminder that you need to build boost in all the flavors and bitnesses you are going to use. See How to use Boost in Visual Studio 2010 for a good example of how to do so.
In an administrator visual studio command prompt go to the boost directory
run bootstrap.bat
run b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64
wait for b2 to finish building
EDIT:
As it turns out the iw in that library refers to the intel compiler... to use that with boost and visual studio you'll need to follow the directions from Intel.

How do I install Crypto++ in Visual Studio 2010?

I downloaded http://www.cryptopp.com/#download 5.6.1 and have no clue that to do at this point. I am a total noob and need good instructions. thanks.
Directly from the readme (Which can be found here Crypto++ Svn Trunk):
* MSVC-Specific Information *
On Windows, Crypto++ can be compiled into 3 forms: a static library including all algorithms, a DLL with only FIPS Approved algorithms, and a static library with only algorithms not in the DLL. (FIPS Approved means Approved according to the FIPS 140-2 standard.) The DLL may be used by itself, or it may be used together with the second form of the static library. MSVC project files are included to build all three forms, and sample applications using each of the three forms are also included.
To compile Crypto++ with MSVC, open the "cryptest.dsw" (for MSVC 6 and MSVC .NET 2003) or "cryptest.sln" (for MSVC 2005 - 2010) workspace file and build one or more of the following projects:
cryptopp - This builds the DLL. Please note that if you wish to use Crypto++ as a FIPS validated module, you must use a pre-built DLL that has undergone the FIPS validation process instead of building your own.
dlltest - This builds a sample application that only uses the DLL.
cryptest Non-DLL-Import Configuration - This builds the full static library along with a full test driver.
cryptest DLL-Import Configuration - This builds a static library containing only algorithms not in the DLL, along with a full test driver that uses both the DLL and the static library.
To use the Crypto++ DLL in your application, #include "dll.h" before including any other Crypto++ header files, and place the DLL in the same directory as your .exe file. dll.h includes the line #pragma comment(lib, "cryptopp") so you don't have to explicitly list the import library in your project settings.
To use a static library form of Crypto++, make the "cryptlib" project a dependency of your application project, or specify it as an additional library to link with in your project settings. In either case you should check the compiler options to make sure that the library and your application are using the same C++
run-time libraries and calling conventions.
If you have any questions feel free to ask and i'll update the anwser with my responses.
I downloaded http://www.cryptopp.com/#download 5.6.1 and have no clue what to do at this point...
This is a very late answer, but the project has released some new files to help folks use Visual Studio 2010 and above.
The project had to release the updated files because VCUpgrade (provided with Visual Studio 2010) does a fairly poor job with this particular project. It has been a source of problems for a few years, and even visually impaired users were commenting about it. The problems were not fixed in VS2012, VS2013 and VS2015, so we don't believe Microsoft has any intentions of fixing the problems.
To use the updated files, download the latest Crypto++ release from the website. Then, visit the Crypto++ wiki and fetch vs2010.zip from the page Visual Studio. Unzip vs2010.zip over the Crypto++ files. Finally double-click the file called cryptest.sln to have Visual Studio open the solution file.
The Crypto++ wiki page also offers project files that provide dynamic runtime linking for both VS2005 and VS2010.
If you convert cryptest.sln from VS2005 to VS2010, you will meet a problem. When you compile source code, the compiler will show an error:
c1xx : fatal error C1027: Inconsistent values for /Ym between creation and use of precompiled header
You can resolve this problem by:
Going to Project Properties --> Configuration Properties --> C/C++ --> Precompiled Headers
Changing it to "Not Using Precompiled Headers"
You'll need to compile the library before using it with anything. You can't just install it. Here is a page from their wiki about compiling the library: http://www.cryptopp.com/wiki/Compiling

Windows Build System: How to build a project (from its source code) which doesn't have *.sln or Visual C++ proj file (*.vcproj)

I'm facing this problem. So, I need to build the support libraries (zlib, libtiff, libpng, libxml2, libiconv) with "Multithreaded DLL" (/MD) & "Multithreaded DLL Debug" (/MDd) run-time options. But the problem is there is no direct way . I mean there is no *.sln / *.vcproj file which I can open in Visual C++ and build it.
I'm aware with the GNU build system:
$./configure --with-all-sorts-of-required-switches
$./make
$./make install
During my search I've encountered with something called CMake which generates *.vcproj & *.sln file but for that CMakeLists.txt is required. Not all projects provide CMakeLists.txt.
I've never compiled anything from Visual C++ Command Line.
Generally most projects provide makefile. Now how do I generate *.vcproj / *.sln from this?
Can I compile with mingw-make of MinGW?
If I can, how do I set different options ("Multi-Threaded"(/MT), "Multi-Threaded Debug"(/MTd), "Multi-Threaded DLL"(/MD), "Multi-Threaded DLL Debug"(/MDd)) for run-time libraries?
I don't know what other ways are available. Please throw some light on this.
I believe all those projects include a .vcproj file (open/build in VC) and/or VC makefile (build with nmake).
You can just create a new project in Visual Studio and add the existing .cpp files to it.
Note that for several of the GNU libraries you've mentioned, you might have difficulty getting them to build on Microsoft Visual Studio's compiler, because as far as I know they are not shy about using GCC extensions in such programs.
Most projects work, when you create an empty Win32 project and drag all files into that.
Then change the output paths and maybe click throught several options.
You can create wrapper scripts for the compiler+linker to call the VC compiler and give them to configure by ./configure CC=my-visual-c-script CXX=my-visual-c++-script. I hacked the compile script distributed with automake to do this thing. Note that automake calls the compiler also to link, so the wrapper must decide if it must call the compiler or the linker.