Error sprintf was not declared in this scope

Обновил компилятор и появились ошибки C++ Решение и ответ на вопрос 1081143

AlexMEll

0 / 0 / 0

Регистрация: 21.01.2014

Сообщений: 16

1

Обновил компилятор и появились ошибки

25.01.2014, 14:04. Показов 4086. Ответов 5

Метки нет (Все метки)


Здравствуйте сегодня обновил компилятор и тут же после открытия старой программы появились ошибки. На прежнем все работало..

XML
1
2
3
4
5
6
7
9   16  C:Documents and SettingsfffРабочий столProj(c++)main.cpp    [Warning] character constant too long for its type [enabled by default]
C:Documents and SettingsfffРабочий столProj(c++)main.cpp    In function 'void pars(int*, int*)':
9   31  C:Documents and SettingsfffРабочий столProj(c++)main.cpp    [Error] 'fopen' was not declared in this scope
12  29  C:Documents and SettingsfffРабочий столProj(c++)main.cpp    [Error] 'sprintf' was not declared in this scope
13  20  C:Documents and SettingsfffРабочий столProj(c++)main.cpp    [Error] 'fputs' was not declared in this scope
16  14  C:Documents and SettingsfffРабочий столProj(c++)main.cpp    [Error] 'fclose' was not declared in this scope
29      C:Documents and SettingsfffРабочий столProj(c++)Makefile.win    recipe for target 'main.o' failed

Код программы если нужно:

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <cstdlib>
#include <iostream>
#include <string>
 
using namespace std;
 
void pars(int *start, int *end) {
     FILE *f;
     f = fopen('file.txt', 'w');
        for (int i=*start;i<=*end;i++) {
        char str[10];
        sprintf(str,"%dn",i);
        fputs(str,f);
        std::cout << str;
        }
     fclose(f);
     }
 
