c++ - include class and compile with g++ -


I am the first in C ++ and working with Unix. So my question is

I have written a few lines in the main function, and I need the function, which is defined in the c_lib - library.

main.cpp:

#include & lt; Iostream & gt; #include "c_lib.cpp" int main () {Return 0; }

I want to execute it on the terminal, so I wrote

  g ++ -c c_lib.cpp g ++ -c main.cpp G ++ -o run C_lib.o main.o  

To this point, there are no error reports.

Then

 . / Run  

I get an error

Error: ./run: Any such file or directory

That's wrong?

with a .cpp is usually not done, usually only Headers are included. Headers usually have announcements that define the interface code in the second .cpp
Can we show us the source of c_lib? It can be helpful.

The source of c_lib is #include , there is no need to compile it separately. In fact it can cause errors / (first of all to come to mind many definitions). All you need to do is: In this case,

  g ++ -o run main.cpp  

to compile your code. Header ( .h ), you will need to compile the implementation ( .cpp ) separately)

Compiled with warnings on:

G ++ -Wall -Wextra -o run main.cpp

And if there are problems with your code, you will get more output.

Is there a run file to be output by GCC? You can check LS in the terminal (or ls run can only be executable for calling, if it exists).

If the executor is present, it may be that it is not marked as runable. I go into it if it is a problem because it is outside the normal range of the site (although still Related)


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -