Page 1 of 1

Compiler, Terminal, and Project Question.

Posted: Fri Nov 11, 2016 10:16 pm
by chappykhmao
Ok, so I'm on linux and I'm relatively new to this IDE coming from Visual Studios. I have four important questions that I can't seem to find the answer to.

The first question is how would I set the compiler to default use the -std=c++14 or -std=++11 on each project by default. I know how to set it manually, but I don't want to do it every single time I create a project.

My second question how would I get my code to run on a certain terminal? So far I'm using the built in terminal CodeLite provides, but I want to use the gnome terminal.

My third question would be importing existing files. I have projects with many cpp and hpp files and when I seem to import all of them into the virtual 'src' folder in each project, it seems to not recognize my header files. When I select the 'New Class...' option it just creates a new one. And I am just confused in the 'New Class from Template' option. I just want to add files that are already created.

And finally my last question is a small one, but when I create a project, how could I just create an empty one. It seems to always create a main.cpp file with C code already filled out. It's kind of annoying.

Re: Compiler, Terminal, and Project Question.

Posted: Fri Nov 11, 2016 10:50 pm
by eranif
chappykhmao wrote:The first question is how would I set the compiler to default use the -std=c++14 or -std=++11 on each project by default. I know how to set it manually, but I don't want to do it every single time I create a project.
You can create your own template. Create a new project, alter the project settings by adding the -std=c++11 or 14
Next, right click the project and select "save as template" give it a name and use it for future projects
chappykhmao wrote:My second question how would I get my code to run on a certain terminal?
CodeLite uses the x-terminal-emulator. You can use update-alternatives to use change that (search the forum for similar questions)
chappykhmao wrote:My third question would be importing existing files. I have projects with many cpp and hpp files and when I seem to import all of them into the virtual 'src' folder in each project, it seems to not recognize my header files. When I select the 'New Class...' option it just creates a new one. And I am just confused in the 'New Class from Template' option. I just want to add files that are already created.
Right click a project and select "Import files from directory"
chappykhmao wrote:And finally my last question is a small one, but when I create a project, how could I just create an empty one. It seems to always create a main.cpp file with C code already filled out. It's kind of annoying.
Same as my first answer: create new project remove the file and save it as template

Eran

Re: Compiler, Terminal, and Project Question.

Posted: Fri Nov 11, 2016 11:10 pm
by chappykhmao
Thanks for answering the other questions.
eranif wrote: Right click a project and select "Import files from directory"
Sorry I should've been more specific with my question.
I know how to import all of the files from a directory into the project.
But for some reason It doesn't compile right when it should.

from the terminal if I compile all my .cpp and .hpp files with g++
For example: g++ main.cpp ProtoFish.cpp ProtoFish.hpp Shark.cpp Shark.hpp
it would compile correctly

but when I put it into CodeLite, it would say something like "fatal error: Shark.hpp: No such file or directory"
All the files I need are in that project. I'm not sure what is going on.

Re: Compiler, Terminal, and Project Question.

Posted: Fri Nov 11, 2016 11:22 pm
by eranif
Post the build log (see my signature)

Eran

Re: Compiler, Terminal, and Project Question.

Posted: Fri Nov 11, 2016 11:58 pm
by chappykhmao

Code: Select all

/bin/sh -c '/usr/bin/make -j4 -e -f  Makefile'
----------Building project:[ program6sharksnfish - Debug ]----------
make[1]: Entering directory '/home/chapshaun/Workspace/CodeLite/program6sharksnfish'
/usr/bin/g++  -c  "/home/chapshaun/Workspace/CodeLite/program6sharksnfish/main.cpp" -g -O3 -O0 -std=c++14 -std=c++11 -Wall  -o ./Debug/main.cpp.o -I. -I.
/usr/bin/g++  -c  "/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Shark.cpp" -g -O3 -O0 -std=c++14 -std=c++11 -Wall  -o ./Debug/Shark.cpp.o -I. -I.
/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Shark.cpp:1:21: fatal error: Shark.hpp: No such file or directory
 #include "Shark.hpp"
                     ^
