You are not logged in.

#1 2013-08-28 22:17:44

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

g++ isn't compiling!

So, I noticed this yesterday, thinking it was application specific. Now I've tried compiling with multiple pieces of code that I've written, all of which compiled successfully at most a week ago. The following paste is from an attempt on a simple example (so as to minimize the amount to paste). I don't know what I did to cause this. Any ideas?

g++  -c main.cpp
In file included from main.cpp:1:0:
/usr/include/c++/4.8.1/cstdlib:118:11: error: ‘::div_t’ has not been declared
   using ::div_t;
           ^
/usr/include/c++/4.8.1/cstdlib:119:11: error: ‘::ldiv_t’ has not been declared
   using ::ldiv_t;
           ^
/usr/include/c++/4.8.1/cstdlib:121:11: error: ‘::abort’ has not been declared
   using ::abort;
           ^
/usr/include/c++/4.8.1/cstdlib:122:11: error: ‘::abs’ has not been declared
   using ::abs;
           ^
/usr/include/c++/4.8.1/cstdlib:123:11: error: ‘::atexit’ has not been declared
   using ::atexit;
           ^
/usr/include/c++/4.8.1/cstdlib:129:11: error: ‘::atof’ has not been declared
   using ::atof;
           ^
/usr/include/c++/4.8.1/cstdlib:130:11: error: ‘::atoi’ has not been declared
   using ::atoi;
           ^
/usr/include/c++/4.8.1/cstdlib:131:11: error: ‘::atol’ has not been declared
   using ::atol;
           ^
/usr/include/c++/4.8.1/cstdlib:132:11: error: ‘::bsearch’ has not been declared
   using ::bsearch;
           ^
/usr/include/c++/4.8.1/cstdlib:133:11: error: ‘::calloc’ has not been declared
   using ::calloc;
           ^
/usr/include/c++/4.8.1/cstdlib:134:11: error: ‘::div’ has not been declared
   using ::div;
           ^
/usr/include/c++/4.8.1/cstdlib:135:11: error: ‘::exit’ has not been declared
   using ::exit;
           ^
/usr/include/c++/4.8.1/cstdlib:136:11: error: ‘::free’ has not been declared
   using ::free;
           ^
/usr/include/c++/4.8.1/cstdlib:137:11: error: ‘::getenv’ has not been declared
   using ::getenv;
           ^
/usr/include/c++/4.8.1/cstdlib:138:11: error: ‘::labs’ has not been declared
   using ::labs;
           ^
/usr/include/c++/4.8.1/cstdlib:139:11: error: ‘::ldiv’ has not been declared
   using ::ldiv;
           ^
/usr/include/c++/4.8.1/cstdlib:140:11: error: ‘::malloc’ has not been declared
   using ::malloc;
           ^
/usr/include/c++/4.8.1/cstdlib:142:11: error: ‘::mblen’ has not been declared
   using ::mblen;
           ^
/usr/include/c++/4.8.1/cstdlib:143:11: error: ‘::mbstowcs’ has not been declared
   using ::mbstowcs;
           ^
/usr/include/c++/4.8.1/cstdlib:144:11: error: ‘::mbtowc’ has not been declared
   using ::mbtowc;
           ^
/usr/include/c++/4.8.1/cstdlib:146:11: error: ‘::qsort’ has not been declared
   using ::qsort;
           ^
/usr/include/c++/4.8.1/cstdlib:152:11: error: ‘::rand’ has not been declared
   using ::rand;
           ^
/usr/include/c++/4.8.1/cstdlib:153:11: error: ‘::realloc’ has not been declared
   using ::realloc;
           ^
/usr/include/c++/4.8.1/cstdlib:154:11: error: ‘::srand’ has not been declared
   using ::srand;
           ^
/usr/include/c++/4.8.1/cstdlib:155:11: error: ‘::strtod’ has not been declared
   using ::strtod;
           ^
/usr/include/c++/4.8.1/cstdlib:156:11: error: ‘::strtol’ has not been declared
   using ::strtol;
           ^
/usr/include/c++/4.8.1/cstdlib:157:11: error: ‘::strtoul’ has not been declared
   using ::strtoul;
           ^
