Author Topic: wxWidgets problem: 'strlen' not declared in this scope  (Read 41011 times)

Offline lllf

  • Single posting newcomer
  • *
  • Posts: 6
wxWidgets problem: 'strlen' not declared in this scope
« on: September 29, 2008, 02:33:17 pm »
Hi!

Since I've been running into problems compiling projects using wxWidgets I just took a simple helloWorld.cpp and #included wx/wx.h
Code
#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:\Programme\wxWidgets-2.8.9\include\wx\wxchar.h||In function `size_t wxStrlen(const wxChar*)':
C:\Programme\wxWidgets-2.8.9\include\wx\wxchar.h|845|error: `strlen' was not declared in this scope
C:\Programme\wxWidgets-2.8.9\include\wx\wxchar.h||In function `char* wxTmemchr(const void*, int, size_t)':
C:\Programme\wxWidgets-2.8.9\include\wx\wxchar.h|1371|error: `memchr' was not declared in this scope
C:\Programme\wxWidgets-2.8.9\include\wx\wxchar.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
C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #1 on: September 29, 2008, 02:55:08 pm »
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.

Offline lllf

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #2 on: September 29, 2008, 06:41:39 pm »
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:\Programme\wxWidgets-2.8.9\include\wx\buffer.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...
C::B NB 2008-09-21 (5203)
MinGW 3.4.5
WinXP

Offline lllf

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #3 on: September 30, 2008, 08:47:39 am »
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).

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

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #4 on: September 30, 2008, 09:56:14 am »
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:\MinGW\include").

Offline lllf

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope (solved)
« Reply #5 on: September 30, 2008, 07:32:08 pm »
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

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

harkin

  • Guest
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #6 on: February 08, 2009, 06:32:47 pm »
Hi all. Been having a similar problem to IIIf (or is it lllf?). Anyway...

I kept getting the error about strup

C:\Programme\wxWidgets-2.8.9\include\wx\buffer.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


Offline psyhotron

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #7 on: October 18, 2010, 07:56:28 pm »
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.11\include\wx\chkconf.h|1824|warning: "wxUSE_WX_RESOURCES" is not defined|
C:\wxWidgets-2.8.11\include\wx\defs.h|978|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\defs.h|979|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\buffer.h||In constructor 'wxCharBuffer::wxCharBuffer(const char*)':|
C:\wxWidgets-2.8.11\include\wx\buffer.h|128|error: 'strdup' was not declared in this scope|

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

C:\wxWidgets-2.8.11\include\wx\list.h||In constructor 'wxListKey::wxListKey(const wxString&)':|
C:\wxWidgets-2.8.11\include\wx\list.h|408|error: 'strdup' was not declared in this scope|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|536|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|536|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|537|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|537|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h||In member function 'long long unsigned int wxIntegerHash::operator()(long long int) const':|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|536|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|556|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|556|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|557|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\hashmap.h|557|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\math.h||In function 'bool wxIsSameDouble(double, double)':|
C:\wxWidgets-2.8.11\include\wx\math.h|102|warning: comparing floating point with == or != is unsafe|
C:\wxWidgets-2.8.11\include\wx\longlong.h|114|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|133|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|135|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|174|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|199|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|201|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|223|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|225|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|340|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h||In constructor 'wxLongLongNative::wxLongLongNative(wxInt32, wxUint32)':|
C:\wxWidgets-2.8.11\include\wx\longlong.h|119|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|120|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h||In member function 'wxLongLongNative& wxLongLongNative::Assign(double)':|
C:\wxWidgets-2.8.11\include\wx\longlong.h|157|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|351|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|371|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|373|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|402|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|427|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|429|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|446|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|448|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|563|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h||In constructor 'wxULongLongNative::wxULongLongNative(wxUint32, wxUint32)':|
C:\wxWidgets-2.8.11\include\wx\longlong.h|356|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|357|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|1070|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|1071|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|1073|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\longlong.h|1074|warning: ISO C++ 1998 does not support 'long long'|
C:\wxWidgets-2.8.11\include\wx\filefn.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  :?

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
subj
« Reply #8 on: October 19, 2010, 12:03:46 pm »
...
Are you sure that "X:\MinGW\include" directory is in your "Search directories"?

Offline psyhotron

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #9 on: October 19, 2010, 02:25:06 pm »
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_mswudll\monodll_debugrpt.o: file not recognized: Memory exhausted
collect2: ld returned 1 exit status
mingw32-make: *** [..\..\lib\gcc_dll\wxmsw291u_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:\MinGW\include
$(#wx)\include
$(#wx)\lib\gcc_dll\mswu

Target is set for Release

project build options->release->search directories:
$(#wx)\lib\gcc_dll\mswu

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

cd C:\wx\build\msw\

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:\MinGW\bin    :?

Offline kencamargo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #10 on: October 19, 2010, 02:51:18 pm »
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

Offline psyhotron

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #11 on: October 19, 2010, 03:18:14 pm »
is there 64bit version of mingw ?

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #12 on: October 19, 2010, 03:23:57 pm »
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.

Offline psyhotron

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #13 on: October 19, 2010, 03:52:38 pm »
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 ?


Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #14 on: October 19, 2010, 04:31:18 pm »
No. I had never used DLL. I hate them. =) For threading i need one, but that is other story.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #15 on: October 19, 2010, 07:01:25 pm »
@psyhotron: It looks like GCC bug to me.
What version of MinGW GCC?
And, who built the MinGW GCC?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline psyhotron

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #16 on: October 19, 2010, 07:24:05 pm »
Hi stahta01

I used mingw-get-inst-20100909.exe ... piece of software which looks for the latest MinGW build on the sourceforge.net ... I have chosen prepackaged repository catalogues 20100909 ... and after installation process was completed ... I could find new folder with MinGW on my C: drive ...

after that I just added in command prompt set path = %path%;C:\MinGW\bin

it works for compiling simple C/C++ code using code blocks but if fails when I'm trying to compile wxWidgets ver 2.8.10, 2.8.11 or 2.9.1 ... o d'oh 2.9.1 was the most successful so far because it creates far more files and libraries before it fails than the others.

I was reading that I could create native x64bit windows toolchain using mingw-w64 project but I do not know if I would like to go that far especially if I do not know if there's a simpler way.

I do not what to reinvent the wheel :)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #17 on: October 19, 2010, 08:46:17 pm »
@psyhotron: I suggest using a stable MinGW GCC Build; if you wish to use the one you picked go to the Compiler or wxWidgets web-site to look for help.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline psyhotron

  • Single posting newcomer
  • *
  • Posts: 6
Re: wxWidgets problem: 'strlen' not declared in this scope
« Reply #18 on: October 20, 2010, 12:59:47 am »
ok! I have made it to work thanks to you all!

This is my small step by step instruction:

1. Remove all old installations of Code Blocks, MinGW, MinGW-64, and wxWidgets ... delete all folders of those applications after uninstallation process is complete.
2. Remove all references of MinGW from Path variable.
3. Download tdm-gcc-4.5.1 from this website -> http://tdm-gcc.tdragon.net/download
4. Start installation of tdm-gcc-4.5.1 and select to install latest stable version (from drop down menu) and make sure that "automatically add to path variable" is selected.
5. Download wxPack_v2.8.11.03.exe from this website -> http://sourceforge.net/projects/wxpack/files/wxpack/2.8.11.03/wxPack_v2.8.11.03.exe/download
6. Install it in C:\wxWidgets2.8
7. Download Code Blocks from this website -> http://www.codeblocks.org/downloads/26
8. Install it in default folder
9. Open up Code Blocks ->Settings -> Compiler and Debugger -> Toolchain Executables ... and select "Reset defaults" button.
10. Select "Autodetect" button in the same tab and it should come up with a popup to say that MinGW in MinGW32 was detected.
11. Select Settings->Global Variables select default from drop down menu click new variable and input "wx" and under base text field type: C:\wxWidgets2.8 and save.

From now on you should be able to select new project "wxWidgets" and it should compile without any problems under windows 7 ultimate 64Bit.  :D

Uff this cost me a looooot of time and reading ... problem is that all them websites including wiki pages ... they are fairly up to date but showing super old solutions or they are working for experienced power users ... or maybe for specific combination of os, compiler, wxWidgets and IDE ...

Anyways its alll good now  :D