Error strlen was not declared in this scope

wxWidgets problem: 'strlen' not declared in this scope

Topic: wxWidgets problem: ‘strlen’ not declared in this scope  (Read 39583 times)

Hi!

Since I’ve been running into problems compiling projects using wxWidgets I just took a simple helloWorld.cpp and

#include

d

wx/wx.h

#include <iostream>
#include "wx/wx.h"

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

These are the first lines of the build messages:

C:ProgrammewxWidgets-2.8.9includewxwxchar.h||In function `size_t wxStrlen(const wxChar*)’:
C:ProgrammewxWidgets-2.8.9includewxwxchar.h|845|error: `strlen’ was not declared in this scope
C:ProgrammewxWidgets-2.8.9includewxwxchar.h||In function `char* wxTmemchr(const void*, int, size_t)’:
C:ProgrammewxWidgets-2.8.9includewxwxchar.h|1371|error: `memchr’ was not declared in this scope
C:ProgrammewxWidgets-2.8.9includewxwxchar.h||In function `int wxTmemcmp(const void*, const void*, size_t)’:

Maybe I screwed up sth. because the first time I tried everything worked just fine.

The global wx variable is set to the appropriate path. I copied the setup.h to the <WXWIN>/include/wx (although I am not sure if this is the proper way to get it into the include path…)

Any ideas on this?

Setup:
C::B nightly Aug-23-2008 (5193),
wxWidgets 2.8.9,
MinGW3.4.5


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


Copying «setup.h» is not the right way, it contains setup definitions, that depend on the options you have used while compiling wxWidgets.
I sometimes read this «tip» on the forum and I think it is potential dangerous, even if it seems to work in the most cases.

If your project is setup correctly you don’t need to copy anything.

Read http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef how to build wxWidgets and prepare C::B for the use of it, or look at the options of a wizard-created project.


Logged


Hm, ok, I removed setup.h from …/wx/include now and included the path I initially copied it from in the (global) compiler options.

But this wasn’t what caused the errors, they remain the same, even if I comment out the

#include

of

wx/wx.h

now, even if I remove anything related to wxWidgets from the project and clean it. I’ll have a look at a wizard generated project now, like proposed…

Well, firstly setup.h is not found, I add the absolute path to the project’s settings (it was there already but through the relative definition of the global wx variable which for some reason didn’t work), then there arise new errors, e.g.

C:ProgrammewxWidgets-2.8.9includewxbuffer.h|127|error: `strdup’ was not declared in this scope

which reminds me a lot of the errors I got previously.

Damn.  :?

Well, so I will recompile wxWidgets now, let’s see…


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


didn’t work…  :(
but I have to admit that I did not really recompile it, i.e. I didn’t clean before I did (I’ll do this tomorrow)… actually I don’t think that a wxWidgets rebuild will solve the problem since the errors all refer to the header files which should be the same with or without a compiled library, shouldn’t they?
I’ll keep trying and will inform you when I find out what is the problem or when I find a solution (but I’d prefer to know what I am doing wrong).


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


Looks more like a problem with your MinGW setup for me, because strlen is a standard c++-function.
Make sure your search-paths are set correctly.

As far as I know, «strlen» and «strdup» are declared in «string.h», which is in MinGW’s include folder (e.g. «c:MinGWinclude»).


Logged


You were right. Together with the wxWidgets search paths I also deleted the mingw/include from the search directories.

It had to be that simple…  :)

Thank you.
:D :D :D


Logged

C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP


harkin

Hi all. Been having a similar problem to IIIf (or is it lllf?). Anyway…

I kept getting the error about strup