/usr/include/c++/4.8.1/cstdlib:158:11: error: ‘::system’ has not been declared
   using ::system;
           ^
/usr/include/c++/4.8.1/cstdlib:160:11: error: ‘::wcstombs’ has not been declared
   using ::wcstombs;
           ^
/usr/include/c++/4.8.1/cstdlib:161:11: error: ‘::wctomb’ has not been declared
   using ::wctomb;
           ^
/usr/include/c++/4.8.1/cstdlib:168:10: error: ‘ldiv_t’ does not name a type
   inline ldiv_t
          ^
/usr/include/c++/4.8.1/cstdlib:201:11: error: ‘::lldiv_t’ has not been declared
   using ::lldiv_t;
           ^
/usr/include/c++/4.8.1/cstdlib:207:11: error: ‘::_Exit’ has not been declared
   using ::_Exit;
           ^
/usr/include/c++/4.8.1/cstdlib:211:11: error: ‘::llabs’ has not been declared
   using ::llabs;
           ^
/usr/include/c++/4.8.1/cstdlib:213:10: error: ‘lldiv_t’ does not name a type
   inline lldiv_t
          ^
/usr/include/c++/4.8.1/cstdlib:217:11: error: ‘::lldiv’ has not been declared
   using ::lldiv;
           ^
/usr/include/c++/4.8.1/cstdlib:228:11: error: ‘::atoll’ has not been declared
   using ::atoll;
           ^
/usr/include/c++/4.8.1/cstdlib:229:11: error: ‘::strtoll’ has not been declared
   using ::strtoll;
           ^
/usr/include/c++/4.8.1/cstdlib:230:11: error: ‘::strtoull’ has not been declared
   using ::strtoull;
           ^
/usr/include/c++/4.8.1/cstdlib:232:11: error: ‘::strtof’ has not been declared
   using ::strtof;
           ^
/usr/include/c++/4.8.1/cstdlib:233:11: error: ‘::strtold’ has not been declared
   using ::strtold;
           ^
/usr/include/c++/4.8.1/cstdlib:241:22: error: ‘__gnu_cxx::lldiv_t’ has not been declared
   using ::__gnu_cxx::lldiv_t;
                      ^
/usr/include/c++/4.8.1/cstdlib:243:22: error: ‘__gnu_cxx::_Exit’ has not been declared
   using ::__gnu_cxx::_Exit;
                      ^
/usr/include/c++/4.8.1/cstdlib:245:22: error: ‘__gnu_cxx::llabs’ has not been declared
   using ::__gnu_cxx::llabs;
                      ^
/usr/include/c++/4.8.1/cstdlib:246:22: error: ‘__gnu_cxx::div’ has not been declared
   using ::__gnu_cxx::div;
                      ^
/usr/include/c++/4.8.1/cstdlib:247:22: error: ‘__gnu_cxx::lldiv’ has not been declared
   using ::__gnu_cxx::lldiv;
                      ^
/usr/include/c++/4.8.1/cstdlib:249:22: error: ‘__gnu_cxx::atoll’ has not been declared
   using ::__gnu_cxx::atoll;
                      ^
/usr/include/c++/4.8.1/cstdlib:250:22: error: ‘__gnu_cxx::strtof’ has not been declared
   using ::__gnu_cxx::strtof;
                      ^
/usr/include/c++/4.8.1/cstdlib:251:22: error: ‘__gnu_cxx::strtoll’ has not been declared
   using ::__gnu_cxx::strtoll;
                      ^
/usr/include/c++/4.8.1/cstdlib:252:22: error: ‘__gnu_cxx::strtoull’ has not been declared
   using ::__gnu_cxx::strtoull;
                      ^
/usr/include/c++/4.8.1/cstdlib:253:22: error: ‘__gnu_cxx::strtold’ has not been declared
   using ::__gnu_cxx::strtold;
                      ^
In file included from main.cpp:2:0:
/usr/include/c++/4.8.1/cstdio:95:11: error: ‘::FILE’ has not been declared
   using ::FILE;
           ^
/usr/include/c++/4.8.1/cstdio:96:11: error: ‘::fpos_t’ has not been declared
   using ::fpos_t;
           ^
/usr/include/c++/4.8.1/cstdio:98:11: error: ‘::clearerr’ has not been declared
   using ::clearerr;
           ^
