#35 Compiling via Visual Studio Express

open
nobody
None
5
2007-04-01
2007-04-01
Warren Cheung
No

Didn't realise it was April Fools...anyways, in all seriousness.

I think it would be nice if Unicon was buildable with the freely available Visual C++ compiler that is now "free forever". That and my current attempted builds with MingW/Cygwin exhibit disturbing results.

So it took a couple days to get working (especially since I got tempted to include the 3D graphics code), so here it is. Instructions on where to get all the tools off the official websites and the steps I took to install it. My build environment was the free Visual Studio C++ Express Edition (MSVC8) using the Windows Platform SDK for Windows Server 2003 R2. I also have cygwin programs installed - particularly, cygwin diff and patch was used to generate the included diff, and cygwin cvs was used to retrieve from the website. Successfully built on two machines!

================
Remaining Issues
================
-use GetEnvironmentVariables instead of getenv in fsys.r
-getenv only looks at the copy of the environment variables loaded by the C runtime (?) -
any changes that occurred after the runtime was loaded won't be visible (potentially resulting
in unexpected behaviour)
-variable length arrays in ropengl.ri
-variable length arrays were hacked to instead allocate multiple arrays of pointers
to pointers to...
-need to quadruple-check the code (pointer arithmetic - shudder - but it does seem to work)
-use alloca for a cleaner implementation?
-didn't touch the C function loading, so still unavailable
-currently modifies files in msvc
-perhaps the originals should be kept untouched and these placed somewhere else (e.g. msvc8)
or vice-versa
-currently assumes MSWindows, NT and MSVC defined
-use some other guard - e.g. MSVC8? - if we're aiming to separate this from the MSVC6 code
-some guards us MSWindows, some use NT...I probably got these confused
-run/fix bugs exposed by the testing suite
-no nmake clean target
-to rebuild, do nmake clean in the uni subdirectory before doing nmake Unicon at top-level
(seems to kind of probably) works
-make a redistributable "binaries-only" version
-only pre-SP1 redistributable binaries are available (could build with _USE_RTM_VERSION
and use these older redistributables till newer ones are available)
-fancy (un)installer

========
Features
========
-Built using "Free as in Beer" Visual Studio 2005 Express SP1
(Built April 1, 2007 from CVS)
-both command-line unicon and windowed wunicon compilers
-Includes 3D Graphics (OpenGL) support
-Two successful builds!
-Development & rebuild from CVS on Windows XP Media Centre Ed. Pentium D 2.6Ghz
(dual core desktop)
-whole install/patch and build from CVS on Windows XP Tablet PC Ed. Pentium M 1.7 Ghz laptop

============
Instructions
============

Download and Install Visual C++ 2005 Express Edition
http://msdn.microsoft.com/vstudio/express/downloads/

Download and Install the Microsoft Windows Server 2003 R2 Platform SDK
http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB
Make a note where you install it (e.g. c:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2)

(Possibly optional)
Download and install Microsoft Visual Studio Express Editions 2005 Service Pack 1 for MS Visual C++
http://download.microsoft.com/download/7/7/3/7737290f-98e8-45bf-9075-85cc6ae34bf1/VS80sp1-KB926748-X86-INTL.exe

(Possibly optional) To use the platform SDK with the IDE follow instructions here
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

However, to build Unicon, we need to add the platform SDK directories to the environment variables.
To do this, edit the vsvars32.bat in the \Common7\Tools of the Visual C++ install
(e.g. C:\Program Files\Microsoft Visual Studio 8\\Common7\Tools\vsvars.bat)

Add c:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin; to the @set PATH=
Add c:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include; to the @set INCLUDE=...
Add c:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib; to the @set LIB=...

Now open the Visual Studio 2005 Command Prompt
(In the Start Menu\All Programs\Visual C++ 2005 Express Edition\Visual Studio Tools submenu)

Check out a copy of unicon CVS
Note that you should do this with DOS-style file terminators. I used cygwin cvs,
making sure to run from the VS 2005 command prompt or a cmd.exe window (NOT a bash shell).
I have my cygwin bin directory (e.g. c:\cygwin\bin\) near the end of my regular path.

Patch using the msvcee.diff
from inside the unicon directory (e.g. c:\unicon). I used cygwin patch.
Test it using something like
patch --dry-run -p1 < msvcee.diff
If that looks like it'll probably work, continue with
patch -p1 < msvcee.diff

Run

nmake NT-Configure

Now make sure the unicon bin directory (e.g. c:\unicon\bin) is in your path
And finally,

nmake Unicon

And then go get a coffee, you're home free :)

==================
Summary of Changes
==================
-A couple fixes when compiling without Graphics3D

=======================
List of changes follows
=======================

Moved Graphics3D #ifdef in graphics.h to after savetextures
(got compile error looking for GLubyte)

Added to define.h
(See http://support.microsoft.com/kb/320479, support for WM_MOUSEWHEEL)
/* Define WINVER */
#ifndef WINVER /* Permit use of features specific to Windows 95 and Windows NT 4.0 or later. */
#define WINVER 0x0400 /* Change this to the appropriate value to target */
#endif /* Windows 98 and Windows 2000 or later. */

#ifndef _WIN32_WINNT /* Permit use of features specific to Windows NT 4.0 or later. */
#define _WIN32_WINNT 0x0400 /* Change this to the appropriate value to target */
#endif /* Windows 98 and Windows 2000 or later. */

#ifndef _WIN32_WINDOWS /* Permit use of features specific to Windows 98 or later. */
#define _WIN32_WINDOWS 0x0410 /* Change this to the appropriate value to target */
#endif /* Windows Millennium Edition or later. */

#define _CRT_SECURE_NO_DEPRECATE /* Quiet the compiler about deprecation */

VS Express no longer appears to need libc.lib
in config/win32/msvc
removed libc.lib (before kernel32.lib) from rtt.lnk
removed libc.lib from icont.lnk
removed libc.lib from iconx.lnk
removed libc.lib from dlliconx.lnk

Added ../common/mlocal.obj to iconx.lnk
Added ../common/mlocal.obj to dlliconx.lnk
(Added ../common/mlocal.obj to icont.lnk)

Appears not to have atanh
#ifndef MSVC around the Mathop for atanh

Makefile in makefile.cmn
replace link32 with $(link)
remove reference to libc.lib, ntdll.lib

Added mlocal.$(O) to COBJS, ICOBJS
getenv collision - line 2389 in fsys.r to be guarded by
#if defined(MSWINDOWS) && !defined(MSVC)

Added to makefile.run
../common/mlocal.$(O) to COBJS, ICOBJS for findonpath
removed libc.lib from MYGUILIBS

line 60 of common/dconsole.c
getenv collision guarded by
#if defined(MSWINDOWS) && !defined(MSVC)

line 1141 of common/fsys.r
guard if statement with #ifdef Graphics

In unicon.mak
Added main.u, cfy.u to dependency and compile for unicon.exe, wunicon.exe
added compile section
Added wunicon.exe to clean

main.u : main.icn
set PATH=$(BIN)
$(ICONT) -c main

cfy.u : cfy.icn
set PATH=$(BIN)
$(ICONT) -c cfy

In makefile.uni (notused?)
Added main.u, cfy.u to UFILES

In ide.mak
Added removal of wu.exe to clean target
changed SRC, OBJ

SRC=ui.icn main.icn filedlg.icn imgs.icn utags.icn classbrowser.icn \ whitemenu.icn buffertabset.icn buffertabitem.icn editortabitem.icn \ buffertextlist.icn icbbutton.icn whitemenubar.icn icbpanel.icn \ templates.icn definitions.icn

OBJ=ui.u filedlg.u main.u imgs.u utags.u classbrowser.u whitemenu.u \ buffertabset.u buffertabitem.u editortabitem.u buffertextlist.u \ icbbutton.u whitemenubar.u icbpanel.u templates.u definitions.u

and had wu and ui build directly from SRC via unicon -G

Successful build (NT-Configure == W-Configure?)

OPENGL FAILS
Trying to add to define.h
#define Graphics3D
complaints in ropengl.ri line 2553 due to usage of variable length array tex (no C99 support in VS)
Hacked implementation of variable length array for bltex, texwindow2D, texwindow3D

line 2553
#if !defined(MSWindows) || !defined(MSVC)
GLubyte tex[height][width][3];
#else /* MSWINDOWS MSVC */
int j;

/* If compiler doesn't support variable length arrays (C99 feature) */
GLubyte ***tex = malloc(height * sizeof(GLubyte **));
GLubyte *tex2 = malloc(height * width * 3 * sizeof(GLubyte));

for (i = 0; i < height; i++) {
tex[i] = malloc(width * sizeof(GLubyte **));
for(j = 0; j < width; j++) {
tex[i][j] = tex2 + i*width*3 + j*3;
}
}
#endif /* MSWINDOWS MSVC */

at the end (~line 2621)

#if defined(MSWindows) && defined(MSVC)
i = texture(width, height, (GLubyte *)tex2, w->context->texmode);

for (j = 0; j < height; ++j) {
free((void *)tex[i]);
}
free((void *)tex);
free((void *)tex2);
#else
i = texture(width, height, (GLubyte *)tex, w->context->texmode);
#endif /* MSWindows && MSVC */

in makefile
Add
opengl32.lib glu32.lib in MYGUILIBS (Not needed/deprecated?)
Add opengl32.lib glu32.lib to the end of wiconx compile statement (Wrong place?)

Add to icont.lnk, iconx.lnk
opengl32.lib glu32.lib
Add to makefile.t
wicont2 target
opengl32.lib glu32.lib

Discussion

  • Warren Cheung
    Warren Cheung
    2007-04-01

    Patch agains CVS (April 1st 2007)

     
    Attachments
  • Warren Cheung
    Warren Cheung
    2007-04-01

    Logged In: YES
    user_id=63610
    Originator: YES

    Includes fixes for bugs 1692137 and 1691664 I posted earlier.