Transfering code from Dev-C++ environment to Xcode

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
ScKaSx
Knows some wx things
Knows some wx things
Posts: 25
Joined: Wed Oct 25, 2006 3:42 am

Transfering code from Dev-C++ environment to Xcode

Post by ScKaSx »

Hi All,

I have some code that I'm trying to compile via Xcode which I know works on Dev-C++. Already, I've hit afew snags in the compiler that I need help with. I'd appreciate help with the the problems I have so far:

(1)
Code:
while (syscmnd.Replace(" "," ")) ;
Error:
error: no matching function for call to 'wxString::Replace(const char [3], const char [2])'
How do I make (" ") a const wxChar*?

(2)
Code (at beginning of my main.cpp file):
wxString MainDataFileName;
Error:
error: 'wxString' does not name a type
(3)
Code:
s_cmndline.Append(wxString::Format(_T("-W%s,%s "),
m_textWlo->GetValue().IsEmpty() ? "0" : m_textWlo->GetValue().c_str(),
m_textWhi->GetValue().IsEmpty() ? "100" : m_textWhi->GetValue().c_str()
));
Error:
error: conditional expression between distinct pointer types 'const char*' and 'const wxChar*' lacks a cast
(4)
Code(wx/size.h):
class WXDLLEXPORT wxStaticBox;
Error/s:
error: forward declaration of 'struct wxStaticBox'
This problem is created in the size.h include file which doesn't let me create any StaticBox structs.

(5) And I guess my last questions for now is how to make an icon for my application? I saw a link for CodeWarrior but nothing for Xcode.

Thanks for any and all help.

Cheers,
ScKaSx
baka_bai
Experienced Solver
Experienced Solver
Posts: 99
Joined: Fri Sep 30, 2005 10:20 pm
Contact:

Post by baka_bai »

(1)
for your wxChar problems use wxT("") or _T("")

(2)
Make sure you are including wx/wx.h and wx/string.h if not using precompiled libraries. This one is from not being able to find a definition of the wxString class, you may have just forgot the include directives for that file.

as for the making an icon you could use a program like inkscape or gimp and save it as an xpm file to be linked into the executable.
____
wxWidgest 2.8.2 / 2.8.6u
mingw32-gcc-3.4.2 / gcc 4.1.2
wxDev-CPP beta 6.10.2 / Anjuta
Dev-CPP (4.9.9.2)
XP Pro / Vista / Feodra 8
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

4) include the header that declares wxStaticBox
5) make it as png, then use an app like CocoThumbX to convert it to icns format. Then, specify its name in your info.plist file and add it to the resources folder of the application. (XCode might have some ways to automatize that, don't quite remember)
ScKaSx
Knows some wx things
Knows some wx things
Posts: 25
Joined: Wed Oct 25, 2006 3:42 am

Post by ScKaSx »

Thanks for the help, your suggestions have solved my problems so far.

Another question:
I am issuing the following command -
m_chk_Fit = CreateCheckBoxAndAddToSizer(sizerFitVar, _T(NonName));

This gives me the following error:
error: 'LNonName' was not declared in this scope

I have defined the NonName array in the following way:
char **NonName;


Any suggestions?

Cheers,
ScKaSx
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

wxT(), _(), etc., are for strings literals, i.e. "text with quotes". They don't work with char* or std::string or whatever other string types

To convert char* to wxString, use something like:

Code: Select all

char* chars = "hello world";
wxString hellostring(chars, wxConvUTF8)
PS: not sure if you read wxBlog, but all these should disappear in wx 3 so it's sad to learn this at this point :wink: but anyway 2.8 will still stay for some time (i don't think your program will break, it just won't be necessary anymore)
ScKaSx
Knows some wx things
Knows some wx things
Posts: 25
Joined: Wed Oct 25, 2006 3:42 am

Post by ScKaSx »

thanks for the help Auria,

I was just wondering how would I convert the array NonName to a wxString? Since I need it to be variable I can't write it as any specific text (char* chars "hello world").

Cheers,
Tyler
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

I don't understand what you mean. In my example I created a const char* for the sake of demonstrating it, but in your case you can use any C string.
ScKaSx
Knows some wx things
Knows some wx things
Posts: 25
Joined: Wed Oct 25, 2006 3:42 am

Post by ScKaSx »

Thanks Auria,

I think I get it, does this look okay:
char **NonName;
.
.
CODE
.
.
wxString hellostring(*NonName, wxConvUTF8); // added

for (int i=0;i<NonN;++i) {
m_chk_Fit = CreateCheckBoxAndAddToSizer(sizerFitVar, hellostring);
if (i==_kappa_ -NON_OFFSET) m_chk_Fit->Disable();
if (i==_beta_ -NON_OFFSET) m_chk_Fit->Disable();
if (i==_c_coat_-NON_OFFSET) m_chk_Fit->Disable();
if (i==_lamD_ -NON_OFFSET) m_chk_Fit->Disable();
if (i==_detM_ -NON_OFFSET) m_chk_Fit->Disable();
}


Also, how would I convert unix commands to wx format, such as my attempt here:

wxLogMessage(_T("Write file: %s\n"),wxDefaultFile.c_str());


This gives me the error that 'wxLogMessage' is not declared in this scope.

And finally, do you know of wxPlot for Mac(Intel)? As far as I can tell from my google searches is that it only works on PC.

Thanks again for all your help.

Cheers,
ScKaSx
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Search for 'wxLogMessage'in the docs, you need to include the proper header file. Also don't convert to C strings... just append the wxStrings
Post Reply