/usr/include/c++/4.8.1/cstdio:99:11: error: ‘::fclose’ has not been declared
   using ::fclose;
           ^
/usr/include/c++/4.8.1/cstdio:100:11: error: ‘::feof’ has not been declared
   using ::feof;
           ^
/usr/include/c++/4.8.1/cstdio:101:11: error: ‘::ferror’ has not been declared
   using ::ferror;
           ^
/usr/include/c++/4.8.1/cstdio:102:11: error: ‘::fflush’ has not been declared
   using ::fflush;
           ^
/usr/include/c++/4.8.1/cstdio:103:11: error: ‘::fgetc’ has not been declared
   using ::fgetc;
           ^
/usr/include/c++/4.8.1/cstdio:104:11: error: ‘::fgetpos’ has not been declared
   using ::fgetpos;
           ^
/usr/include/c++/4.8.1/cstdio:105:11: error: ‘::fgets’ has not been declared
   using ::fgets;
           ^
/usr/include/c++/4.8.1/cstdio:106:11: error: ‘::fopen’ has not been declared
   using ::fopen;
           ^
/usr/include/c++/4.8.1/cstdio:107:11: error: ‘::fprintf’ has not been declared
   using ::fprintf;
           ^
/usr/include/c++/4.8.1/cstdio:108:11: error: ‘::fputc’ has not been declared
   using ::fputc;
           ^
/usr/include/c++/4.8.1/cstdio:109:11: error: ‘::fputs’ has not been declared
   using ::fputs;
           ^
/usr/include/c++/4.8.1/cstdio:110:11: error: ‘::fread’ has not been declared
   using ::fread;
           ^
/usr/include/c++/4.8.1/cstdio:111:11: error: ‘::freopen’ has not been declared
   using ::freopen;
           ^
/usr/include/c++/4.8.1/cstdio:112:11: error: ‘::fscanf’ has not been declared
   using ::fscanf;
           ^
/usr/include/c++/4.8.1/cstdio:113:11: error: ‘::fseek’ has not been declared
   using ::fseek;
           ^
/usr/include/c++/4.8.1/cstdio:114:11: error: ‘::fsetpos’ has not been declared
   using ::fsetpos;
           ^
/usr/include/c++/4.8.1/cstdio:115:11: error: ‘::ftell’ has not been declared
   using ::ftell;
           ^
/usr/include/c++/4.8.1/cstdio:116:11: error: ‘::fwrite’ has not been declared
   using ::fwrite;
           ^
/usr/include/c++/4.8.1/cstdio:117:11: error: ‘::getc’ has not been declared
   using ::getc;
           ^
/usr/include/c++/4.8.1/cstdio:118:11: error: ‘::getchar’ has not been declared
   using ::getchar;
           ^
/usr/include/c++/4.8.1/cstdio:119:11: error: ‘::gets’ has not been declared
   using ::gets;
           ^
/usr/include/c++/4.8.1/cstdio:120:11: error: ‘::perror’ has not been declared
   using ::perror;
           ^
/usr/include/c++/4.8.1/cstdio:121:11: error: ‘::printf’ has not been declared
   using ::printf;
           ^
/usr/include/c++/4.8.1/cstdio:122:11: error: ‘::putc’ has not been declared
   using ::putc;
           ^
/usr/include/c++/4.8.1/cstdio:123:11: error: ‘::putchar’ has not been declared
   using ::putchar;
           ^
/usr/include/c++/4.8.1/cstdio:124:11: error: ‘::puts’ has not been declared
   using ::puts;
           ^
/usr/include/c++/4.8.1/cstdio:125:11: error: ‘::remove’ has not been declared
   using ::remove;
           ^
/usr/include/c++/4.8.1/cstdio:126:11: error: ‘::rename’ has not been declared
   using ::rename;
           ^
/usr/include/c++/4.8.1/cstdio:127:11: error: ‘::rewind’ has not been declared
   using ::rewind;
           ^
/usr/include/c++/4.8.1/cstdio:128:11: error: ‘::scanf’ has not been declared
   using ::scanf;
           ^
/usr/include/c++/4.8.1/cstdio:129:11: error: ‘::setbuf’ has not been declared
   using ::setbuf;
           ^