compilation terminated.
program6sharksnfish.mk:119: recipe for target 'Debug/Shark.cpp.o' failed
make[1]: *** [Debug/Shark.cpp.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/home/chapshaun/Workspace/CodeLite/program6sharksnfish/main.cpp:9:65: fatal error: Shark.hpp: No such file or directory
 #include "Shark.hpp"  // TODO: uncomment to test fish and sharks
                                                                 ^
compilation terminated.
program6sharksnfish.mk:103: recipe for target 'Debug/main.cpp.o' failed
make[1]: *** [Debug/main.cpp.o] Error 1
make[1]: Leaving directory '/home/chapshaun/Workspace/CodeLite/program6sharksnfish'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
====3 errors, 0 warnings====

Re: Compiler, Terminal, and Project Question.

Posted: Sat Nov 12, 2016 12:07 am
by eranif
Well... add the path to the header file...
project settings->compiler->include paths

Eran

Re: Compiler, Terminal, and Project Question.

Posted: Sat Nov 12, 2016 12:17 am
by chappykhmao
Ok I added all the hpp files to the include paths area.

Code: Select all

/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Shark.hpp
/home/chapshaun/Workspace/CodeLite/program6sharksnfish/ProtoFish.hpp
/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Fish.hpp
/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Direction.hpp
and this is the build log
/bin/sh -c '/usr/bin/make -j4 -e -f Makefile'
----------Building project:[ program6sharksnfish - Debug ]----------
make[1]: Entering directory '/home/chapshaun/Workspace/CodeLite/program6sharksnfish'
/usr/bin/g++ -c "/home/chapshaun/Workspace/CodeLite/program6sharksnfish/main.cpp" -g -O3 -O0 -std=c++14 -std=c++11 -Wall -o ./Debug/main.cpp.o -I. -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Shark.hpp -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/ProtoFish.hpp -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Fish.hpp -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Direction.hpp
/usr/bin/g++ -c "/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Shark.cpp" -g -O3 -O0 -std=c++14 -std=c++11 -Wall -o ./Debug/Shark.cpp.o -I. -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Shark.hpp -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/ProtoFish.hpp -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Fish.hpp -I/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Direction.hpp
cc1plus: warning: /home/chapshaun/Workspace/CodeLite/program6sharksnfish/ProtoFish.hpp: not a directory
cc1plus: warning: /home/chapshaun/Workspace/CodeLite/program6sharksnfish/Fish.hpp: not a directory
cc1plus: warning: /home/chapshaun/Workspace/CodeLite/program6sharksnfish/Direction.hpp: not a directory
cc1plus: warning: /home/chapshaun/Workspace/CodeLite/program6sharksnfish/ProtoFish.hpp: not a directory
cc1plus: warning: /home/chapshaun/Workspace/CodeLite/program6sharksnfish/Fish.hpp: not a directory
cc1plus: warning: /home/chapshaun/Workspace/CodeLite/program6sharksnfish/Direction.hpp: not a directory
/home/chapshaun/Workspace/CodeLite/program6sharksnfish/main.cpp:9:65: fatal error: Shark.hpp: No such file or directory
#include "Shark.hpp" // TODO: uncomment to test fish and sharks
^
compilation terminated.
program6sharksnfish.mk:103: recipe for target 'Debug/main.cpp.o' failed
make[1]: *** [Debug/main.cpp.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/home/chapshaun/Workspace/CodeLite/program6sharksnfish/Shark.cpp:4:21: fatal error: Shark.hpp: No such file or directory
#include "Shark.hpp"
^
compilation terminated.
program6sharksnfish.mk:119: recipe for target 'Debug/Shark.cpp.o' failed
make[1]: *** [Debug/Shark.cpp.o] Error 1
make[1]: Leaving directory '/home/chapshaun/Workspace/CodeLite/program6sharksnfish'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
====3 errors, 0 warnings====

Re: Compiler, Terminal, and Project Question.

Posted: Sat Nov 12, 2016 12:30 am
by eranif
Ok I added all the hpp files to the include paths area.
Hmm, more of a compiler related question, but you need to add folders not each file. i.e. add the path to the location of "Shark.hpp"

Re: Compiler, Terminal, and Project Question.

Posted: Sat Nov 12, 2016 12:39 am
by chappykhmao
eranif wrote:
Ok I added all the hpp files to the include paths area.
Hmm, more of a compiler related question, but you need to add folders not each file. i.e. add the path to the location of "Shark.hpp"
I figured it out, sorry for the trouble, apparently my Shark.hpp file was corrupted now its working.