LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-31-2012, 03:50 AM   #1
Huamin
Member
 
Registered: May 2011
Posts: 562

Rep: Reputation: 12
Use Qt for a Dialog in Solaris studio


Hi,
Why can’t I use “ShowMessage” in my Solaris studio?

Many Thanks & Best Regards,
HuaMin
 
Old 05-31-2012, 04:39 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,924

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
Why? What have you tried and what's happened?
 
Old 05-31-2012, 05:53 AM   #3
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks. Why do I get this problem
"main.cpp", line 21: Error: The function "ShowMessage" must have a prototype.
1 Error(s) detected.

to this line?
ShowMessage("Hello");
 
Old 05-31-2012, 06:22 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
It looks like you're not including the header that provides the prototype for that function. Can you provide the rest of your code, please? We don't want to have to guess.

Also, please try to use more descriptive thread titles in future. Something like "Solaris Studio C++: The function ... must have a prototype" would have been better.
 
Old 05-31-2012, 06:27 AM   #5
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks a lot. I've put these in the beginning of my codes.

#include <cstdlib>
#include <list>

using namespace std;

int main(...
...

Last edited by Huamin; 05-31-2012 at 06:28 AM.
 
Old 05-31-2012, 06:34 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
OK, so you need to include the header that contains the signature for ShowMessage(). If this ShowMessage() function is in the same file as main(), then you have two options.

1. Put the function before main():

Code:
ShowMessage()
{
  ...
}

int main()
{
  ...
}
2. Leave the function after main(), but include a prototype, e.g.

Code:
void ShowMessage();

int main()
{
 ...
}

void ShowMessage()
{
 ...
}
Is this not covered in the book/tutorial you used/are using to learn C++?
 
Old 05-31-2012, 06:38 AM   #7
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks a lot. In Visual C++, there is one given function like MessageBox. Do we have the equivalence for it in Solaris studio C++? Before this, I thought ShowMessage is the equivalent one for MessageBox.

Best Regards
 
Old 05-31-2012, 06:41 AM   #8
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
I don't know, as I've never used Solaris Studio. Perhaps check their documentation. As an aside, you might want to also consider using, e.g. Qt to generate dialog boxes. At least that way, it'd be more portable between compilers.
 
1 members found this post helpful.
Old 05-31-2012, 06:43 AM   #9
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks. Is Qt also supported in Visual C++ or not?

Best regards
 
Old 05-31-2012, 06:47 AM   #10
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
It looks like Qt supports Visual C++, yes. If you don't know anything about Qt, it's a whole "application framework" that provides with the ability to do, e.g. multi-threading, database access, as well as GUIs. There's more info on the Qt website.
 
Old 05-31-2012, 08:50 PM   #11
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Good day Nylex,
When I tired to put this
#include <QDialog>

I’ve got this. What Qt library should be download?
"main.cpp", line 10: Error: Could not open include file<QDialog>.

Many Thanks & Best Regards,
HuaMin
 
Old 05-31-2012, 11:53 PM   #12
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Did you try installing Qt already? Obviously it's not going to be on your system if not. Obviously, as well, you need to tell the compiler where to find the headers and library files.

See the download page here. I assume the Windows online (or offline) installer is what you want. You might want to install the Visual Studio add-in as well, though I don't know as I don't use Windows.
 
Old 06-01-2012, 12:23 AM   #13
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks.
No, all are done within Red hat, as Solaris studio is for Linux & Unix only.

Last edited by Huamin; 06-01-2012 at 12:41 AM.
 
Old 06-01-2012, 01:51 AM   #14
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
The Qt installation on your system was likely compiled with the GNU compiler. I've never tried, but I don't know whether it's possible to make use of libraries built with a different compiler. One issue you may have is to do with name mangling (see the Wikipedia article on it). So, this may mean you need to first build Qt with Solaris Studio. Is there a reason for you not to use g++?

Also, is it possible to edit your thread title? If not, ask a mod to do it. Hopefully that will help attract someone more able to help you.
 
Old 06-01-2012, 02:44 AM   #15
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks a lot Nylex.
Moderator,
Can you please change the title of this to be

Use Qt for a Dialog in Solaris studio

Nylex,
What is g++?

Many Thanks & Best Regards,
HuaMin
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Solaris studio Huamin Linux - Software 29 05-29-2012 11:41 PM
LXer: Oracle gooses Studio compilers for Solaris, Linux LXer Syndicated Linux News 0 12-19-2011 09:20 PM
Using Solaris Studio to compile GCC Mark_667 Solaris / OpenSolaris 4 10-13-2011 05:07 AM
Studio to studio or studio to transmitter stable open source solution MATRIX_q Linux - Server 0 08-25-2011 03:44 AM
Solaris 10 + Studio 11 rleesBSD Solaris / OpenSolaris 2 04-05-2006 03:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration