VOGONS


First post, by thecrankyhermit

User metadata
Rank Member
Rank
Member

I'm just trying to play around with the source code, nothing serious. This is mainly a case of satisfying my OCD intolerance for imperfections. Everything runs fine if I set:
#define C_SSHOT 0
or if I just don't try to take snapshots.

I am building from stable 0.74 code, using Visual Studio 2008. I am linking with all of the libraries except for curses. I got libpng.lib and zlib.lib from the GnuWin32 as stated in the INSTALL file.

The Zlib paragraph says:
For win32 get libz (rename to zlib) from http://gnuwin32.sourceforge.net/packages.html

However, there is no "libz" there, just a "zlib," which I got.

I got it to compile, but if I try to run it, it needs "libpng12.dll" and "zlib1.dll." I don't understand why, because the official version doesn't need them, and it works with screenshots just fine. But I get these files too, from the same place, and put them with the DOSBox executable.

Next, I build it in debug mode. I run it, and it works fine. If I press CTRL+F5 to take a snapshot, a 0-byte png file is created.

Release mode also builds and runs fine. But if I press CTRL+F5 to take a snapshot, it simply crashes with an unhandled exception.

How can I find out what is going wrong?

I found that in hardware.cpp, this line:
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,NULL, NULL);

seems to be where things start to go wrong. If I set a breakpoint there, this is the last line of code I can step through before the Release build crashes. And in debug mode, it returns a null pointer.

Running:
Windows 10
Core i5-6600
Geforce GTX 970
8GB RAM

Reply 1 of 9, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I don't understand why, because the official version doesn't need them

static linking vs. dynamic linking (the latter -> dll)

If you have fun try building zlib and libpng from source using vs2008,
should work fine and you can select the type of library that's compiled.

Reply 2 of 9, by frobme

User metadata
Rank Member
Rank
Member

I got it to compile, but if I try to run it, it needs "libpng12.dll" and "zlib1.dll."

The official PNG and ZLIB sources have issues like this when compiling with the Visual Studio projects and have for some time. It's a straight out bug, which I reported upstream long ago, but not many people use the VS projects apparently, or they just fix it and move on. But for what it's worth, it's not you =).

I statically link everything (or I did under VS2008, I use 2010 now).

-Frob

Reply 3 of 9, by thecrankyhermit

User metadata
Rank Member
Rank
Member

I'm having some trouble with this static linking thing. Here's what I've done:

I've taken the zlib.lib and libpng.lib out of the linker dependencies.

I've installed the zlib and libpng source. In the dosbox solution, I've added these projects:
gnu32\src\libpng\1.2.37\libpng-1.2.37-src\projects\visualc71\libpng.vcproj
and
gnu32\src\zlib\1.2.3\zlib\contrib\vstudio\vc8\zlibstat.vcproj

And I've changed the include directories so that dosbox includes the source files I just installed.

Then I right-click dosbox project, Project Dependencies, and check off both libpng and zlibstat. I change libpng to a static library configuration.

Then I build. libpng and zlibstat both build fine. But dosbox has these linker errors:

1>Linking...
1>dosbox.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>hardware.obj : error LNK2019: unresolved external symbol _deflateInit_ referenced in function "public: bool __thiscall VideoCodec::SetupCompress(int,int)" (?SetupCompress@VideoCodec@@QAE_NHH@Z)
1>hardware.obj : error LNK2019: unresolved external symbol _inflateInit_ referenced in function "public: bool __thiscall VideoCodec::SetupDecompress(int,int)" (?SetupDecompress@VideoCodec@@QAE_NHH@Z)
1>hardware.obj : error LNK2019: unresolved external symbol _deflateReset referenced in function "public: bool __thiscall VideoCodec::PrepareCompressFrame(int,enum zmbv_format_t,char *,void *,int)" (?PrepareCompressFrame@VideoCodec@@QAE_NHW4zmbv_format_t@@PADPAXH@Z)
1>libpngd.lib(pngwutil.obj) : error LNK2001: unresolved external symbol _deflateReset
1>hardware.obj : error LNK2019: unresolved external symbol _deflate referenced in function "public: int __thiscall VideoCodec::FinishCompressFrame(void)" (?FinishCompressFrame@VideoCodec@@QAEHXZ)
1>libpngd.lib(pngwrite.obj) : error LNK2001: unresolved external symbol _deflate
1>libpngd.lib(pngwutil.obj) : error LNK2001: unresolved external symbol _deflate
1>hardware.obj : error LNK2019: unresolved external symbol _inflate referenced in function "public: bool __thiscall VideoCodec::DecompressFrame(void *,int)" (?DecompressFrame@VideoCodec@@QAE_NPAXH@Z)
1>hardware.obj : error LNK2019: unresolved external symbol _inflateReset referenced in function "public: bool __thiscall VideoCodec::DecompressFrame(void *,int)" (?DecompressFrame@VideoCodec@@QAE_NPAXH@Z)
1>libpngd.lib(png.obj) : error LNK2001: unresolved external symbol _inflateReset
1>libpngd.lib(pngwrite.obj) : error LNK2019: unresolved external symbol _deflateEnd referenced in function _png_write_destroy
1>libpngd.lib(png.obj) : error LNK2019: unresolved external symbol _crc32 referenced in function _png_reset_crc
1>libpngd.lib(pngwutil.obj) : error LNK2019: unresolved external symbol _deflateInit2_ referenced in function _png_write_IHDR
1>.\Debug/dosbox.exe : fatal error LNK1120: 9 unresolved externals

