Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Console 'Hello World' won't build.
Console 'Hello World' won't build. [message #10906] Fri, 03 August 2007 23:30 Go to next message
JohnO is currently offline  JohnO
Messages: 4
Registered: August 2007
Location: Ireland
Junior Member
Hi,
Here is a simple console program which won't build (in theIDE).
It gives this error:

syntax error : missing ';' before identifier 'a'

This code is basically from the Core value types tutorial.
Type 'String' doesn't appear to be recognised.
Any idea what's up with this code?

Thanks,
John

---------------------------
#include "stdio.h"
#include <iostream>

using namespace Upp;

int main(int argc, const char *argv[])
{
char dummy;
String a;

a = "Howdy";
a = a + " Partner!";

std::cerr << "Hello, platform! " << std::endl;
std::cerr << a << std::endl;
std::cin >> dummy;
return 0;
}
Re: Console 'Hello World' won't build. [message #10907 is a reply to message #10906] Sat, 04 August 2007 01:35 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
If I recall well, one can't use "naked" "main" function with U++...
Have a look at console apps examples (e.g CParser)

3 minimum U++ requirements :

1. include at least one U++ package which recursively includes <Core/Core.h>

2. Your code must be wrapped inside:
2.a
 CONSOLE_APP_MAIN
{
...
}

OR
2.b
 GUI_APP_MAIN
{
...
}

3. Main package configuration flags must be set accordingly: CONSOLE or GUI.


====
"String" is not recognized because it gets included with "Core" mentioned above.

[Updated on: Sat, 04 August 2007 01:37]

Report message to a moderator

Re: Console 'Hello World' won't build. [message #10908 is a reply to message #10907] Sat, 04 August 2007 03:09 Go to previous messageGo to next message
JohnO is currently offline  JohnO
Messages: 4
Registered: August 2007
Location: Ireland
Junior Member
Hi,
Thanks for the reply - much appreciated.
I'm not sure that you really need the

CONSOLE_APP_MAIN
{
...
}

construct when building/executing a console-mode program from
within theIDE. Certainly the sample program (Prog_1) below compiles
and executes fine without it.

The second program (Prog_2) is just a minor modification of it using String (with
the <Core/Core.h> headers added) and it won't build. It still does
not recognise String. What other modification is required to Prog_2
to make it work?

Thanks.
John


------ Prog_1 -------
#include "stdio.h"
#include <iostream>

int main(int argc, const char *argv[])
{
char dummy;

std::cerr << "Hello, world! " << std::endl;

std::cin >> dummy;
return 0;
}


------ Prog_2 -------
#include "stdio.h"
#include <iostream>
#include <Core/Core.h>

int main(int argc, const char *argv[])
{
char dummy;
String a;

a = "Hello, world!";
std::cerr << a << std::endl;

std::cin >> dummy;
return 0;
}
Re: Console 'Hello World' won't build. [message #10916 is a reply to message #10908] Sat, 04 August 2007 18:20 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Post the contents of your *.upp file

Edit: P.S. this topic might be useful?:
http://www.ultimatepp.org/forum/index.php?t=msg&th=2558& amp;start=0&

[Updated on: Sat, 04 August 2007 18:46]

Report message to a moderator

Re: Console 'Hello World' won't build. [message #10934 is a reply to message #10906] Sun, 05 August 2007 19:42 Go to previous messageGo to next message
JohnO is currently offline  JohnO
Messages: 4
Registered: August 2007
Location: Ireland
Junior Member
Hi,
Where would I find the .upp file - I don't seem to have one.
Could this be the problem?

I tried this (below) too, but it also wouldn't build.

Thanks,
John


------ Prog_3 ------
#include "stdio.h"
#include <iostream>
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
char dummy;
String a;

a = "Hello, world!";
std::cerr << a << std::endl;

std::cin >> dummy;
}
Re: Console 'Hello World' won't build. [message #10935 is a reply to message #10906] Sun, 05 August 2007 20:07 Go to previous messageGo to next message
JohnO is currently offline  JohnO
Messages: 4
Registered: August 2007
Location: Ireland
Junior Member
Hi,
Another thing - Prog_1 (above) builds and runs as expected.
But if you simply include the <Core/Core.h> headers (even though
they are not needed), it no longer builds.
Surely HelloWorld apps can't be this tricky, right?

#include "stdio.h"
#include <iostream>
#include <Core/Core.h> // <-- adding this causes build to fail

int main(int argc, const char *argv[])
{
char dummy;

std::cerr << "Hello, world!" << std::endl;

std::cin >> dummy;
}
Re: Console 'Hello World' won't build. [message #10936 is a reply to message #10906] Sun, 05 August 2007 20:35 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Your include paths are not set up correctly.

Did you create your own assembly in the "Set main package" dialog?

If yes, add the path to uppsrc (in upp directory) next to path of your own assembly. Check this post:
http://www.ultimatepp.org/forum/index.php?t=msg&goto=108 30&#msg_10830

The [project].upp file is located inside the directory of your package (which is located inside the chosen assembly).
If not, you are using IDE's assemblies and packages in wrong way, or you have your IDE already mis-configured.

If you open some example, does it compile ok?
Re: Console 'Hello World' won't build. [message #10937 is a reply to message #10936] Sun, 05 August 2007 21:32 Go to previous messageGo to next message
mezise is currently offline  mezise
Messages: 54
Registered: April 2006
Member
Hi John, please check this up:
1. New package
2. Choose "Console application (no U++)"
3. Take your first code posted in this topic
4. Add: #include <Core/Core.h>
5. MENU->Project->Add package to...->(Choose "Core")
6. Add operator ~ to "a" variable to get const char in line:
std::cerr << ~a << std::endl;

7. It compiles OK.

Michal
Re: Console 'Hello World' won't build. [message #10939 is a reply to message #10936] Sun, 05 August 2007 21:41 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Ok, correct me if I'm wrong:

If I recall well, one can't use "naked" "main" function with U++... (I didn't say C++ !!! Smile )
Have a look at console apps examples (e.g CParser)


*** 3 minimum requirements If you use U++ ***
(but you have to be able to compile Upp examples first!!!)

You have to have:

=========
1. at least one #include in at least one of your files (directly or recursively) usually
1.a <Core/Core.h> for CONSOLE apps
<CtrlLib/CtrlLib.h> for GUI apps

1.b (Synchronically, in parallel or any similar word of your choice) at least one U++ package with the same name added to
to your packages (check the top-left list of names (they are the names of packages) or in MyPackageName.upp file)
[How to find MyPackageName.upp file - a separate topic]
=========
2. your code wrapped inside:
2.a
 CONSOLE_APP_MAIN
{
...
}

OR
2.b
 GUI_APP_MAIN
{
...
}

==========
3. Main package configuration flags set accordingly: CONSOLE or GUI.


Edit:
BTW, have you read this:
http://www.ultimatepp.org/app$ide$GettingStarted$en-us.html

[Updated on: Sun, 05 August 2007 21:51]

Report message to a moderator

Previous Topic: What compiler are you using with Ultimate++?
Next Topic: Intel compiler
Goto Forum:
  


Current Time: Tue Apr 23 22:11:51 CEST 2024

Total time taken to generate the page: 0.01288 seconds