WebObjects: How to Change Carriage Returns When Porting Applications

This document describes how to convert Windows to UNIX carriage returns when porting WebObjects applications.
When building a WebObjects application developed on Microsoft Windows and ported to Solaris, sometimes compilation errors, link errors, or runtime errors result. One cause of these types of errors is Microsoft Windows form for indicating a carriage return, which differs from Solaris.

Determining the cause of compilation errors

If your projects build properly on Windows, but on Solaris produces errors like the following, the problem may be Windows-style carriage returns and end of file characters in your source or make files.

Undefined symbol   first referenced in file

ologof             /opt/Apple/Local/Library/Frameworks/OracleEOAdaptor.framework/libOracleEOAdaptor.so

.

.

.

ld: fatal: Symbol referencing errors. No output written to /users/install/apps/WOApp.woa/WOApp

make: *** [/users/install/apps/WOApp.woa/WOApp] Error 1

Evaluate any listed source files which you had previously edited on Windows and check all of your Makefiles for Windows style control characters such as carriage returns. Windows files and editing tools use carriage return (CR) + line feed (LF) to separate lines of ASCII Text. Solaris uses just line feed (LF).

When tools on Solaris encounter the carriage return characters, the tools can exhibit erratic behavior. You can determine if your files contain these CR characters after moving them to your Solaris system by issuing the following command:

cat -v filename

You could also open the suspect files in the vi editor to see if the carriage return characters appear.

When a Windows style carriage returns exist, ^M appears at the end of every line. In order to properly compile your project, you need to strip these characters out of the file. You should run the Solaris dos2unix utility to remove the unwanted CR characters. Detailed information about the dos2unix utility is available on a Solaris computer in the dos2unix man page.

Here's an example of running the dos2unix command which copies all text except carriage returns and Windows end of file characters from oldfilename to newfilename.

dos2unix -ascii oldfilename newfilename

If you want to replace the file inline, you can issue the command as follows:

dos2unix -ascii filename filename

If you wish to run a recursive batch processing of dos2unix on all the files within a directory tree, cd to the directory containing your WebObjects application's PB.project file. Then issue the following command:

find . -type f -print | xargs -I {} dos2unix -ascii {} {}

Note: You may safely disregard the following warnings issued by the dos2unix command as it does its processing.

could not open /dev/kbd to get keyboard type US keyboard assumed

could not get keyboard type US keyboard assumed

Other factors can lead to build problems on Solaris including incorrect environment variables and improper installations of frameworks, but attempts to resolve those problems will be futile if your source and make files contain Windows-style carriage returns and end of file characters. After uploading your files from Windows to UNIX in ASCII mode, searching for and removing carriage returns from your source files and makefiles should be the next step you take in your efforts to resolve your build problems.

Published Date: Feb 20, 2012