jacklicn / leptonica

Automatically exported from code.google.com/p/leptonica
0 stars 0 forks source link

Warnings (and errors) on Visual Studio 2008 builds of 1.63 #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Perform Debug build of leptonlib using Visual Studio 2008.

What is the expected output? What do you see instead?
I expected to build leptonlib.lib. Instead the build fails with multiple
errors.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.

First of all the solution provided for Visual Studio 2008 couldn't find ANY
of the source files. I "fixed" the problem by directly editing
leptonlib.vcproj:

 Replace all occurences of:  RelativePath=".\
 With: RelativePath=".\src\

Alternatively, you can move the .sln and .vcproj file INTO the src
directory (where it used to be).

---

Since pstdint.h isn't in the src directory, remove it from the Header Files
folder. (As mentioned in README.html 9.d you have to get pstdint.h
elsewhere, I just rename it to stdint.h and copy it into the C:\Program
Files\Microsoft Visual Studio 9.0\VC\include directory.)

---

I added the following compiler flags to turn off more warning messages
(including those previously mentioned in Issue 9):

 /wd4244 /wd4305 /wd4018 /wd4267 /wd4996

This leaves this Warning (which I'm pretty sure is an error):

 warning C4553: '==' : operator has no effect; did you intend '='
leptonlib-1.63\src\grayquant.c  433

This line should be changed from:

        d == 8;

To:

        d = 8;

And these other warning (some of which might be bugs):

 Command line warning D9035 : option 'Wp64' has been deprecated and will be
removed in a future release cl

 warning C4101: 'bigbuf' : unreferenced local variable
leptonlib-1.63\src\psio2.c  291

 warning C4700: uninitialized local variable 'd' used
leptonlib-1.63\src\pixcomp.c    192

 warning C4715: 'pixcompGetDimensions' : not all control paths return
a value     leptonlib-1.63\src\pixcomp.c    332

 warning C4700: uninitialized local variable 'pixt' used 
leptonlib-1.63\src\scale.c  1512    leptonlib

 warning C4028: formal parameter 2 different from declaration
leptonlib-1.63\src\pix1.c   249

And the following Error:

 error C2668: 'sqrt' : ambiguous call to overloaded function
leptonlib-1.63\src\binarize.c   692

Which can be fixed by removing the /TP option (Change "leptonlib Properties
| Advanced | Compile as" from C++ Code to default).

----

To get rid of the various image library include errors add these to
"leptonlib Properties | C/C++ | General | Additional Include Directories"
(assuming you download the appropriate libraries and build them at the same
"level" as leptonlib):

..\zlib;..\libtiff\libtiff;..\libpng;..\libjpeg\include

----

In summary my C/C++ command line for a Debug build looks like:

 /Od /I "..\zlib" /I "..\libtiff\libtiff" /I "..\libpng" /I
"..\libjpeg\include" /D "WIN32" /D "_DEBUG" /D "_LIB" /D "L_LITTLE_ENDIAN"
/D "USE_PSTDINT" /D "snprintf=_snprintf" /D "COMPILER_MSVC=1" /D "XMD_H"
/Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /Wp64
/ZI /showIncludes /errorReport:prompt

With these additional options to turn off warnings:

 /wd4244 /wd4305 /wd4018 /wd4267 /wd4996

For Debug builds I also change "Librarian | General | Output File" from: 

 $(OutDir)\$(ProjectName).lib

to:

 $(OutDir)\$(ProjectName)d.lib

thereby getting leptonlibd.lib as the name of library (so I can distinguish
between Debug and Release builds).

My C/C++ command line for a Release build looks like:

 /I "..\zlib" /I "..\libtiff\libtiff" /I "..\libpng" /I
"..\libjpeg\include" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "L_LITTLE_ENDIAN"
/D "USE_PSTDINT" /D "snprintf=_snprintf" /D "COMPILER_MSVC=1" /D "XMD_H"
/FD /EHsc /MD /Fo"Release\\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Wp64 /Zi
/errorReport:prompt

With these additional options to turn off warnings:

 /wd4244 /wd4305 /wd4018 /wd4267 /wd4996

Original issue reported on code.google.com by tomp2...@gmail.com on 19 Nov 2009 at 3:09

GoogleCodeExporter commented 9 years ago
Thank you very much for this bug report.

I intend to fix this in 1.64 and put it out within two weeks.
The goal, as you say, is to have this build correctly without changes,
assuming, for example, that the three I/O libraries are available for linking.

Are you able to send me your corrected (and working) project file?
Also, are you willing to put together a small "readme" for building on
windows, that I can incorporate into the distribution (with your name,
of course, if you wish)?

Original comment by dan.bloo...@gmail.com on 20 Nov 2009 at 4:36

GoogleCodeExporter commented 9 years ago
When using Visual Studio 2008, the problem isn't really with building 
leptonlib, but
with correctly getting and building the four default library dependencies (zlib,
libpng, libjpeg, and libtiff) and then building one of the programs in the prog
directory. I originally started using leptonlib about a year ago, and figured 
out
(somewhat chaotically) how to do this at that time.

My current .sln and .vcproj files unfortunately reflect some obscure naming and
placement decisions I made back then. Let me revisit this so I can send you a 
cleaner
solution.

Original comment by tomp2...@gmail.com on 20 Nov 2009 at 5:50

GoogleCodeExporter commented 9 years ago
I believe the windows issues are now addressed by Tom's scripts and guide
in 1.64.

Original comment by dan.bloo...@gmail.com on 3 Jan 2010 at 11:24