int main()
{
    int *start = new int;
    int *end = new int;
 
    std::cout << "Считаем от: ";
    std::cin >> *start;
    std::cout << "Считаем до: ";
    std::cin >> *end;
 
    pars(start, end);
 
    delete start;
    delete end;
    system("PAUSE");
    return EXIT_SUCCESS;
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



zss

Модератор

Эксперт С++

12641 / 10135 / 6102

Регистрация: 18.12.2011

Сообщений: 27,170

25.01.2014, 14:11

2

А почему у Вас такая путаница из двух способов ввода-вывода?
Ошибки выдаются из-за того, что не подключено

C++
1
#include <stdio.h>

из сишной библиотеки ввода-вывода.
Советую эти функции заменить на >> <<

Добавлено через 3 минуты

C++
1
2
3
4
5
6
7
8
void pars(int *start, int *end) {
std::ostream f('file.txt');
for (int i=*start;i<=*end;i++) 
{
    f<<i;
   std::cout << str;
}
}



0



AlexMEll

0 / 0 / 0

Регистрация: 21.01.2014

Сообщений: 16

25.01.2014, 14:13

 [ТС]

3

Цитата
Сообщение от zss
Посмотреть сообщение

А почему у Вас такая путаница из двух способов ввода-вывода?
Ошибки выдаются из-за того, что не подключено

C++
1
#include <stdio.h>

из сишной библиотеки ввода-вывода.
Советую эти функции заменить на >> <<

Если вы про запись в файл в функции. То это сделано для того чтобы добавить к числу переход строки при записи в файл n

При подключении библиотеки которую вы предложили говорит

Код

4	19	C:Documents and SettingsfffРабочий столProj(c++)parsing.cpp	[Error] sddio.h: No such file or directory
compilation terminated.
29		C:Documents and SettingsfffРабочий столProj(c++)Makefile.win	recipe for target 'parsing.o' failed



0



3986 / 3255 / 910

Регистрация: 25.03.2012

Сообщений: 12,102

Записей в блоге: 1

25.01.2014, 14:38

4

stdio с одним d



0



0 / 0 / 0

Регистрация: 21.01.2014

Сообщений: 16

25.01.2014, 14:58

 [ТС]

5

Переписал программу проблема решена



0



5493 / 4888 / 831

Регистрация: 04.06.2011

Сообщений: 13,587

25.01.2014, 17:43

6

Цитата
Сообщение от AlexMEll
Посмотреть сообщение

сегодня обновил компилятор

Интересно: что на что обновили?



0



Hi,

I have problems to build OpenCV3-RC1 with the Debug build type activated. I was able to build a normal shared library version, but with debug mode I get the following:

error: 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' was not declared in this scope

My compiler is ‘mingw-w64 4.9.2 posix sjlj’.

Extract from the log:

    [  2%] [  9%] Built target zlib
Built target libjpeg
[ 18%] [ 23%] Built target libwebp
Built target libjasper
[ 23%] Built target opencv_ts_pch_dephelp
[ 26%] [ 32%] Built target libpng
[ 42%] Built target libtiff
Built target IlmImf
[ 42%] Built target pch_Generate_opencv_ts
[ 42%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/videoio/src/cap_dshow.cpp.obj
[ 42%] [ 43%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/features2d/src/dynamic.cpp.obj
Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/features2d/src/evaluation.cpp.obj
[ 43%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/features2d/src/fast.cpp.obj
[ 43%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/features2d/src/fast_score.cpp.obj
In file included from D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:332:0:
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp: In member function 'void videoInput::getMediaSubtypeAsString(GUID, char*)':
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2178:41: error: 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' was not declared in this scope
     if( type == MEDIASUBTYPE_RGB24)     sprintf(tmpStr, "RGB24");
                                         ^
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2178:57: warning: left operand of comma operator has no effect [-Wunused-value]
     if( type == MEDIASUBTYPE_RGB24)     sprintf(tmpStr, "RGB24");
                                                         ^
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2179:5: error: 'else' without a previous 'if'
     else if(type == MEDIASUBTYPE_RGB32) sprintf(tmpStr, "RGB32");
     ^
In file included from D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:332:0:
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2179:41: error: 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' was not declared in this scope
     else if(type == MEDIASUBTYPE_RGB32) sprintf(tmpStr, "RGB32");
                                         ^
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2179:57: warning: left operand of comma operator has no effect [-Wunused-value]
     else if(type == MEDIASUBTYPE_RGB32) sprintf(tmpStr, "RGB32");
                                                         ^
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2180:5: error: 'else' without a previous 'if'
     else if(type == MEDIASUBTYPE_RGB555)sprintf(tmpStr, "RGB555");
     ^
In file included from D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:332:0:
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2180:41: error: 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' was not declared in this scope
     else if(type == MEDIASUBTYPE_RGB555)sprintf(tmpStr, "RGB555");
                                         ^
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1opencvsourcesmodulesvideoiosrccap_dshow.cpp:2180:57: warning: left operand of comma operator has no effect [-Wunused-value]
     else if(type == MEDIASUBTYPE_RGB555)sprintf(tmpStr, "RGB555");
                                                         ^
D:ProgrammierungBibliothekenOpenCV3.0.0-rc1 ...

(more)

  • Summary

  • Files

  • Reviews

  • Support

  • Mailing Lists

  • Tickets ▾

    • Bugs
    • Patches
    • Feature Requests
  • Discussion

Menu

‘sprintf’ was not declared in this scope


Created:

2009-12-21

Updated:

2013-04-24

  • Rudolf Vavruch

    I am trying to compile Amsynth 1.2.2 on Linux Mint 8. I get the following error:

    JackOutput.cc: In member function ‘virtual int JackOutput::init(Config&)’:
    JackOutput.cc:85: error: ‘sprintf’ was not declared in this scope

    Here is the full output of make:

    make  all-recursive
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2′
    Making all in src
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src’
    Making all in drivers
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/drivers’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/drivers’
    Making all in VoiceBoard
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/VoiceBoard’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/VoiceBoard’
    Making all in GUI
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/GUI’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/GUI’
    Making all in Effects
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/Effects’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/Effects’
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src’
    g++ -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -I/usr/include/gtkmm-2.4 -I/usr/lib/gtkmm-2.4/include -I/usr/include/giomm-2.4 -I/usr/lib/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/pangomm-1.4/include -I/usr/include/gtk-2.0 -I/usr/include/gtk-unix-print-2.0 -I/usr/include/atkmm-1.6 -I/usr/include/gdkmm-2.4 -I/usr/lib/gdkmm-2.4/include -I/usr/include/glibmm-2.4 -I/usr/lib/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -I/usr/include/cairomm-1.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0     -Wall -O3 -ffast-math -fno-exceptions -fomit-frame-pointer -Dwith_oss -Dwith_jack -DENABLE_BINRELOC -Wall -O3 -ffast-math -fno-exceptions -fomit-frame-pointer -Dwith_oss -Dwith_jack -MT amSynth-JackOutput.o -MD -MP -MF .deps/amSynth-JackOutput.Tpo -c -o amSynth-JackOutput.o `test -f ‘JackOutput.cc’ || echo ‘./’`JackOutput.cc
    make  all-recursive
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2′
    Making all in src
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src’
    Making all in drivers
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/drivers’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/drivers’
    Making all in VoiceBoard
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/VoiceBoard’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/VoiceBoard’
    Making all in GUI
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/GUI’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/GUI’
    Making all in Effects
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src/Effects’
    make: Nothing to be done for `all’.
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src/Effects’
    make: Entering directory `/home/krokodil/Downloads/amSynth-1.2.2/src’
    g++ -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -I/usr/include/gtkmm-2.4 -I/usr/lib/gtkmm-2.4/include -I/usr/include/giomm-2.4 -I/usr/lib/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/pangomm-1.4/include -I/usr/include/gtk-2.0 -I/usr/include/gtk-unix-print-2.0 -I/usr/include/atkmm-1.6 -I/usr/include/gdkmm-2.4 -I/usr/lib/gdkmm-2.4/include -I/usr/include/glibmm-2.4 -I/usr/lib/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -I/usr/include/cairomm-1.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0     -Wall -O3 -ffast-math -fno-exceptions -fomit-frame-pointer -Dwith_oss -Dwith_jack -DENABLE_BINRELOC -Wall -O3 -ffast-math -fno-exceptions -fomit-frame-pointer -Dwith_oss -Dwith_jack -MT amSynth-JackOutput.o -MD -MP -MF .deps/amSynth-JackOutput.Tpo -c -o amSynth-JackOutput.o `test -f ‘JackOutput.cc’ || echo ‘./’`JackOutput.cc
    JackOutput.cc: In member function ‘virtual int JackOutput::init(Config&)’:
    JackOutput.cc:85: error: ‘sprintf’ was not declared in this scope
    make: ***  Error 1
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src’
    make: ***  Error 1
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2/src’
    make: ***  Error 1
    make: Leaving directory `/home/krokodil/Downloads/amSynth-1.2.2′
    make: ***  Error 2

  • nick dowell

    Have just submitted a potential fix (was not seeing this issue on my test systems) to the subversion repository (trunk revision 284).

    Please try compiling the source from subversion and let us know whether the issue is resolved, thanks!

  • nick dowell

    P.S. when building from an svn checkout an extra step is required before building:

    autogen.sh creates the ./configure script.

  • Rudolf Vavruch

    Thanks. I tried it again, everything went fine until I tried sudo make install and I got the following:

    Making install in src
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    Making install in drivers
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    Making install in VoiceBoard
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    Making install in GUI
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make  install-am
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    Making install in Effects
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    g++ -DHAVE_CONFIG_H -I. -I..    -Wall -W -O3 -ffast-math -fno-exceptions -fomit-frame-pointer -Dwith_oss -Dwith_jack -DENABLE_BINRELOC -Wall -W -O3 -ffast-math -fno-exceptions -fomit-frame-pointer -Dwith_oss -Dwith_jack -MT amSynth-main.o -MD -MP -MF .deps/amSynth-main.Tpo -c -o amSynth-main.o `test -f ‘main.cc’ || echo ‘./’`main.cc
    main.cc: In function ‘int fcopy(const char*, const char*)’:
    main.cc:96: error: ‘malloc’ was not declared in this scope
    main.cc:100: error: ‘free’ was not declared in this scope
    main.cc: In function ‘void install_default_files_if_reqd()’:
    main.cc:115: error: ‘getenv’ was not declared in this scope
    main.cc:144: error: ‘free’ was not declared in this scope
    main.cc: In function ‘void fatal_error(const std::string&)’:
    main.cc:190: error: ‘exit’ was not declared in this scope
    make: ***  Error 1
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    make: ***  Error 1
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    make: ***  Error 1

    Kind regards,
    Rudolf

  • nick dowell

    Could you tell me what kind of system (linux distro / freebsd / etc) you are compiling on?
    Also, what version of gcc are you building with? (running gcc -v should provide that information)
    Thanks!

  • Rudolf Vavruch

    I’m running Linux Mint:
    Linux Hermit 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC 2010 i686 GNU/Linux

    $ gcc -v
    Using built-in specs.
    Target: i486-linux-gnu
    Configured with: ../src/configure -v -with-pkgversion=’Ubuntu 4.4.1-4ubuntu9′ -with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs -enable-languages=c,c++,fortran,objc,obj-c++ -prefix=/usr -enable-shared -enable-multiarch -enable-linker-build-id -with-system-zlib -libexecdir=/usr/lib -without-included-gettext -enable-threads=posix -with-gxx-include-dir=/usr/include/c++/4.4 -program-suffix=-4.4 -enable-nls -enable-clocale=gnu -enable-libstdcxx-debug -enable-objc-gc -enable-targets=all -disable-werror -with-arch-32=i486 -with-tune=generic -enable-checking=release -build=i486-linux-gnu -host=i486-linux-gnu -target=i486-linux-gnu
    Thread model: posix
    gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)

  • nick dowell

    Hi again — latest code (svn rev 285) should build for you now; I’ve fixed and verified it on linux mint now :-)

  • Rudolf Vavruch

    Hi,

    Forgive my ignorance, it seems — at least to me that ‘sudo make install’ runs successfully, but after that I’m not sure what to do next. I’ve tried just running ‘amsynth’ from the command line but the system tells me it is not installed. Has it been compiled to a particular directory?

    Here is the output:
    $ sudo make install
    Making install in src
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    Making install in drivers
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/drivers’
    Making install in VoiceBoard
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/VoiceBoard’
    Making install in GUI
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make  install-am
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/GUI’
    Making install in Effects
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src/Effects’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    test -z «/usr/local/bin» || /bin/mkdir -p «/usr/local/bin»
      /bin/bash ../libtool   -mode=install /usr/bin/install -c amSynth ‘/usr/local/bin’
    libtool: install: /usr/bin/install -c amSynth /usr/local/bin/amSynth
    make  install-exec-hook
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    chown root /usr/local/bin/amSynth
    chmod +s /usr/local/bin/amSynth
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/src’
    Making install in skel
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/skel’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk/skel’
    make: Nothing to be done for `install-exec-am’.
    test -z «/usr/local/share/amSynth» || /bin/mkdir -p «/usr/local/share/amSynth»
    /usr/bin/install -c -m 644 presets Controllersrc rc ‘/usr/local/share/amSynth’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/skel’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk/skel’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk’
    make: Entering directory `/home/krokodil/Downloads/amsynthe/trunk’
    make: Nothing to be done for `install-exec-am’.
    make: Nothing to be done for `install-data-am’.
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk’
    make: Leaving directory `/home/krokodil/Downloads/amsynthe/trunk’

  • nick dowell

    amSynth was installed as /usr/local/bin/amSynth

    It could be that /usr/local/bin is not in your shell’s $PATH — try running it with the full path

  • Rudolf Vavruch

    Thanks, it’s working. I think the problem is I was trying to run ‘amsynth’ not ‘amSynth’ (note the capital S).


Log in to post a comment.

Bug #58936 Can’t compile on Ubuntu
Submitted: 2009-11-05 08:33 UTC Modified: 2017-01-10 08:12 UTC
Votes: 2
Avg. Score: 3.5 ± 0.5
Reproduced: 2 of 2 (100.0%)
Same Version: 1 (50.0%)
Same OS: 0 (0.0%)
From: thor005 at gmx dot de Assigned:
Status: Suspended Package: SCA_SDO (PECL)
PHP Version: 5.2.11 OS: Ubuntu 9.10
Private report: No CVE-ID: None

 [2009-11-05 08:33 UTC] thor005 at gmx dot de

Description:
------------
Hi,

I tried to compile the SCA_SDO extension with pecl.
It stops compiling  with the following error.

pecl install SCA_SDO
[..]
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp: In static member function 'static SDOString* commonj::sdo::SDODataConverter::convertToSDOString(const commonj::sdo::DataTypeInfo::SDODataTypeUnion&, const commonj::sdo::DataTypeInfo::TrueDataType&)':
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:619: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:624: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:629: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:634: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:638: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp: In static member function 'static unsigned int commonj::sdo::SDODataConverter::convertToBytes(const commonj::sdo::DataTypeInfo::SDODataTypeUnion&, const commonj::sdo::DataTypeInfo::TrueDataType&, char*, unsigned int)':
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:760: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:778: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:796: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:814: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:832: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp: In static member function 'static unsigned int commonj::sdo::SDODataConverter::convertToString(const commonj::sdo::DataTypeInfo::SDODataTypeUnion&, const commonj::sdo::DataTypeInfo::TrueDataType&, wchar_t*, unsigned int)':
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:981: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:999: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:1017: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:1035: error: 'sprintf' was not declared in this scope
/tmp/pear/download/SCA_SDO-1.2.4/commonj/sdo/SDODataConverter.cpp:1053: error: 'sprintf' was not declared in this scope
make: *** [commonj/sdo/SDODataConverter.lo] Error 1
ERROR: `make' failed

I can compile other packages like memcache without errors.
Can you please help me fixing this issue.

Regards
Michael

Reproduce code:
---------------
I'm no C expert, but the following solved my compiling problem:
diff commonj/sdo/SDODataConverter.cpp.orig commonj/sdo/SDODataConverter.cpp
20a21
> #include <stdio.h>

But I'm not sure if the module works perfectly.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2009-11-26 10:42 UTC] kroesler at roe-net dot de

I got the same issue, also on Ubuntu 9.10. 

Could you explain your fix? Where did you get the cpp.orig?

 [2011-06-20 06:07 UTC] gabriel dot valladolid at gmail dot com

I got same issue and simply added #include <stdio.h> to cpp file with problems, and voila.

Also was needed to remove some static modifiers from function declarations.

 [2017-01-10 08:12 UTC] kalle@php.net

-Status: Open
+Status: Suspended

 [2017-01-10 08:12 UTC] kalle@php.net

Suspending this report as the extension have not had a release for almost 9 years.  Please revive this if the extension once again shows life

usage of <stdio.h> (printf, sprintf)

Moderator: igrr

Sun Mar 29, 2015 7:38 am
#12921

Hello,

i try to use the stdio.h but i get allays compiling errors.

example code:

Code: Select all
#include <stdio.h>

void setup() {
  char wBuf[10];
  uint8_t wTest = 2;
  sprintf(wBuf, "TEST: %d", 2);
  printf("%sn", wBuf);
}

void loop() {

}

error:

Code: Select allC:/arduino-nightly/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:Tempbuild7857054617614130097.tmp/sketch_mar29a.cpp.elf section `.text' will not fit in region `iram1_0_seg'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-mallocr.o):(.literal+0x2c): undefined reference to `_sbrk_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-mallocr.o): In function `malloc_extend_top':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdlib/../../../../../newlib/libc/stdlib/mallocr.c:2165: undefined reference to `_sbrk_r'
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdlib/../../../../../newlib/libc/stdlib/mallocr.c:2202: undefined reference to `_sbrk_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-freer.o): In function `_malloc_trim_r':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdlib/../../../../../newlib/libc/stdlib/mallocr.c:3325: undefined reference to `_sbrk_r'
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdlib/../../../../../newlib/libc/stdlib/mallocr.c:3332: undefined reference to `_sbrk_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-freer.o):d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdlib/../../../../../newlib/libc/stdlib/mallocr.c:3340: more undefined references to `_sbrk_r' follow
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-makebuf.o):(.literal+0x8): undefined reference to `_fstat_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-makebuf.o): In function `__smakebuf_r':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdio/../../../../../newlib/libc/stdio/makebuf.c:59: undefined reference to `_fstat_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o):(.literal+0x4): undefined reference to `_read_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o):(.literal+0x8): undefined reference to `_lseek_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o):(.literal+0xc): undefined reference to `_write_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o):(.literal+0x10): undefined reference to `_close_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o): In function `__sread':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdio/../../../../../newlib/libc/stdio/stdio.c:48: undefined reference to `_read_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o): In function `__swrite':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdio/../../../../../newlib/libc/stdio/stdio.c:89: undefined reference to `_lseek_r'
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdio/../../../../../newlib/libc/stdio/stdio.c:97: undefined reference to `_write_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o): In function `__sseek':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdio/../../../../../newlib/libc/stdio/stdio.c:117: undefined reference to `_lseek_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(lib_a-stdio.o): In function `__sclose':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcstdio/../../../../../newlib/libc/stdio/stdio.c:135: undefined reference to `_close_r'
C:/arduino-nightly/hardware/tools/esp8266/sdk//liblibc.a(isatty.o): In function `_isatty_r':
d:NeoProjectESP8266DevKitbuildcompilerdlesp-newlibbuildxtensa-lx106-elfnewliblibcsysxtensa/../../../../../../newlib/libc/sys/xtensa/isatty.c:13: undefined reference to `_fstat_r'
collect2.exe: error: ld returned 1 exit status

is there a way to use sprintf and printf in the ESP8266 Arduino IDE?

Sun Mar 29, 2015 9:11 am
#12927

Currently this is not possible because these functions use malloc from ulibc.
ulibc-provided malloc doesn’t work because it depends on _sbrk which isn’t implemented.

The solution is to either use os_sprintf from the SDK, or to fix ulibc so that it would use os_malloc and os_free instead of malloc and free.

Sun Mar 29, 2015 1:47 pm
#12946

ok i add some defines to use the os function, now i can port some code from avr Arduino projects :)

Code: Select all#define printf(...) os_printf( __VA_ARGS__ )
#define sprintf(...) os_sprintf( __VA_ARGS__ )

for some reasons i also need to add

Code: Select allextern int os_printf_plus(const char * format, ...);

Tue Mar 31, 2015 4:05 pm
#13143

I put your defines at the start of my sketch but I get this error on compile —

Code: Select all: 1.6.1 (Windows 8.1), Board: "Generic ESP8266 board"

Using library PubSubClient in folder: D:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1librariesPubSubClient (legacy)

Using library ESP8266WiFi in folder: D:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1hardwareesp8266comesp8266librariesESP8266WiFi

Using library DHT in folder: D:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1librariesDHT (legacy)

D:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1/hardware/tools/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -ID:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1/hardware/tools/esp8266/sdk//include -c -Os -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -std=c++11 -MMD -DF_CPU=80000000L -DARDUINO=10601 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -ID:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1hardwareesp8266comesp8266coresesp8266 -ID:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1hardwareesp8266comesp8266variantsesp01 -ID:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1librariesPubSubClient -ID:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1hardwareesp8266comesp8266librariesESP8266WiFisrc -ID:ESP8266tools-utilitesarduino-1.6.1-windowsarduino-1.6.1librariesDHT C:UsersMichaelAppDataLocalTempbuild1840418149224716237.tmpmyDht11-mqtt.cpp -o C:UsersMichaelAppDataLocalTempbuild1840418149224716237.tmpmyDht11-mqtt.cpp.o

myDht11-mqtt.ino:19:16: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

myDht11-mqtt.ino: In function 'void setup()':

myDht11-mqtt.ino:38:46: error: 'os_sprintf' was not declared in this scope

myDht11-mqtt.ino:41:3: note: in expansion of macro 'sprintf'

Error compiling.

I’m hoping to use sprint() to merge my chip ID with my mqtt topic. I am able to get the chip ID
with the suggested addition of:

extern «C» {#include «user_interface.h»}
long chipId = system_get_chip_id();

#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)

#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.

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

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,833
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

#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;.

#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.

#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.

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

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

Re: g++ isn’t compiling!

Show us the code…

#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)nn");
    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;
}

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

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,018
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.

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

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

Re: g++ isn’t compiling!

MisterEwok wrote:

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

Use cstdlib.h instead of stdlib.h ,etc

#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

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

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

Re: g++ isn’t compiling!

I should have said «#include <cstdlib>»

#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.

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

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,246
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?

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

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

Re: g++ isn’t compiling!

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

#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!nn");
  
  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!nn");
                              ^

#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

#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:

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:

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)

Понравилась статья? Поделить с друзьями:
  • Error spmhdb 238
  • Error setting up or running liquibase
  • Error splitting the argument list option not found
  • Error setting up listener mongodb
  • Error splicing file input output error