These instructions assume you have a computer with Linux and Windows already installed, and a filesystem that's visible to both. My machine, for example, dual-boots Ubuntu 10.04 LTS and Windows 7, with a shared data partition. These instructions also assume you have Visual Studio 2010. If you don't, you can get it from the Engineering school's MSDNAA program, or through Dreamspark.
ACE setup is easier on the CEC machines since it's already built. Instructions that you should skip for CEC machines are highlighted in light blue.
Part A: Build and Configure ACE on Linux (one-time setup)
- Download ACE, version 6.0.1 (latest BFO micro release), tar+bzip2 format, from http://download.dre.vanderbilt.edu/.
- Follow the steps here to set up and build ACE. You can skip steps 5, 8, and 9, since we're not installing it.
- Add the ACE_ROOT and LD_LIBRARY_PATH environment variables to your .bashrc or .cshrc. See #1 here for an example of how to go about this.
Part B: Build and Configure ACE on Windows (one-time setup)
- Download ACE, version 6.0.1 (latest BFO micro release), zip format, from http://download.dre.vanderbilt.edu/.
- Follow the steps here to set up and build ACE using Visual Studio 2010. Steps 3, 6, 7, and 8 are skippable. The build can take a while (half an hour for me).
- If you haven't already, add ACE_ROOT\lib to your Windows PATH variable. On the CEC machines ACE_ROOT\lib is "\\warehouse.cec.wustl.edu\home\cec\class\cse532\ACE_wrappers_win\lib".
- Tell Visual Studio where to find ACE header files and libraries:
- Open Visual Studio 2010. If this is the first time the program's been used, choose the Visual C++ development environment if a dialog pops up.
- Go to File -> New -> Project...
- Choose Visual C++ Win32 Console Application and enter in a dummy name. (We'll delete the project later, so it doesn't matter what the name is.) Click OK, then Finish.
- Visual Studio has now created a dummy project for you. Go to View -> Property Manager. The Property Manager will probably appear in the upper right or upper left.
- Click on the small arrow to the left of the project name in the Property Manager to expand it. The Property Manager should now look something like this:
- Click on the small arrow to the left of "Debug | Win32" in the Property Manager to expand it.
- Double-click on "Microsoft.Cpp.Win32.user".
- Under "Common Properties", click on "VC++ Directories".
- In "Include Directories", add the full path for ACE_ROOT at the end (use a semicolon as a separator if needed). For example, on my machine ACE_ROOT is "C:\Program Files\ACE\ACE-6.0.1\ACE_wrappers". On the CEC machines ACE_ROOT is "\\warehouse.cec.wustl.edu\home\cec\class\cse532\ACE_wrappers_win".
- In "Library Directories", add the full path for ACE_ROOT\lib at the end (use a semicolon as a separator if needed). For example, on my machine ACE_ROOT\lib is "C:\Program Files\ACE\ACE-6.0.1\ACE_wrappers\lib". On the CEC machines ACE_ROOT\lib is "\\warehouse.cec.wustl.edu\home\cec\class\cse532\ACE_wrappers_win\lib". Click OK.
- Close Visual Studio 2010. If you get a prompt that says "One or more inherited user property sheets have not been saved. Save them now?", click Yes. Delete the dummy project. (If you don't know where the dummy project is, it's probably at Documents\Visual Studio 2010\Projects.)
Part C: Add code and set up file structure
Part C and after are setup on the project level. Follow these instructions for every lab/studio/project that you want across both OSes and IDEs.- Create a folder for your lab/studio/project in the shared filesystem. In this document, the folder will be named
Studio1
. - Create a
src
folder underneath the newly created project folder. - Create
Server
andClient
folders underneath the newly createdsrc
folder. - Put server.cpp in the
Server
folder and client.cpp in theClient
folder.
Part D: Project setup on Windows
- Open Visual Studio 2010.
- Go to File -> New -> Project...
- Choose Visual C++ Win32 Console Application. Enter
Client
for the Name. Type in a more descriptive name for the Solution Name. In this document, it will beWindowsStudio1
. - For the location, select the upper-level folder for your lab/studio/project (
Studio1
in this example). Click OK. - Click Next, then check
Empty project
. Click Finish. - Go to View -> Solution Explorer. The Solution Explorer will probably appear in the upper right or upper left.
- In the Solution Explorer, right-click on Client, then go to Add -> Existing Item...
- Navigate to the
src\Client
directory and selectclient.cpp
. Click Add. - Go to Project -> Properties. In the dialog that opens, go to the Configuration dropdown (in the upper left) and select "All Configurations".
- Go to Configuration Properties -> Linker -> Input.
- In the
Additional Dependencies
field, addace.lib
to the end (use semicolons to separate if necessary). Click OK. - Go to File -> Add -> New Project...
- Enter
Server
for the name, then click OK. - Click Next, then check
Empty project
. Click Finish. - In the Solution Explorer, right-click on Server, then go to Add -> Existing Item...
- Navigate to the
src\Server
directory and selectserver.cpp
. Click Add. - Go to Project -> Properties. In the dialog that opens, go to the Configuration dropdown (in the upper left) and select "All Configurations".
- Go to Configuration Properties -> Linker -> Input.
- In the
Additional Dependencies
field, addace.lib
to the end (use semicolons to separate if necessary). Click OK. - You're ready to build! Select Build -> Rebuild Solution. Your executables will be at WindowsStudio1\Debug.
Part E: Project setup on Linux
- Create a directory for Linux-related project stuff underneath
Studio1
, for exampleLinuxStudio1
. - Download the course Makefile into the
LinuxStudio1
directory. - For
CMPL_SRCS1
, changeclient.cpp
to../src/Client/client.cpp
. - For
CMPL_SRCS2
, changeserver.cpp
to../src/Server/server.cpp
. - Change line 78 from
INCFLAGS = -I/home/cec/class/cse532/ACE_wrappers
to
INCFLAGS = -I$(ACE_ROOT)
- Change line 83 from
LIBLOCFLAGS = -L/home/cec/class/cse532/ACE_wrappers/ace -L./
to
LIBLOCFLAGS = -L$(ACE_ROOT)/ace -L./
- Save and close the Makefile.
- You're ready to build! Run
make
in theLinuxStudio1
directory. Your executables will be in the same directory (LinuxStudio1
).
Random stuff
- For the most part, you can use the same code for both Windows and Linux. However, if you run into a situation where you need different code for each, use
#ifdef
s. On Windows,Win32
has already been#define
d, and on Linux, you can uselinux
. For example:
#ifdef WIN32
printf("%s", "Running on Windows\n");
#endif /* WIN32 */
#ifdef linux
printf("%s", "Running on Linux\n");
#endif /* linux */ - At some point you might want to share code between client and server. Put the shared code in a new
Shared
folder undersrc
. In Visual Studio, use Add -> Existing Item... to add each shared file to both projects. Similarly, for g++, modifyCMPL_SRCS1
,CMPL_SRCS2
,HEADER_FILES1
, andHEADER_FILES2
so all shared files are compiled into both targets.
Differences between ACE on Windows vs. Linux
ACE should work with the same code for both Windows and Linux, but sometimes this isn't the case. We'll try to post such differences here when we find them.- In the client code,
ACE_INET_Addr server(SERVER_PORT);
works in Linux but not in Windows. UseACE_INET_Addr server(SERVER_PORT, "127.0.0.1");
instead.
No comments:
Post a Comment