/usr/include/c++/4.8.1/cstdio:130:11: error: ‘::setvbuf’ has not been declared
   using ::setvbuf;
           ^
/usr/include/c++/4.8.1/cstdio:131:11: error: ‘::sprintf’ has not been declared
   using ::sprintf;
           ^
/usr/include/c++/4.8.1/cstdio:132:11: error: ‘::sscanf’ has not been declared
   using ::sscanf;
           ^
/usr/include/c++/4.8.1/cstdio:133:11: error: ‘::tmpfile’ has not been declared
   using ::tmpfile;
           ^
/usr/include/c++/4.8.1/cstdio:134:11: error: ‘::tmpnam’ has not been declared
   using ::tmpnam;
           ^
/usr/include/c++/4.8.1/cstdio:135:11: error: ‘::ungetc’ has not been declared
   using ::ungetc;
           ^
/usr/include/c++/4.8.1/cstdio:136:11: error: ‘::vfprintf’ has not been declared
   using ::vfprintf;
           ^
/usr/include/c++/4.8.1/cstdio:137:11: error: ‘::vprintf’ has not been declared
   using ::vprintf;
           ^
/usr/include/c++/4.8.1/cstdio:138:11: error: ‘::vsprintf’ has not been declared
   using ::vsprintf;
           ^
/usr/include/c++/4.8.1/cstdio:167:11: error: ‘::snprintf’ has not been declared
   using ::snprintf;
           ^
/usr/include/c++/4.8.1/cstdio:168:11: error: ‘::vfscanf’ has not been declared
   using ::vfscanf;
           ^
/usr/include/c++/4.8.1/cstdio:169:11: error: ‘::vscanf’ has not been declared
   using ::vscanf;
           ^
/usr/include/c++/4.8.1/cstdio:170:11: error: ‘::vsnprintf’ has not been declared
   using ::vsnprintf;
           ^
/usr/include/c++/4.8.1/cstdio:171:11: error: ‘::vsscanf’ has not been declared
   using ::vsscanf;
           ^
/usr/include/c++/4.8.1/cstdio:177:22: error: ‘__gnu_cxx::snprintf’ has not been declared
   using ::__gnu_cxx::snprintf;
                      ^
/usr/include/c++/4.8.1/cstdio:178:22: error: ‘__gnu_cxx::vfscanf’ has not been declared
   using ::__gnu_cxx::vfscanf;
                      ^
/usr/include/c++/4.8.1/cstdio:179:22: error: ‘__gnu_cxx::vscanf’ has not been declared
   using ::__gnu_cxx::vscanf;
                      ^
/usr/include/c++/4.8.1/cstdio:180:22: error: ‘__gnu_cxx::vsnprintf’ has not been declared
   using ::__gnu_cxx::vsnprintf;
                      ^
/usr/include/c++/4.8.1/cstdio:181:22: error: ‘__gnu_cxx::vsscanf’ has not been declared
   using ::__gnu_cxx::vsscanf;
                      ^
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12:22: error: ‘printf’ was not declared in this scope
     printf("\nUsage:");
                      ^
main.cpp:14:11: error: ‘exit’ was not declared in this scope
     exit(0);
           ^

Last edited by MisterEwok (2013-08-29 10:15:07)

Offline

#2 2013-08-28 22:18:35

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

I've already tried force removing and reinstalling gcc and gcc-libs, with no change.

Offline

#3 2013-08-29 01:07:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: g++ isn't compiling!

Is gcc also not compiling?  If gcc works on a c file, you should probably change the title to specify g++ as all the issues are c++ lib related.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2013-08-29 01:12:10

at0m5k
Member
Registered: 2013-07-22
Posts: 40
Website

Re: g++ isn't compiling!

These look like linking errors. Make sure that all of your headers are defined explicitly (just to be sure). Then make sure that you are using the std namespace i.e using namespace std;.

Offline

#5 2013-08-29 10:16:29

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

@Trilby: compiling and linking work with a simple .c program so I changed the title

@at0m5k: The -c flag means I'm only trying to compile in the above paste.

Offline

#6 2013-08-29 10:24:25

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

Like I said, I have never had this problem until two days ago.

When I change the includes to

#include <stdlib.h>
#include <stdio.h>

