Page 1 of 1

(SOLVED) #include <x> not working, c++

Posted: Mon Aug 31, 2015 4:14 am
by Speedicus
Running Windows 10, CodeLite version 8.1, Mingw32/64, TDM GCC 64, Not self compiled as far as I know.

The problem is that whenever I try to manually use #include <x>, where x is the library (or whatever you call it, sorry I am new to the langauge). Iostream, ctime, and others do not work, which is hindering my progress. I also submitted this as a issue via github.

Build Output:

Code: Select all

C:\WINDOWS\system32\cmd.exe /C "C:/TDM-GCC-64/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f  Makefile"
"----------Building project:[ Time - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/dylan/Desktop/Time'
mingw32-make.exe[1]: Leaving directory 'C:/Users/dylan/Desktop/Time'
mingw32-make.exe[1]: Entering directory 'C:/Users/dylan/Desktop/Time'
C:/TDM-GCC-64/bin/gcc.exe -c  "C:/Users/dylan/Desktop/Time/main.c" -g -O0 -Wall  -o ./Debug/main.c.o -I. -I.
C:/Users/dylan/Desktop/Time/main.c:2:20: fatal error: iostream: No such file or directory
compilation terminated.
mingw32-make.exe[1]: *** [Debug/main.c.o] Error 1
Time.mk:97: recipe for target 'Debug/main.c.o' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/dylan/Desktop/Time'
Makefile:4: recipe for target 'All' failed
mingw32-make.exe: *** [All] Error 2
2 errors, 0 warnings
Actual Code:

Code: Select all

#include <stdio.h>
#include <iostream>
#include <ctime>


int main(int argc, char **argv)
{
	printf("hello world\n");
	return 0;
}

Re: #include <x> not working, c++

Posted: Mon Aug 31, 2015 11:26 am
by Jarod42
You should change extension of your files to .cpp
It is currently compiler as C (not C++) with simple extension .c

that's why C header `<stdio.h>` is included but not C++ header `<iostream>`

Re: #include <x> not working, c++

Posted: Mon Aug 31, 2015 10:50 pm
by Speedicus
Wow, your right!

I put this together this morning when I was on mobile and couln't reply/test my theory out, but thanks for confirming. This does make sense as my teacher is working on C with us right now.

Coolio.