Thread: iLiad C++ for Iliad code
View Single Post
Old 11-25-2008, 03:51 PM   #3
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Cool C++ recipe for contentLister

Hi,

If you want to compile contentLister with c++ files, here is how to start. It is important that main() gets compiled with the c++ compiler...


1: make a working copy of contenLister
Code:
cp -r contentLister   cppLister
cd cppLister
2: edit configure.ac as follows:

Code:
after the line 'AC_PROG_CC', add a line with 'AC_PROG_CXX'
Edit this line
Code:
< AC_CONFIG_SRCDIR(src/main.c)
> AC_CONFIG_SRCDIR(src/main.cpp)

3: goto the sources:
Code:
cd src
rm -rf .deps   # necessary if you have compiled this stuff before
4: edit Makefile.am
Code:
< contentLister_SOURCES = main.c \
> contentLister_SOURCES = main.cpp \


5: convert main.c to main.cpp
mv main.c main.cpp
edit main.cpp as follows:

Code:
before the first #include add a line:
extern "C" {

just before main() add a line:
}; // end of extern "C"
6: use the official tools to generate a good Makefile (don't forget to set the right compiler environment with setup_build_env.sh or such)

Code:
cd ..
autoreconf --install --force
./configure --host=arm-linux --build=i686  --prefix=/usr --datadir=/usr/share
7 Compile everything
Code:
cd src
make
8: now you're ready to add C++ stuff
I hope this helps someone, took me a while to figure it all out...

Happy hacking!

Tip: If you forget some step, and get errors: restart from scratch (a clean copy
Tip: This looks like a nice simple FAQ on combining C and C++: http://www.parashift.com/c++-faq-lit...c-and-cpp.html

Last edited by hansel; 11-25-2008 at 04:19 PM. Reason: forgot to mention Makefile.am
hansel is offline   Reply With Quote