instead of

#include <cstdlib>
#include <cstdio>

as I originally had it, I get this:

g++ -c main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12:22: error: ‘printf’ was not declared in this scope
     printf("\nUsage:");
                      ^
main.cpp:14:11: error: ‘exit’ was not declared in this scope
     exit(0);
           ^

And these lines are also at the end of the first paste.

Offline

#7 2013-08-29 10:40:25

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,658
Website

Re: g++ isn't compiling!

Show us the code...

Offline

#8 2013-08-29 10:43:22

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

#include <stdlib.h>
#include <stdio.h>
#include "matrixOps.h"

using namespace std;

int main(int argsc, char* Args[])
{
  /* Check for correct number of arguments (output file not required; defaults to "RESULT.mat") */
  if (argsc < 3)
  {
    printf("\nUsage:");
    printf("\nMultMatrices first_matrix_file second_matrix_file output_file(optional)\n\n");
    exit(0);
  }
  
  //declare variables (three matrices and their respective dimensions)
  double **A, **B, **C;
  int Arows, Acols, Brows, Bcols, Crows, Ccols;
  
  //Populate Matrices A and B from first two file arguments
  readMatrix(Args[1],A,Arows,Acols);
  readMatrix(Args[2],B,Brows,Bcols);
  
  //Populate Matrix C by multiplying A and B
  mat_mat_multiply(A,Arows,Acols,B,Brows,Bcols,C,Crows,Ccols);
  
  //Write the resultant C matrix to the third file argument
  writeMatrix(Args[3],C,Crows,Ccols);

  return 0;
}

Offline

#9 2013-08-29 10:53:31

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,373
Website

Re: g++ isn't compiling!

Could you check that your filesystem isn't corrupted by checking the filetype and size of the include files. e.g.

$ file /usr/include/c++/4.8.1/cstdio
/usr/include/c++/4.8.1/cstdio: C source, ASCII text

$ du /usr/include/c++/4.8.1/cstdio 
8       /usr/include/c++/4.8.1/cstdio

Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#10 2013-08-29 10:58:06

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,658
Website

Re: g++ isn't compiling!

MisterEwok wrote:
#include <stdlib.h>
#include <stdio.h>

Use cstdlib.h instead of stdlib.h ,etc

Offline

#11 2013-08-29 11:40:55

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

@Allan:

 g++ -c main.cpp
main.cpp:1:21: fatal error: cstdlib.h: No such file or directory
 #include <cstdlib.h>
                     ^
compilation terminated.

@WorMsy

$ file /usr/include/c++/4.8.1/cstdio
/usr/include/c++/4.8.1/cstdio: C source, ASCII text
$ du /usr/include/c++/4.8.1/cstdio
8	/usr/include/c++/4.8.1/cstdio

Offline

#12 2013-08-29 23:08:33

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,658
Website

Re: g++ isn't compiling!

I should have said "#include <cstdlib>"

Offline

#13 2013-08-30 11:58:43

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

@Allan: That's what I had in the first place; see original post.

Offline

#14 2013-08-30 12:08:05

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,658
Website

Re: g++ isn't compiling!

Can you give us a more minimal example without a mystery header so we can actually try compiling it ourselves?

Offline

#15 2013-08-30 12:09:32

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,658
Website

Re: g++ isn't compiling!

Also run "pacman -Qkk" on gcc and glibc to check all files are fine.

Offline

#16 2013-08-30 12:36:27

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

Here's a hello code:

#include <cstdio>

using namespace std;

int main ()
{
  printf("\nHello world!\n\n");
  
  return 0;
}

Compiling gives:

$ g++ -c hello.cpp 
In file included from hello.cpp:1:0:
/usr/include/c++/4.8.1/cstdio:95:11: error: ‘::FILE’ has not been declared
   using ::FILE;
           ^
/usr/include/c++/4.8.1/cstdio:96:11: error: ‘::fpos_t’ has not been declared
   using ::fpos_t;
           ^
/usr/include/c++/4.8.1/cstdio:98:11: error: ‘::clearerr’ has not been declared
   using ::clearerr;
           ^
/usr/include/c++/4.8.1/cstdio:99:11: error: ‘::fclose’ has not been declared
   using ::fclose;
           ^
