Monday, 18 July 2016

Installing libcurl to visual studio 2015 project for x64 machine

1. Download libcurl zip file from this link : https://curl.haxx.se/download.html

2. Unzip to some location say F drive  "F:\"

3. Open visual studio 2015 project

4. Choose the configuration Release or Debug whatever you want to build.

Adding Visual Studio Command Prompt

5. Open Visual Studio Command prompt if you don't have this follow these steps
1. In your visual studio project go to Tools-> External tools
2. fill the values required like this:
1. Title   : VS Command Prompt   //note:you can give any name
2. Command : C:\Windows\System32\cmd.exe
3. Arguments : /k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
4. Initial Directory : click the arrow in front and choose Project Directory
3. Then click OK or Apply.
4. After this go to Tools and you will be able to see your tool in the list above External Tools open it.check it should not give any error and should start with your
 project Directory location.

6. At the command prompt, change to the Visual C++ installation directory. 
  (The location depends on the system and the Visual Studio installation, but a typical location is C:\Program Files (x86)\Microsoft Visual Studio version\VC\.) 
For example, enter:
cd "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
Now cmd prompt should be in this folder.

To configure this Command Prompt window for 64-bit x64 command-line builds, at the command prompt, enter:
vcvarsall x64

7. Now in command prompt goto winbuild directory in the unzipped folder for example:
cd "F:\curl-7.49.1\curl-7.49.1\winbuild"
kindly use your directory here this is just for example

Adding nmake to command prompt

8. Give command :
nmake
to check whether it is recognised as a command it should print somethig like this:
Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
Copyright (C) Microsoft Corporation.  All rights reserved.

NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
it shows nmake is present and if it says:
'nmake' is not recognized as an internal or external command,
operable program or batch file.

Then to add nmake follow these steps:
1. For visual studio 2015 community edition add the following path to your system environment path
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
 in the above path there is the nmake command
How to set enviroment path?
1. Press windows key on keyboard and type "edit the system environment variables" and click on it
2. On the window click "Environment Variables".
3. In the system variables click path then click on edit.
4. Click on new and paste this C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

Generating dll and lib files

9. Now for debug build give cmd:
nmake /f Makefile.vc mode=dll VC=14.0 DEBUG=yes MACHINE=x64
   for release build give cmd:
nmake /f Makefile.vc mode=dll DEBUG=no MACHINE=x64
   
   This commands should not give any error like fatal error etc. To know more about this options(DEBUG, VC, MACHINE etc) or play around with this options search for nmake
   cmd in file at path "F:\curl-7.49.1\curl-7.49.1\winbuild\BUILD.WINDOWS.txt" this is my local path search for yours.

10. This will create some folders at location : 
F:\curl-7.49.1\curl-7.49.1\builds
   for Debug build:
1. There will be a folder named "libcurl-vc14.0-x64-debug-dll-ipv6-sspi-winssl"
2. It will have three folders bin, include and lib.
3. Open bin and check it should have libcurl_debug.dll.
4. Open lib and check it should have libcurl_debug.lib.
5. If these two things are not there something went wrong.
   for Release build :
1. There will be a folder named "libcurl-vc-X64-release-dll-ipv6-sspi-winssl"
2. It will have three folders bin, include and lib.
3. Open bin and check it should have libcurl.dll.
4. Open lib and check it should have libcurl.lib.
5. If these two things are not there something went wrong. 

Project settings

11. Now open your visual studio project goto Project then to properties of your project at the end.
1. In configuartion properties -> VC++ Directories -> General -> select Include directories then click on down arrow click on edit,
 double click in the top box and then click on ... box and browse to the location of above mentioned include folder and click ok.
2. In configuartion properties -> VC++ Directories -> General -> select Library Directories then click on down arrow click on edit,
 double click in the top box and then click on ... box and browse to the location of above mentioned lib folder and click ok.
3. In configuartion properties -> Linker -> Input -> select Additional Dependencies then click on down arrow click on edit,
 and in the top box at the end add add full path to the above mentioned libcurl.lib file (libcurl_debug.lib for debug) with in double quotes.
4. Then click Ok and apply this properties and come out of property page.

12. Now copy the above mentioned libcurl.dll (libcurl_debug.dll for debug) and paste in the location where your exe file is present.

13. That's all now you should be able to compile build and Run your project with libcurl installed.

14. In configuartion properties -> C/C++ -> Code Generation -> Runtime Library check whether its multi threaded DLL . I am not sure about this but libcurl needs
    multithreaded option.

15. For x86 machine use x86 in place of x64 in the above process .. I haven't verified this.

Sunday, 10 April 2016

SPOJ "The Bulk" Hint

Basic Steps :

1. Remove faces non perpendicular to Z axis
2. Remove Unnecessary Points from all faces
3. Sort faces on the basis of height along Z axis
4. Assign sign to each face whether it contributes positive volumes or negative volume
5. Find Area of each face
6. volume contributed by each face = sign*height along Z axis*area
7. Answer is sum of volume contributed by each face.

1. Remove faces non perpendicular to Z axis

we need only faces which are perpendicular to a particular axis lets take it as z axis since if you know all faces of a cube perpendicular to z axis then you can predict the other faces so that is just an extra information.


2. Remove Unnecessary Points from all faces


If there are three points (x1,y,z),(x2,y,z) and (x3,y,z) given in order as shown in fig. then x2 is an unnecessary point removing that point will still result in the same line so remove such points. Similarly apply for y as shown in fig.


3. Sort faces on the basis of height along Z axis

Now to find empty cubes we need to decide the sign of faces . if the volume below some face is empty its sign is negative. Now to decide which face is below which face we have to short faces on the basis of there heights along z axis.


4. Assign sign to each face whether it contributes positive volumes or negative volume

Now to decide sign of a face its sign would be opposite to that of one above it. Since we have already sorted the faces start with the top face giving it a positive sign. Now for each face find a face above it which covers it or in other words overlaps it and give it a sign opposite to that face. Now to find such face for each face steps are
1. Among the points with highest Y value in a face find one with least x value let this                              point be (X,Y,Z).
2. Now for each face above it starting from the one just above it in terms of height with respect                to Z axis find the no of horizontal lines(parallel to x axis) passing through the  point(X,y,Z)                  such that y >= Y.
 3. If the count is odd it means the face is covering current face .
4. Give current face opposite sign of this face and move to next face


5. Find Area of each face

To find area of a face using co-ordinates (xi,yi) iterate over cordinates .Take the point (x1,y1) and next point (x2,y2) and add up to the answer (x1*y2 - y1*x2).do it for all the points and (sum/2) is the area of face.


6. volume contributed by each face = sign*height along Z axis*area


7. Answer is sum of volume contributed by each face.



To get the c++ code for reference request me for the same via my email prince.ranawat@gmail.com i will share link to my code with you.

Sunday, 30 August 2015

memory card corrupted

Mobile gives an error that memory card is corrupted and format the card....


Steps::
* Get a memory card reader and put it on your computer.
* Get the drive letter for the card it will be like "Removable drive (X):" in my computer
* Type in command prompt " chkdsk /r X: "   replace X with your drive letter.


Sunday, 19 April 2015

g++.exe has stopped working?

solving it for windows 8 dev c++ without installing new version of dev c++.

steps

1. Goto tools -- compiler option -- programs
2. make following changes:
    gcc.exe  to mingw32-gcc.exe
    g++.exe to c++.exe
    make.exe to mingw32-make.exe