How to build an Xcode c++ program on terminal - c++

I am using Xcode to program c++ projects. I am using ncurses library.
I am create a simple example, which works fine on terminal, but it does not work using xcode.
#include<ncurses.h>
#include<iostream>
int main()
{
char c;
initscr();
printw("Hello world!");
refresh();
c=getch();
endwin();
return 0;
}
On Xcode I get this error
Error opening terminal: unknown.
I am wondering that Xcode is not able to emulate an terminal. So, I try to change the "build phase" in xcode in order to build my project on terminal. I have used the proposed solution Automatically open terminal when debugging in Xcode?
But my project continue to run on xcode. What is the problem?

Related

Notepad++ NppExec console warning, need explanation "C++"

I've tried using Notepad++ to code c++ and followed a few tutorials on youtube, here's what I did:
-Installed gcc/g++ compiler using mingw64
-Installed NppExec plugin on N++
-Typed in the following compilier script and saved as C++:
NPP_SAVE cd $(CURRENT_DIRECTORY) g++ $(FILE_NAME) cmd /c $(CURRENT_DIRECTORY)\program.exe
Anyways whenever compiling a program, for example a simple program
#include <iostream>
using namespace std;
int main(){
cout << "Online\n";
system("pause"); //So that cmd doesn't disappear immeadiately on running.
return 0;
}
The console displays the following warning:
"C:\Users\pc\Desktop\Courses\Projects\C\program.exe' is not recognized as an internal or external command, operable program or batch file."
My question is, When I run the program on cmd, it runs perfectly but the error displayed during linking says that the folder does not exist in %PATH%
Any explanation?
Thank you!
Ok so, what I basically did was change the script,
cmd /c $(CURRENT_DIRECTORY)\program.exe
To be later
cmd /c $(CURRENT_DIRECTORY)\a.exe
the console worked fine and even received input
Here is a link to a similar problem:
How to compile/execute C++ code from within Notepad++

My terminal in VS Code won't print anything or give me an error. Don't know why it is not printing

Just installed Visual Studio Code with C/C++ IntelliSense... (Microsoft) and Code Runner extensions. I am also using MinGW. This code refuses to print to my terminal.
#include<stdio.h>
int main(){
printf("Hello World");
}
While viewing this file press Ctrl+Shift+P and type Run Code and press enter.
You should see a terminal opened with OUTPUT tab and see the result or an error.
If an error occurs publish it alongside with your question.

QtCreator returns error "Cannot change to working directory"

I'm trying to running a simple HelloWorld program with Qt Creator
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
When running occurs the error
Cannot change to working directory '/home/myusername/build-myproject-Desktop-Debug': file or directory not found
Many tutorials in the internet tell me to disable "Run in terminal", but I need this for my project.
My working directory is /home/myusername/build-myproject-Desktop-Debug
Any help?
Which OS are you running?
I'm on Linux and had the same problem. My solution was to use xterm and set the default Terminal in Qtcreator to xterm (In the menu: Tools, then Options, then Environment, then Terminal, there "/usr/bin/xterm -e")
You can install Terminator terminal (sudo apt-get install terminator) and use it as Qt Creator terminal:
Tools->Options->Enviroment->System->Terminal->"/usr/bin/terminator -x"

QtCreator and ncurses

I have a little program with C++ and ncurses in QtCreator:
#include <ncurses.h>
int main()
{
initscr();// inicializa pantalla
printw("Hello world!");
refresh();
getch();
endwin();
}
but when is opened xterm, it says:
Error opening terminal:unknown
It occured in Eclipse...
I've installed ncurses library correctly.
I run my code from console right.
On the Projects tab, Targets, Desktop, Run, Run Environment. Look for the TERM variable. If no found, add it and on the value of it, write xterm

How do I run a C++ program in Xcode 4?

I want to write a C++ program in Xcode on my Mac. I wrote this basic one to test it. When I build, I get a "Build Successful" message.
However, I cannot run it! If I hit Command+R nothing happens. When I go to Project->Run the Run option is disabled.
#include <iostream>
using namespace std;
int main()
{
cout << "helo" << endl;
}
Launch XCode
In the "Choose template" box, pick Mac OS X, then Command Line Tool. Press Next
Give your project a name, select C++ as the type
You should see a new project with main.cpp
press the Run button
At the bottom of the screen, under All Output you should see:
Hello, World!
Program ended with exit code: 0