Edit - I wound up just adding the zlib c files to the dosbox project. Not the cleanest solution, but it seems to build a functional exe. I'm satisfied, unless there's a reason I shouldn't be.

Though I also noticed that my release executable is a good deal smaller than the official one - 2.06 MB vs 3.55 MB. VC isn't exactly known for producing lean code, so I'm kind of curious about what causes the size discrepancy. Does omitting curses alone account for the 1.53 MB?

Running:
Windows 10
Core i5-6600
Geforce GTX 970
8GB RAM

Reply 4 of 9, by orynider

User metadata
Rank Newbie
Rank
Newbie

I get 7 errors and 0 warnings, with unresolved externals:

Error	1	error LNK2019: unresolved external symbol _deflateInit_ referenced in function "public: bool __thiscall VideoCodec::SetupCompress(int,int)" (?SetupCompress@VideoCodec@@QAE_NHH@Z)	hardware.obj

Reply 5 of 9, by bloodbat

User metadata
Rank Oldbie
Rank
Oldbie

Don't remove the .libs from the additional dependencies tree; point the include dirs to wherever you have the libs. Header files and you'll also need to point the library dirs to wherever those libraries compiled. The size discrepancies, among other things, could amount to the fact that you're not linking statically to msvcrtxxx.dll (the x's being whatever version you're using). Also, the official build probably has support for some things you don't, also statically linked; optimizations (incluiding size vs speed) could also have something to do.

thecrankyhermit wrote:
I'm having some trouble with this static linking thing. Here's what I've done: […]
Show full quote

I'm having some trouble with this static linking thing. Here's what I've done:

I've taken the zlib.lib and libpng.lib out of the linker dependencies.

I've installed the zlib and libpng source. In the dosbox solution, I've added these projects:
gnu32\src\libpng\1.2.37\libpng-1.2.37-src\projects\visualc71\libpng.vcproj
and
gnu32\src\zlib\1.2.3\zlib\contrib\vstudio\vc8\zlibstat.vcproj

And I've changed the include directories so that dosbox includes the source files I just installed.

Then I right-click dosbox project, Project Dependencies, and check off both libpng and zlibstat. I change libpng to a static library configuration.

Then I build. libpng and zlibstat both build fine. But dosbox has these linker errors:

1>Linking...
1>dosbox.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>hardware.obj : error LNK2019: unresolved external symbol _deflateInit_ referenced in function "public: bool __thiscall VideoCodec::SetupCompress(int,int)" (?SetupCompress@VideoCodec@@QAE_NHH@Z)
1>hardware.obj : error LNK2019: unresolved external symbol _inflateInit_ referenced in function "public: bool __thiscall VideoCodec::SetupDecompress(int,int)" (?SetupDecompress@VideoCodec@@QAE_NHH@Z)
1>hardware.obj : error LNK2019: unresolved external symbol _deflateReset referenced in function "public: bool __thiscall VideoCodec::PrepareCompressFrame(int,enum zmbv_format_t,char *,void *,int)" (?PrepareCompressFrame@VideoCodec@@QAE_NHW4zmbv_format_t@@PADPAXH@Z)
1>libpngd.lib(pngwutil.obj) : error LNK2001: unresolved external symbol _deflateReset
1>hardware.obj : error LNK2019: unresolved external symbol _deflate referenced in function "public: int __thiscall VideoCodec::FinishCompressFrame(void)" (?FinishCompressFrame@VideoCodec@@QAEHXZ)
1>libpngd.lib(pngwrite.obj) : error LNK2001: unresolved external symbol _deflate
1>libpngd.lib(pngwutil.obj) : error LNK2001: unresolved external symbol _deflate
1>hardware.obj : error LNK2019: unresolved external symbol _inflate referenced in function "public: bool __thiscall VideoCodec::DecompressFrame(void *,int)" (?DecompressFrame@VideoCodec@@QAE_NPAXH@Z)
1>hardware.obj : error LNK2019: unresolved external symbol _inflateReset referenced in function "public: bool __thiscall VideoCodec::DecompressFrame(void *,int)" (?DecompressFrame@VideoCodec@@QAE_NPAXH@Z)
1>libpngd.lib(png.obj) : error LNK2001: unresolved external symbol _inflateReset
1>libpngd.lib(pngwrite.obj) : error LNK2019: unresolved external symbol _deflateEnd referenced in function _png_write_destroy
1>libpngd.lib(png.obj) : error LNK2019: unresolved external symbol _crc32 referenced in function _png_reset_crc
1>libpngd.lib(pngwutil.obj) : error LNK2019: unresolved external symbol _deflateInit2_ referenced in function _png_write_IHDR
1>.\Debug/dosbox.exe : fatal error LNK1120: 9 unresolved externals

