How to compile and link separated .h and .cpp files in C++ using the command line?

Nogurenn

I wanted to separate function definitions and function headers using folders but I get a fatal error saying "x.h" was not found. The filenames provided below are just samples. Is this even possible?

This is the line I'm using:

g++ -I ./headers/ -o main2.o main2.cpp ./definitions/x.cpp 
P0W

If you're sure you've correct files in correct path, one issue is :-

There shouldn't be any space after -I and use just ./headers

g++ -I./headers -o main2.o main2.cpp ./definitions/x.cpp 
      ^^No Space

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I compile and link multiple files from the command line?

From Dev

What's command line to compile 2 files into a single exe that uses the math.h library in C

From Dev

How to compile set of java files in different packages and then build .jar file using command line?

From Dev

Makefile to compile both c and cpp files

From Dev

how to rename files using command line

From Dev

How to download files using WinSCP command line?

From Dev

How to copy a number of files using command line?

From Dev

Does splitting your files into .cpp and .h decrease compile time?

From Dev

How to compile Android Project's with Windows command line using script?

From Dev

how to compile and start a Java undertow HTTP server using command line

From Dev

Unable to compile and link simple C++ program with Visual Studio 2015 command line tools

From Dev

How to use .cpp and .h files inside subdirectories?

From Dev

Removing Specific Line from Multiples files (.cpp /.h) in multiple directories

From Dev

How to link, and compile, a C++ code using GNU Octave functions?

From Dev

Compile and link two files using cmake?

From Dev

C - Using .h files

From Dev

How to create a makefile for several .cpp files with .h files and main.cpp without a .h

From Dev

How do I remove errors after creating .h and .cpp files for a class? C++

From Dev

Cannot compile c file from command line

From Dev

Windows Command line c file compile error

From Dev

Using the make command to compile class files

From Dev

How do I easily rename multiple files using command line?

From Dev

Elasticsearch how to index text files using the command line

From Dev

How to script the rename of multiple files using the Mac command line

From Dev

How do I easily rename multiple files using command line?

From Dev

How to ZIP specific files from a folder using Winzip command line?

From Dev

Elasticsearch how to index text files using the command line

From Dev

How do I upload files using the command line on Windows?

From Dev

How can I get a count of files in a directory using the command line?

Related Related

  1. 1

    How do I compile and link multiple files from the command line?

  2. 2

    What's command line to compile 2 files into a single exe that uses the math.h library in C

  3. 3

    How to compile set of java files in different packages and then build .jar file using command line?

  4. 4

    Makefile to compile both c and cpp files

  5. 5

    how to rename files using command line

  6. 6

    How to download files using WinSCP command line?

  7. 7

    How to copy a number of files using command line?

  8. 8

    Does splitting your files into .cpp and .h decrease compile time?

  9. 9

    How to compile Android Project's with Windows command line using script?

  10. 10

    how to compile and start a Java undertow HTTP server using command line

  11. 11

    Unable to compile and link simple C++ program with Visual Studio 2015 command line tools

  12. 12

    How to use .cpp and .h files inside subdirectories?

  13. 13

    Removing Specific Line from Multiples files (.cpp /.h) in multiple directories

  14. 14

    How to link, and compile, a C++ code using GNU Octave functions?

  15. 15

    Compile and link two files using cmake?

  16. 16

    C - Using .h files

  17. 17

    How to create a makefile for several .cpp files with .h files and main.cpp without a .h

  18. 18

    How do I remove errors after creating .h and .cpp files for a class? C++

  19. 19

    Cannot compile c file from command line

  20. 20

    Windows Command line c file compile error

  21. 21

    Using the make command to compile class files

  22. 22

    How do I easily rename multiple files using command line?

  23. 23

    Elasticsearch how to index text files using the command line

  24. 24

    How to script the rename of multiple files using the Mac command line

  25. 25

    How do I easily rename multiple files using command line?

  26. 26

    How to ZIP specific files from a folder using Winzip command line?

  27. 27

    Elasticsearch how to index text files using the command line

  28. 28

    How do I upload files using the command line on Windows?

  29. 29

    How can I get a count of files in a directory using the command line?

HotTag

Archive