C:ProgrammewxWidgets-2.8.9includewxbuffer.h|127|error: `strdup’ was not declared in this scope

I’d included the DirectX sdk include path in my search path, and after pushing it to the bottom of the list and pulling the Mingw include path to the top my basic wx.cpp compiles fine.

P.S. I used this post to compile wxWidgets properly

http://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_2.8.6_to_develop_Code::Blocks_(MSW)

Thanks guys and gals


Logged


Hi I have similiar problem and it doesn’t matter if I will compile wxWidgets from the source code or use wxPack I’m always ending up with the same result wchich is:

C:wxWidgets-2.8.11includewxchkconf.h|1824|warning: «wxUSE_WX_RESOURCES» is not defined|
C:wxWidgets-2.8.11includewxdefs.h|978|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxdefs.h|979|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxbuffer.h||In constructor ‘wxCharBuffer::wxCharBuffer(const char*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|128|error: ‘strdup’ was not declared in this scope|

C:wxWidgets-2.8.11includewxbuffer.h||In member function ‘wxCharBuffer& wxCharBuffer::operator=(const char*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|128|error: ‘strdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxbuffer.h||In constructor ‘wxWCharBuffer::wxWCharBuffer(const wchar_t*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|135|error: ‘_wcsdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxbuffer.h||In member function ‘wxWCharBuffer& wxWCharBuffer::operator=(const wchar_t*)’:|
C:wxWidgets-2.8.11includewxbuffer.h|135|error: ‘_wcsdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxstring.h||In function ‘int Stricmp(const char*, const char*)’:|
C:wxWidgets-2.8.11includewxstring.h|141|error: ‘strcasecmp’ was not declared in this scope|
C:wxWidgets-2.8.11includewxstring.h|1073|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxstring.h|1079|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxstring.h|1191|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxstring.h|1193|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlist.h||In constructor ‘wxListKey::wxListKey(const wxChar*)’:|
C:wxWidgets-2.8.11includewxlist.h|406|error: ‘strdup’ was not declared in this scope|

C:wxWidgets-2.8.11includewxlist.h||In constructor ‘wxListKey::wxListKey(const wxString&)’:|
C:wxWidgets-2.8.11includewxlist.h|408|error: ‘strdup’ was not declared in this scope|
C:wxWidgets-2.8.11includewxhashmap.h|536|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|536|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|537|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|537|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h||In member function ‘long long unsigned int wxIntegerHash::operator()(long long int) const’:|
C:wxWidgets-2.8.11includewxhashmap.h|536|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|556|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|556|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|557|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxhashmap.h|557|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxmath.h||In function ‘bool wxIsSameDouble(double, double)’:|
C:wxWidgets-2.8.11includewxmath.h|102|warning: comparing floating point with == or != is unsafe|
C:wxWidgets-2.8.11includewxlonglong.h|114|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|133|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|135|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|174|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|199|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|201|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|223|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|225|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|340|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h||In constructor ‘wxLongLongNative::wxLongLongNative(wxInt32, wxUint32)’:|
C:wxWidgets-2.8.11includewxlonglong.h|119|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|120|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h||In member function ‘wxLongLongNative& wxLongLongNative::Assign(double)’:|
C:wxWidgets-2.8.11includewxlonglong.h|157|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|351|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|371|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|373|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|402|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|427|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|429|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|446|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|448|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|563|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h||In constructor ‘wxULongLongNative::wxULongLongNative(wxUint32, wxUint32)’:|
C:wxWidgets-2.8.11includewxlonglong.h|356|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|357|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1070|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1071|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1073|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxlonglong.h|1074|warning: ISO C++ 1998 does not support ‘long long’|
C:wxWidgets-2.8.11includewxfilefn.h|198|warning: ISO C++ 1998 does not support ‘long long’|
||=== Build finished: 7 errors, 45 warnings ===|

I’m trying to solve this problem for about 3 days now … and I’m loosing my mind here … so anyone please help me  :?


Logged


Are you sure that «X:MinGWinclude» directory is in your «Search directories»?


Logged


I’m using Win 7 64bit and it looks like my wxWidgets compilation fails … in fact I have tried to compile the source many times using diffrent versions of wxWidgets and also to redirect the output of compilation into a file rather than console but if fails more or less with the same error message


gcc_mswudllmonodll_debugrpt.o: file not recognized: Memory exhausted
collect2: ld returned 1 exit status
mingw32-make: *** [….libgcc_dllwxmsw291u_gcc_custom.dll] Error 1

I did attached full warrning/error log for comparision.

my global variable base is C:wx were C:wx is main folder with my source code …

project build options->search directories:
C:MinGWinclude
$(#wx)include
$(#wx)libgcc_dllmswu

Target is set for Release

project build options->release->search directories:
$(#wx)libgcc_dllmswu

I’m trying to compile the source code using following commands

cd C:wxbuildmsw

mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release clean

mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release > install_log.txt

System Path is set to C:MinGWbin    :?


Logged


I’m using Win 7 64bit and it looks like my wxWidgets compilation fails …

You are using the 32 bit mingw under a 64 bit OS, maybe there is a mix-up with some of the libraries? Your message log indicates a linker error…

Ken


Logged


is there 64bit version of mingw ?


Logged


I’m using Win 7 64 bit too. And using 32 bit compiler. So the reason not it. But i’ve build wxWidgets as static library.


Logged


I’m using Win 7 64 bit too. And using 32 bit compiler. So the reason not it. But i’ve build wxWidgets as static library.

StelRat did you had similiar problems with compilation before you tried to compile as static library ?


Logged


No. I had never used DLL. I hate them. =) For threading i need one, but that is other story.


Logged


  • Home
  • Forum
  • The Ubuntu Forum Community
  • Ubuntu Specialised Support
  • Development & Programming
  • Packaging and Compiling Programs
  • [SOLVED] Compiling error ‘strlen’ was not declared in this scope

  1. Compiling error ‘strlen’ was not declared in this scope

    So I found out about Makehuman two days ago and thought how much this would help me with making models and the like, so I install the 1.0 Alpha 5 build (deb) and all was working fine until I tried to import a dae from MH to blender I keep getting this Python script error, so I try the mhx format from MH and it works, but, BAM, no edit mode. So I look around for tuts on how to fix these errors, but, none of them have anything to do with my problem at all so I decide to go back to a version that has been tested and that was 0.9.1 rc1. But here, I have to say, google failed be, I have honestly googled the mess out of my computer, here is the error I get

    Code:

    make[2]: Entering directory `/home/anon/Desktop/animorph-0.3/src'
    /bin/bash ../libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..    -Wall -g -O2 -MT BodySettings.lo -MD -MP -MF .deps/BodySettings.Tpo -c -o BodySettings.lo BodySettings.cpp
     g++ -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -MT BodySettings.lo -MD -MP -MF .deps/BodySettings.Tpo -c BodySettings.cpp  -fPIC -DPIC -o .libs/BodySettings.o
    BodySettings.cpp: In member function 'void Animorph::BodySettings::fromStream(std::ifstream&)':
    BodySettings.cpp:54: error: 'strlen' was not declared in this scope
    make[2]: *** [BodySettings.lo] Error 1
    make[2]: Leaving directory `/home/anon/Desktop/animorph-0.3/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/anon/Desktop/animorph-0.3'
    make: *** [all] Error 2

    What I did was look for

    Code:

    'strlen' was not declared in this scope

    but to no avail then I looked for

    Code:

    BodySettings.cpp:54: error: 'strlen' was not declared in this scope

    and again nothing, the closest I got to solving this problem was this link which led me to this link but the first one does not, to my knowledge, explain how, as in what has to be done in the terminal or folder, to get past this. I have been trying to compile this for four days, all the while googling the problem and trying different links but most don’t even get a response (others that had this problem and posted) and the ones that do are way above my current level of understanding of ubuntu. It’s not through lack of trying that I am not able to understand it just is not clicking what it is I have to do. Any help would be greatly appreciated.

    Last edited by royevans; June 20th, 2010 at 01:20 AM.

    Karera ga kirai, kika sete nagai ma, karera wa osorete


  2. Re: Compiling error ‘strlen’ was not declared in this scope

    have you tried adding
    #include <cstring>
    to the .cpp file? sounds like its missing that header


  3. Re: Compiling error ‘strlen’ was not declared in this scope

    actually having a look at makehuman, it seems there is .deb files for ubuntu to download and even a repository you can add. Unless you are really keen on compiling it yourself, using the repository would seem to be a good idea


  4. Re: Compiling error ‘strlen’ was not declared in this scope

    have you tried adding
    #include <cstring>
    to the .cpp file? sounds like its missing that header

    Now when you say that, do you mean all thirty-five of them or just one specific one?
    *I just looked at the error again and I see «BodySettings.cpp» I am going to try that.
    **Thanks, it gets me past that but then I run into this error

    Code:

    In file included from VertexVector.cpp:2:
    ../include/animorph/util.h: In function 'void Animorph::stringTokeni(const std::string&, const std::string&, T&)':
    ../include/animorph/util.h:169: error: 'atoi' is not a member of 'std'
    ../include/animorph/util.h:174: error: 'atoi' is not a member of 'std'
    make[2]: *** [VertexVector.lo] Error 1
    make[2]: Leaving directory `/home/anon/Desktop/animorph-0.3/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/anon/Desktop/animorph-0.3'
    make: *** [all] Error 2

    Quote Originally Posted by SevenMachines
    View Post

    actually having a look at makehuman, it seems there is .deb files for ubuntu to download and even a repository you can add. Unless you are really keen on compiling it yourself, using the repository would seem to be a good idea

    I have tried the 1.0 Alpha X Makehuman debs as well as the 9.0 deb but none of them work how other’s work, the Collada export always errors out but I figured out the one I have yet to try was the 9.1 rc1 version which is the one that many many MANY tutorials use.

    Last edited by royevans; June 20th, 2010 at 05:53 PM.

    Karera ga kirai, kika sete nagai ma, karera wa osorete


  5. Re: Compiling error ‘strlen’ was not declared in this scope

    util.h needs
    #include <cstdlib>


  6. Re: Compiling error ‘strlen’ was not declared in this scope

    Quote Originally Posted by SevenMachines
    View Post

    util.h needs
    #include <cstdlib>

    This is indeed get me past my little problem, thank you, however, i decided to grow some balls and try the nightly build along with the 2.5 Alpha of blender, which works like a charm. I will move this thread to solved.

    Karera ga kirai, kika sete nagai ma, karera wa osorete


  7. Re: Compiling error ‘strlen’ was not declared in this scope

    Quote Originally Posted by royevans
    View Post

    This is indeed get me past my little problem, thank you, however, i decided to grow some balls and try the nightly build along with the 2.5 Alpha of blender, which works like a charm. I will move this thread to solved.

    What fixed it for me was adding include «string.h» in the files the error occured.
    In my case that was disco-matic .


