[solved]Using C++STL / C newlib

Have got a technical question regarding the development for bada platform? Share it with us!

[solved]Using C++STL / C newlib

Postby remy_david » Mon Mar 08, 2010 3:20 pm

Has anyone already tried to work with these libraries ?
Here is what the documentation says:

You can use these methods by including the relevant header file in the standard manner, for example:
"#include <vector>".

The current release provides an early version of STL and standard C functions, including the newlib subset.


However when I try to add any include from these libs the compilation fails because it cannot found the headers. That is because the include folder of the SDK does not include them. Does it mean this is not yet supported ? or did I miss something :mrgreen: ?

Thanks for your help!
Last edited by remy_david on Mon Mar 08, 2010 7:29 pm, edited 1 time in total.
Need more hands, one for each mobile platform out there...
User avatar
remy_david
Moderator & Author
 
Posts: 368
Joined: Thu Feb 25, 2010 9:29 am
Location: France

Re: Using C++STL / C newlib

Postby Nour » Mon Mar 08, 2010 4:07 pm

Hi

You need to add the libraries similar to this solution presented by wit

viewtopic.php?f=4&t=13

However, I read that STL is not recommended for mobile devices because it is memory-expensive

You need to check that, my info could be outdated.
Sailing in the stormy Bada, searching for the Treasure Island.
User avatar
Nour
Moderator & Author
 
Posts: 1023
Joined: Sat Nov 28, 2009 5:36 pm
Location: Syria

Re: Using C++STL / C newlib

Postby Nour » Mon Mar 08, 2010 4:08 pm

you may need to read this topic [for custom new/delete operators]

viewtopic.php?f=6&t=60
Sailing in the stormy Bada, searching for the Treasure Island.
User avatar
Nour
Moderator & Author
 
Posts: 1023
Joined: Sat Nov 28, 2009 5:36 pm
Location: Syria

Re: Using C++STL / C newlib

Postby remy_david » Mon Mar 08, 2010 5:10 pm

Actually I only want to use the math.h standard C library but I don't know how to do that.
Need more hands, one for each mobile platform out there...
User avatar
remy_david
Moderator & Author
 
Posts: 368
Joined: Thu Feb 25, 2010 9:29 am
Location: France

Re: Using C++STL / C newlib

Postby sparky » Mon Mar 08, 2010 5:49 pm

1. Include this in your header file:
Code: Select all
#include <math.h>

2. Go to Linker settings in your project properties (As Nour said, look at this thread by wit http://forums.badadev.com/viewtopic.php?f=4&t=13 if you don't know where they are) and add the location of the std libraries to the Library Search Path (-L). For example:
Code: Select all
"c:/bada/SDK/1.0.0b1/Tools/Toolchains/Win32/include/c++/4.4.1"


That's it. It should compile fine (didn't test it in action though :-D).
Take the wheel, my trick's over!
User avatar
sparky

 
Posts: 173
Joined: Mon Nov 30, 2009 8:25 am

Re: Using C++STL / C newlib

Postby Nour » Mon Mar 08, 2010 5:50 pm

yes, it should be enough as sparky wrote.
Sailing in the stormy Bada, searching for the Treasure Island.
User avatar
Nour
Moderator & Author
 
Posts: 1023
Joined: Sat Nov 28, 2009 5:36 pm
Location: Syria

Re: Using C++STL / C newlib

Postby remy_david » Mon Mar 08, 2010 7:15 pm

Thanks for your responses, I was missing the "c:/bada/SDK/1.0.0b1/Tools/Toolchains/Win32/include/c++/4.4.1" part :) However it was not as you said ;)

To get it to work you have to add "C:\bada\SDK\Tools\Toolchains\Win32\include\c++\4.4.1" to the Include path. The library search path is left untouched since stl & clib are part of the FBase library (which should already be in the path). This step is in fact not mandatory, as compilation will not fail, but the IDE will complain not finding the includes.

My problem was more C stdlib related. For the C standard library, the normal way of including the headers doesn't work. They are renamed as follow : normal name = "lib_name.h" -> bada name = "clib_name"

Exemple for "math.h" put "cmath" instead, which means:
Code: Select all
#include <cmath>

And not :
Code: Select all
#include <math.h>
Need more hands, one for each mobile platform out there...
User avatar
remy_david
Moderator & Author
 
Posts: 368
Joined: Thu Feb 25, 2010 9:29 am
Location: France

Re: [solved]Using C++STL / C newlib

Postby sparky » Mon Mar 08, 2010 8:47 pm

Good to know, remy_david! I am pretty sure I will need the math thingy very soon! ... Thanks!
Take the wheel, my trick's over!
User avatar
sparky

 
Posts: 173
Joined: Mon Nov 30, 2009 8:25 am


Return to Help Requests

Who is online

Users browsing this forum: Google [Bot] and 4 guests