Edit - I wound up just adding the zlib c files to the dosbox project. Not the cleanest solution, but it seems to build a functional exe. I'm satisfied, unless there's a reason I shouldn't be.

Though I also noticed that my release executable is a good deal smaller than the official one - 2.06 MB vs 3.55 MB. VC isn't exactly known for producing lean code, so I'm kind of curious about what causes the size discrepancy. Does omitting curses alone account for the 1.53 MB?

Reply 6 of 9, by orynider

User metadata
Rank Newbie
Rank
Newbie

1. I made a little refresh to the libraries that I already hade on my hard drive for other projects like VSFilter, etc., so that I can compile the latest versions of DosBox source in VS 7.1 with no need of any fixing or teaking on code by myself at this moment.

I downloaded libpng 1.4.8 + 1.5.4 and zlib 1.2.5 from http://sourceforge.net/projects/libpng/.

2. I set the enviroment variables --
* for include to:
C:\Public\PSDKR2\Include\.;C:\public\PSDK\Include\.;C:\Public\vs71\SDK\v1.1\include\;c:\prog\VS7\SDK\v1.1\include\
* for lib to:
C:\Public\PSDKR2\Lib\.;C:\public\PSDK\Lib\.;C:\Public\vs71\SDK\v1.1\Lib\;c:\prog\VS7\SDK\v1.1\Lib\

3. In VS 2003 I added:
* for include to:
c:\Public\DxSdk\Include\; E:\prog\User\SDL_net-1.2.7-VC6\include\; E:\prog\User\SDL-1.2.13-VC6\include\; e:\prog\User\libpng\zlib\; E:\prog\User\curses\
*for lib to: c:\Public\98DDK\lib\; c:\Public\DxSdk\Lib\; E:\prog\User\SDL_net-1.2.7-VC6\lib\; E:\prog\User\SDL-1.2.13-VC6\lib\; e:\prog\User\libpng\1.4.8\lib\; E:\prog\User\curses\

4. First I made a try to build with libpng\1.5.4\ and build with some warnings.
Then I opened prog\User\libpng\1.4.8\projects\visualc6\libpng.dsw in VS71 DevEnv.
A new fresh solution file was generated with corecponding *.vcproj and for zlib in prog\User\libpng\zlib\projects\visualc6\ 😀
Build log was saved at "file://e:\prog\User\libpng\1.4.8\projects\visualc6\Win32_LIB_Release\BuildLog.htm"
pngtest - 0 error(s), 0 warning(s)
http://pubory.uv.ro/pub/dosbox/compilelogs/li … se/buildlog.htm
Build log was saved at "file://e:\prog\User\libpng\1.4.8\projects\visualc6\Win32_DLL_Release\BuildLog.htm"
pngtest - 0 error(s), 0 warning(s)
http://pubory.uv.ro/pub/dosbox/compilelogs/li … se/buildlog.htm
Then I run one command to copy the library files that I need later:
copy \prog\User\libpng\1.4.8\projects\visualc6\Win32_DLL_Release\ libpng14.* \prog\User\libpng\1.4.8\lib\
copy \prog\User\libpng\1.4.8\projects\visualc6\Win32_LIB_Release\libpng.lib \prog\User\libpng\1.4.8\lib\

5. I did a fresh SVN Checkout in <https://dosbox.svn.sourceforge.net/svnroot/dosbox HEAD>
I opened \prog\User\dosbox-x\dosbox\tags\RELEASE_0_74\visualc_net\dosbox.vcproj in notepad++ to edit the AdditionalDependencies line for DEGUD and Release to:
AdditionalDependencies="opengl32.lib winmm.lib zlib1.lib libpng14.lib sdl_net.lib sdlmain.lib sdl.lib curses.lib odbc32.lib odbccp32.lib ws2_32.lib"

Then I opened dosbox.vcproj in VS71 DevEnv and all whent ok with no need to add any extra include lines in src\dosbox.cpp, but I get 5 warnings.
Build log was saved at "file://e:\prog\User\dosbox-x\dosbox\tags\Release_0_74\visualc_net\Release\BuildLog.htm"
dosbox - 0 error(s), 5 warning(s)
edit:
Build log at: http://pubory.uv.ro/pub/dosbox/compilelogs/Re … se/BuildLog.htm

Then I did copy libpng14.dll, zlib1.dll to zlib1.dll, and dosbox.exe to dosbox.exe, in the folder were I have the other builds and works ok.

6. I did have a look on dosbox-x-hackipedia-20110822-0606.tar.gz

I did get this error:
e:\prog\User\dosbox-x\dosbox\tags\RELEASE_hackipedia-20110822-0606\src\hardware\vga.cpp(301): error C3861: 'strtof': identifier not found, even with argument-dependent lookup
Deleted some lines from VGA_Init() in Section_prop bellow string str to mach the SVN code.
vga_force_refresh_rate = strtof(str.c_str(),NULL); to vga_force_refresh_rate = false;

Build log at: http://pubory.uv.ro/pub/dosbox/compilelogs/Re … 822-0606mod.htm