2005/5/10

     
 

How create own Executable

artefaktur

How to create your own executable using the ACDK libraries.

How to create own Executable/Library Project Currently there are multiple ways to create your own Project using the ACDK libraries.

Content of this chapter:

   Minimal Makefile sample for Unix
   Minimal build.csf sample for all platforms
   Use acdk_boot as sample
   Generate own Makefiles/Project using acdklisp

 Minimal Makefile sample for Unix

In an empty directory create the file minacdksample.cpp

#include <acdk.h>
#include <acdk/lang/System.h>

using namespace acdk::lang;

// minimal example, which just says hello
class MiniAcdkSample
{
public:
  static int acdkmain(RStringArray args)
  {
    System::out->println("Hello from miniacdksample");
    return 0;
  }
};

int
main(int argc, char* argv[], char** envptr)
{
  return acdk::lang::System::main(MiniAcdkSample::acdkmain, argc, argv, envptr);
}
Create the corresponding Makefile for unix/gcc:

# where is your ACDK installed
ACDKHOME=/artefaktur/acdk

CCOMPILER=g++ -Wall -Wno-unused -g -D_REENTRANT -I .  -I $(ACDKHOME)/include

# system libraries. These are needed by ACDK at least
SYSLIBRARIES=-lpthread -lm -ldl
ACDKLIBS=-lacdk_core

# all libs together
LIBS = $(SYSLIBRARIES) -Wl,-Bdynamic -L$(ACDKHOME)/bin $(ACDKLIBS)

# want maybe to debug
SYSLDFLAGS=-g


OBJECTS = minacdksample.o

# builds the executable itself
# don't forget to export LD_LIBRARY_PATH=/artefaktur/acdk/bin before execute the binary
minacdksample: $(OBJECTS)
	g++ $(SYSLDFLAGS)  $(OBJECTS) -o minacdksample $(LIBS)

%.o: %.cpp
	$(CCOMPILER) -c $< -o $@

clean:
	rm *.o minacdksample
That is all. Just make.

 Minimal build.csf sample for all platforms

 ACDK Make is a platform independ make substitution. Currently it is in experimental state. Create a build.csf in our directory:


/*
  Just execute acdkmake in this directory
*/

// needed for base definitions
#include "amake_config.csf"

// Create a standard ACDK console executable 
minacdksample = new acdk.make.AcdkExeTask("minacdksample");

//  add a single source. This also excepts pattern
//  like "src/acdk/bla/*.cpp" 
//  or   "src/acdk/blub/**/*.cpp"
minacdksample.addSource("minacdksample.cpp");

// this uses acdk_core library
minacdksample.addAcdkLib("acdk_core");

// make a project
default = new acdk.make.AcdkProjectTask("default");
default.addSubTask("minacdksample");
Execute acdkmake in the directory.

 Use acdk_boot as sample

The package  ACDK Boot is small sample project which, which can be used as a template for creating own projects.

 Generate own Makefiles/Project using acdklisp

Currently ACDK uses a lisp files to generate platform make files. In the future this will replaced with acdkmake. Please refer to  Platform makes.