Home > Pub

Pub

Pub is a project mainly written in C++ and SHELL, based on the View license.

Public repository of WexWorks code

WexWorks Application Development Tree

Mobile application development code base:

app - Applications lib - Shared libraries ext - External libraries

Supports Android (and later, iOS) C++ development with lightweight emulation and debugging on Linux and Windows.

Requires the ILM Base vector and matrix library and the ARM OpenGL ES 2.0 emulator.

Use app/MakeApp to create a new application from a template.

Machine Configuration

  1. Install recent Ubuntu (e.g. 32-bit 10.10).
  2. Install proprietary NVIDIA linux drivers.
  3. Install recent version of eclipse, including C++ and Java support.
  4. Install Android SDK, ADT and NDK (I put these in /opt/android). Add sdk-root/{platform-tools,tools} and ndk-root to your PATH (e.g. in ~/.bashrc)
  5. Attach Android device, enable: Settings -> Applications -> Development -> USB Debugging
  6. Attach device using USB cable. Use "adb devices" to check. For devices with no number (e.g. "????????"), see: http://www.google.com/support/forum/p/android/thread?tid=08945730bbd7b22b
  7. Install the latest ARM OpenGL ES 2.0 emulator in /ext from: http://www.malideveloper.com/developer-resources/tools/opengl-es-20-emulator.php There are separate Windows and Linux installers, with the Windows installer having spaces in filenames vs. underscores in Linux. Also, the Windows installer has a "v" in the version name, and includes a lib directory and .dll files instead of .so files in the bin directory. You can set the directory name in the common.vsprops User Macros along with TopOfTree.
  8. Install the latest ILMBase (math, vector & matrix) libs in /ext from: http://www.openexr.com/downloads.html

Build Instructions

Create a new application by running: bash makeapp.sh MyApp mydomain Use your app and domain name, of course. This will create a new directory using the HelloApp template and renaming directories and files and replacing instances of HelloApp in the configuration and code files.

New apps should be placed in the /app subdirectory.

Opening a new Eclipse Workspace:

  1. Start eclipse
  2. Set Workspace directory. I recommend: ~/workspace/--, e.g ~/workspace/wexworks-pub-linux, with a unique WS for each OS.
  3. Set Google C++ style: Window -> Preferences -> C/C++ -> Code Style -> Import... Load: /lib/eclipse/google-c++-style.xml
  4. If building for Android, set Android SDK root: Window -> Preferences -> Android -> SDK Location: Browse... and point it to SDK, e.g.: /opt/android/android-sdk-linux_x86 hit Apply to verify that you have at least 2.2
  5. Set Top of Tree directory in build variables with: Window -> Preferences -> General ->Workspace -> Linked Resources -> New... Set Name to "top_of_tree" and Folder... to set the location of containing app, ext, and lib directories.
  6. If building for Android, set ANDROID_NDK_ROOT=/opt/android/android-ndk-r5c in Window -> Preferences -> C/C++ -> Environment -> Add...
  7. File -> Import -> General -> Existing Projects into Workspace, hit Next... Browse... to and hit OK. myapp and util should both be visible and selected in the Projects list. Select only the Linux projects and import them into the workspace. (There are two instances of myapp, one for Linux and one for Android.)
  8. Open the C/C++ Perspective using the drop-down list in the upper right corner of the Eclipse window, next to the Java Perspective.
  9. Build the app by selecting the app project and hitting Control-b. It should build without errors.
  10. If running Linux, set the runtime LD_LIBRARY_PATH by right clicking on the project (you will need to set this separately in each project): Properties -> Run/Debug Settings -> (Select launch config) -> Edit... Select the Environment tab and hit New... and set it to e.g.: LD_LIBRARY_PATH=/home/wex/WexWorks/Pub/ext/ARM/Mali_Developer_Tools/OpenGL_ES_2_0_Emulator_1.2.0/bin
  11. If first time using android, copy the vertex and fragment shaders to device: adb push app/MyApp/myapp.vp /sdcard/mydomain/MyApp/myapp.vp adb push app/MyApp/myapp.fp /sdcard/mydomain/MyApp/myapp.fp (Note: dir set via glesu::AddShaderPath in app/myapp.cpp:MyApp::Init()
  12. Debug or launch as Android Application to verify everything worked. You may have to select the profile to run the app the first time, but from then on you can hit the Debug (bug) button on the toolbar.

Opening a new Visual Studio Solution:

  1. Start Visual Studio
  2. In Express version, Tools -> Advanced Settings (to enable Property Mgr)
  3. Load /app/MyApp/build/vs10/myapp.sln
  4. View -> Property Manager...
  5. Open myapp -> Debug|Win32 -> common -> User Macros Set TopOfTree variable
  6. Close Property Manager (optional)
  7. Adding Files:

Create the new file in /MyApp/src/myapp. You can have app-specific libraries in /MyApp/src/mylib, or shared libraries in /lib/mylib.

Linux:

  1. Open the eclipse project in MyApp/build/linux
  2. Right click on MyApp project and select New -> File... -> Link
  3. Select Variables... and choose top_of_tree
  4. Append relative path to file, e.g. top_of_tree/app/MyApp/src/myapp/foo.cpp

Android:

  1. Open /app/MyApp/build/android/jni/Android.mk
  2. Add the file by adding it to LOCAL_SRC_FILES following the existing conventions, adding a new directory variable if needed.

Windows:

  1. Start Visual Studio on /app/MyApp/build/vs10/myapp.sln
  2. Add file to existing or new folders in project.

Tips

o You can debug Android apps running on the device using a remote gdb session as detailed in the NDK docs.

o You can also debug using gdb and the remote server in Eclipse: http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging

o Window -> Show View... -> Android -> {Devices,LogCat}

o Download a free logcat viewer app (e.g. aLogcat) from the Android Market. Check log for errors after crashes, use util/debug.h functions to print to log/console.

o Device screenshots can be taken from the Devices window with Camera. Also easy to kill app from the Devices window by selecting and Stop.

o On Windows/Linux, hit 'r' to emulate rotating the screen.

o On Windows/Linux, hit ESC to exit.

o Eclipse has a race condition which can result in a black console window. Only workaround is to restart eclipse until it goes away.

o Windows -> Preferences -> Run/Debug -> Launching Set Save required dirty editors before launching to Always

o On Linux/Windows: Right click on project -> Properties -> Run/Debug Settings Select project and hit Edit... On Debugger tab, de-select Stop on startup at: main

o The Perspective tab can be dragged to the left so you can see all modes

Copyright (c), 2011 by WexWorks, LLC. All Rights Reserved