Bookmarks

Bookmarks


Posting Permissions

Я пытаюсь скомпилировать этот фрагмент кода, но по какой-то причине он не будет работать. Кто-нибудь может мне помочь? Я хочу знать, как правильно использовать strlen():

 #include<iostream>
 using namespace std;

 int main()
 {
    char buffer[80];

    cout << "Enter a string:";
    cin >> buffer;
    cout << strlen(buffer);

    return 0;

 }

Я пробовал использовать cin.getline(buffer, 80); но я получаю ту же ошибку компиляции.

Мой компилятор говорит, что ошибка в этом

ошибка: strlen не был объявлен в этой области

3 ответы

Вы забыли включить <cstring> or <string.h>.

cstring дам тебе strlen в std пространство имен, а string.h сохранит его в глобальном пространстве имен.

Создан 13 июля ’13, 04:07

Вам нужно включить cstring заголовок для strlen:

 #include <cstring>

вы также можете включить string.h и это поставило бы strlen в глобальном пространстве имен, в отличие от std пространство имен. Я думаю, что лучше использовать практику cstring и сбросить с помощью using namespace std.

ответ дан 23 мая ’17, 13:05

Вы можете включить <cstring>, то вы не получите никаких ошибок.

код

#include<iostream>
#include<cstring>
 using namespace std;

 int main()
 {
    char buffer[80];

    cout << "Enter a string:";
    cin >> buffer;
    cout << strlen(buffer);

    return 0;

 }

ответ дан 22 дек ’20, 17:12

Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками

c++

or задайте свой вопрос.

Понравилась статья? Поделить с друзьями:
  • Error string or binary data would be truncated the statement has been terminated
  • Error string index out of range java
  • Error string in namespace std does not name a type
  • Error string could not be parsed as xml
  • Error status sec dl forbidden 0xc0020004 meizu u10