Preface
Reference |
Installations
a) cmake
apt-get install cmake
b) java
apt-get install sun-java6-jdk
apt-get install sun-java6-jre
apt-get install sun-java6-plugin
apt-get install sun-java6-font
!!NOTES:
It can be done as follows, too
command >> gnome-app-install
Search "java" with "all available applications" column selected
c) eclipse
apt-get install eclipse
!!NOTES:
Please refer this web site to install WTP, Tomcat and configure WTP
d) Eclipse CDT
-- please go to http://www.eclipse.org/cdt
-- extract the tar file under /usr/lib, and it will be put into /usr/lib/eclipse
e) gdb
f) gcc
Use Ecplise for C/C++ "hello_lib" project step-by-step
1) Run Eclipse
2) Create a new C project
Action: File -> New -> Create "Standard Make C Project"
Ref: (2.a), (2.b)
(2.a)
(2.b)
3) create the following folders
Action: right-click "hello_lib" project -> New ->folder
Ref: (3.a), (3.b)
-- build (the location for cmake to be executed)
-- lib_a (the library for "hello_lib_a")
-- lib_b (the library for "hello_lib_b")
-- src (the source file where main() will be written)
(3.a)
(3.b)
4) Write the needed source files
Action: right-click "hello_lib" project -> New -> header file / source file
Ref: (4.a), (4.b)
lib_a/hello_lib_a.h
#ifndef HELLO_LIB_A_H_
#define HELLO_LIB_A_H_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void hello_a();
#ifdef __cplusplus
}
#endif // __cplusplus
#endif /*HELLO_LIB_A_H_*/
lib_a/hello_lib_a.c
#include "hello_lib_a.h"
void hello_a() {
printf ("hello_a\n");
}
lib_b/hello_lib_b.h
#include "hello_lib_b.h"
void hello_b() {
printf ("hello_b\n");
}
lib_b/hello_lib_b.h
#ifndef HELLO_LIB_B_H_
#define HELLO_LIB_B_H_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void hello_b();
#ifdef __cplusplus
}
#endif // __cplusplus
#endif /*HELLO_LIB_B_H_*/
src/hello_main.c
#include <hello_lib_a.h>
#include <hello_lib_b.h>
int main () {
hello_lib_a();
hello_lib_b();
return 0;
}
(4.a)
(4.b)
5) Write CMakeLists.txt
Action: right-click "hello_lib" project -> New -> File
Ref: (5.a), (5.b)
lib_a/CMakeLists.txt
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_DEBUG})
ADD_LIBRARY(hello_lib_a SHARED hello_lib_a.c)
lib_b/CMakeLists.txt
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_DEBUG})ADD_LIBRARY(hello_lib_b SHARED hello_lib_b.c)
src/CMakeLists.txt
INCLUDE_DIRECTORIES(${HELLO_LIB_TEST_SOURCE_DIR}/lib_a)
INCLUDE_DIRECTORIES(${HELLO_LIB_TEST_SOURCE_DIR}/lib_b)
LINK_DIRECTORIES(${HELLO_LIB_TEST_BINARY_DIR}/lib_a)
LINK_DIRECTORIES(${HELLO_LIB_TEST_BINARY_DIR}/lib_b)
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_DEBUG})
ADD_EXECUTABLE(hello hello_main.c)
TARGET_LINK_LIBRARIES(hello hello_lib_a hello_lib_b)
/CMakeLists.txt
PROJECT (HELLO_LIB_TEST)
ADD_SUBDIRECTORY(lib_a)
ADD_SUBDIRECTORY(lib_b)
ADD_SUBDIRECTORY(src)
(5.a)
(5.b)
6) Prepare External Tools for cmake and Run it
Action:
a) Run -> External Tools -> External Tools...
b) New program named "cmake_hello_lib_test"
c) fill the corresponding columns as (6.a) picture
d) Run -> External Tools -> cmake_hello_lib_test
Ref: (6.a)
(6.a)
7) Prepare make environment
Action:
a) right-click "hello_lib" project -> Properties as (7.a)
b) fill in "build_directory" with "/hello_lib/build"
Ref: (7.a)
(7.a)
8) Debug environment
Action:
a) Run -> Debug
b) New "C++ Local Application" as (8.a) shows
c) Fill in "C/C++ Application" columns as (8.b) shows
d) Press "Apply" button
e) Press "Debug" button as (8.c) shows
f) Press F5 to Step-Into or F6 to Step-Over
Ref: (8.a), (8.b)
(8.a)
(8.b)
(8.c)