/usr/include/c++/4.8.1/cstdio:100:11: error: ‘::feof’ has not been declared
   using ::feof;
           ^
/usr/include/c++/4.8.1/cstdio:101:11: error: ‘::ferror’ has not been declared
   using ::ferror;
           ^
/usr/include/c++/4.8.1/cstdio:102:11: error: ‘::fflush’ has not been declared
   using ::fflush;
           ^
/usr/include/c++/4.8.1/cstdio:103:11: error: ‘::fgetc’ has not been declared
   using ::fgetc;
           ^
/usr/include/c++/4.8.1/cstdio:104:11: error: ‘::fgetpos’ has not been declared
   using ::fgetpos;
           ^
/usr/include/c++/4.8.1/cstdio:105:11: error: ‘::fgets’ has not been declared
   using ::fgets;
           ^
/usr/include/c++/4.8.1/cstdio:106:11: error: ‘::fopen’ has not been declared
   using ::fopen;
           ^
/usr/include/c++/4.8.1/cstdio:107:11: error: ‘::fprintf’ has not been declared
   using ::fprintf;
           ^
/usr/include/c++/4.8.1/cstdio:108:11: error: ‘::fputc’ has not been declared
   using ::fputc;
           ^
/usr/include/c++/4.8.1/cstdio:109:11: error: ‘::fputs’ has not been declared
   using ::fputs;
           ^
/usr/include/c++/4.8.1/cstdio:110:11: error: ‘::fread’ has not been declared
   using ::fread;
           ^
/usr/include/c++/4.8.1/cstdio:111:11: error: ‘::freopen’ has not been declared
   using ::freopen;
           ^
/usr/include/c++/4.8.1/cstdio:112:11: error: ‘::fscanf’ has not been declared
   using ::fscanf;
           ^
/usr/include/c++/4.8.1/cstdio:113:11: error: ‘::fseek’ has not been declared
   using ::fseek;
           ^
/usr/include/c++/4.8.1/cstdio:114:11: error: ‘::fsetpos’ has not been declared
   using ::fsetpos;
           ^
/usr/include/c++/4.8.1/cstdio:115:11: error: ‘::ftell’ has not been declared
   using ::ftell;
           ^
/usr/include/c++/4.8.1/cstdio:116:11: error: ‘::fwrite’ has not been declared
   using ::fwrite;
           ^
/usr/include/c++/4.8.1/cstdio:117:11: error: ‘::getc’ has not been declared
   using ::getc;
           ^
/usr/include/c++/4.8.1/cstdio:118:11: error: ‘::getchar’ has not been declared
   using ::getchar;
           ^
/usr/include/c++/4.8.1/cstdio:119:11: error: ‘::gets’ has not been declared
   using ::gets;
           ^
/usr/include/c++/4.8.1/cstdio:120:11: error: ‘::perror’ has not been declared
   using ::perror;
           ^
/usr/include/c++/4.8.1/cstdio:121:11: error: ‘::printf’ has not been declared
   using ::printf;
           ^
/usr/include/c++/4.8.1/cstdio:122:11: error: ‘::putc’ has not been declared
   using ::putc;
           ^
/usr/include/c++/4.8.1/cstdio:123:11: error: ‘::putchar’ has not been declared
   using ::putchar;
           ^
/usr/include/c++/4.8.1/cstdio:124:11: error: ‘::puts’ has not been declared
   using ::puts;
           ^
/usr/include/c++/4.8.1/cstdio:125:11: error: ‘::remove’ has not been declared
   using ::remove;
           ^
/usr/include/c++/4.8.1/cstdio:126:11: error: ‘::rename’ has not been declared
   using ::rename;
           ^
/usr/include/c++/4.8.1/cstdio:127:11: error: ‘::rewind’ has not been declared
   using ::rewind;
           ^
/usr/include/c++/4.8.1/cstdio:128:11: error: ‘::scanf’ has not been declared
   using ::scanf;
           ^
/usr/include/c++/4.8.1/cstdio:129:11: error: ‘::setbuf’ has not been declared
   using ::setbuf;
           ^
/usr/include/c++/4.8.1/cstdio:130:11: error: ‘::setvbuf’ has not been declared
   using ::setvbuf;
           ^
/usr/include/c++/4.8.1/cstdio:131:11: error: ‘::sprintf’ has not been declared
   using ::sprintf;
           ^
/usr/include/c++/4.8.1/cstdio:132:11: error: ‘::sscanf’ has not been declared
   using ::sscanf;
           ^
/usr/include/c++/4.8.1/cstdio:133:11: error: ‘::tmpfile’ has not been declared
   using ::tmpfile;
           ^
/usr/include/c++/4.8.1/cstdio:134:11: error: ‘::tmpnam’ has not been declared
   using ::tmpnam;
           ^
/usr/include/c++/4.8.1/cstdio:135:11: error: ‘::ungetc’ has not been declared
   using ::ungetc;
           ^
/usr/include/c++/4.8.1/cstdio:136:11: error: ‘::vfprintf’ has not been declared
   using ::vfprintf;
           ^
/usr/include/c++/4.8.1/cstdio:137:11: error: ‘::vprintf’ has not been declared
   using ::vprintf;
           ^
/usr/include/c++/4.8.1/cstdio:138:11: error: ‘::vsprintf’ has not been declared
   using ::vsprintf;
           ^
/usr/include/c++/4.8.1/cstdio:167:11: error: ‘::snprintf’ has not been declared
   using ::snprintf;
           ^
/usr/include/c++/4.8.1/cstdio:168:11: error: ‘::vfscanf’ has not been declared
   using ::vfscanf;
           ^
/usr/include/c++/4.8.1/cstdio:169:11: error: ‘::vscanf’ has not been declared
   using ::vscanf;
           ^
/usr/include/c++/4.8.1/cstdio:170:11: error: ‘::vsnprintf’ has not been declared
   using ::vsnprintf;
           ^
/usr/include/c++/4.8.1/cstdio:171:11: error: ‘::vsscanf’ has not been declared
   using ::vsscanf;
           ^
/usr/include/c++/4.8.1/cstdio:177:22: error: ‘__gnu_cxx::snprintf’ has not been declared
   using ::__gnu_cxx::snprintf;
                      ^
/usr/include/c++/4.8.1/cstdio:178:22: error: ‘__gnu_cxx::vfscanf’ has not been declared
   using ::__gnu_cxx::vfscanf;
                      ^
/usr/include/c++/4.8.1/cstdio:179:22: error: ‘__gnu_cxx::vscanf’ has not been declared
   using ::__gnu_cxx::vscanf;
                      ^
/usr/include/c++/4.8.1/cstdio:180:22: error: ‘__gnu_cxx::vsnprintf’ has not been declared
   using ::__gnu_cxx::vsnprintf;
                      ^
/usr/include/c++/4.8.1/cstdio:181:22: error: ‘__gnu_cxx::vsscanf’ has not been declared
   using ::__gnu_cxx::vsscanf;
                      ^
hello.cpp: In function ‘int main()’:
hello.cpp:7:30: error: ‘printf’ was not declared in this scope
   printf("\nHello world!\n\n");
                              ^

Offline

#17 2013-08-30 12:40:05

MisterEwok
Member
Registered: 2013-08-28
Posts: 38

Re: g++ isn't compiling!

$ pacman -Qkk gcc glibc
gcc: 1938 total files, 0 altered files
warning: glibc: /etc/gai.conf (Modification time mismatch)
warning: glibc: /etc/locale.gen (Modification time mismatch)
warning: glibc: /etc/locale.gen (Size mismatch)
warning: glibc: /etc/nscd.conf (Modification time mismatch)
glibc: 1503 total files, 3 altered files

Offline

#18 2013-08-30 17:16:49

derhamster
Member
Registered: 2012-07-08
Posts: 86

Re: g++ isn't compiling!

Compile the code in verbose mode:

g++ -v main.cpp

and post the output. Might be worth looking at the default include directories.

Also, did you try compiling the code with clang?

Edit, with more ideas:
You can generate a list of defined preprocessor macros with:

g++ -dM -E - < /dev/null

Its quite long, but someone might still spot some missing or incorrectly defined macros in there.

Do you have any environment variables defined, that affect g++? printenv lists all variables.

Last edited by derhamster (2013-08-30 17:27:30)

Offline

Board footer

Powered by FluxBB