Author Topic: Code::Blocks  (Read 3871 times)

notsogood

  • Guest
Code::Blocks
« on: 14 November 2010, 04:14:17 »
Anyone knows how to compile with code::blocks?

I tried to create a project "shared_lib" in it and added the files in source/shared_lib/sources/ and source/shared_lib/include/
When I tried to build then it complained that it couldn't find the h-files so I added all directories under source/shared_lib/include/
in a list Build options - Search directories (one by one...)
And STREFLOP_SSE to Build options - Compiler settings - #defines
And the "Known Libraries" to "Libraries used in project" under Properties - Libraries

now it complains about "/usr/include/c++/4.4/cwchar:67: error: ‘::mbstate_t’ has not been declared"
and 50 more like that

I guess I am doing something completely wrong here... what shall I do?

kukac2

  • Guest
Re: Code::Blocks
« Reply #1 on: 14 November 2010, 13:24:50 »
I'm not really sure, but have you installed compilers (like MinGW?)

notsogood

  • Guest
Re: Code::Blocks
« Reply #2 on: 14 November 2010, 13:56:26 »
I'm not really sure, but have you installed compilers (like MinGW?)

when I look in synaptic package manager mingw32 is not installed, but isn't minGW for creating windows executables?
"Minimalist GNU win32 (cross) compiler   A Linux hosted, win32 target, cross compiler for C/C++"
I only want to compile for linux (I am using ubuntu10.04 32bit)

megaglest compiles without error if I run 'jam' at commandline, but shouldn't codeblocks be able
to compile by itself?
the "Selected compiler"  in codeblocks build options is GNU GCC Compiler

kukac2

  • Guest
Re: Code::Blocks
« Reply #3 on: 14 November 2010, 18:52:16 »
I don't really know, since I'm using Windows :) I just needed to download and install CB, and everything worked fine.

notsogood

  • Guest
Re: Code::Blocks
« Reply #4 on: 15 November 2010, 14:55:02 »
I'm using Windows :) I just needed to download and install CB, and everything worked fine.

strange that it works in Windows but not in Linux,
how did you set up the project in codeblocks? I did like this:
1. clicked "Create a new project"
2. selected "Static library"
3. choosed the name "shared_lib" in trunk/source/
4. pressed Finish in the next screen (debug and release checked and Compiler was set to "GNU GCC Compiler")
5. Add files recursively trunk/source/shared_lib/ (both include/ and sources/)
6. unchecking macosx and win32 in Multiple selection dialog but not sure there's any difference by that
7. checked both Debug and Release
8. Removed the "main.c" that codeblocks autogenerated

if I try to Build now, CB complains about  #include "BMPReader.h" in BMPReader.cpp
like it can't find BMPReader.h because it is not in the same folder as BMPReader.cpp?
if I add include/graphics/ in Build options - Search directories tab, is complains on next h-file #include "platform_util.h" etc
so I had to add all of the include/ folders (I guess I should have given up here already since there is no
way to select all in one operation so I have to do the Add one folder at a time....)

Should I have set something in Build options.. or Properties... (or codeblocks Settings) ?

I am using Code::Blocks 8.02

I have tried adding some #defines I found
__linux__
STREFLOP_SSE
LIBM_COMPILING_FLT32
X11_AVAILABLE
HAVE_SYS_IOCTL_H

perhaps there some more I should add?

maybe I should have pasted the errormessages here:

-------------- Build: Release in shared_lib ---------------

Compiling: sources/graphics/BMPReader.cpp
In file included from /usr/include/c++/4.4/bits/postypes.h:42,
                 from /usr/include/c++/4.4/bits/char_traits.h:42,
                 from /usr/include/c++/4.4/string:42,
                 from include/platform/sdl/platform_util.h:14,
                 from include/graphics/FileReader.h:15,
                 from include/graphics/BMPReader.h:19,
                 from sources/graphics/BMPReader.cpp:12:
/usr/include/c++/4.4/cwchar:67: error: ‘::mbstate_t’ has not been declared
/usr/include/c++/4.4/cwchar:141: error: ‘::wint_t’ has not been declared
/usr/include/c++/4.4/cwchar:143: error: ‘::btowc’ has not been declared
/usr/include/c++/4.4/cwchar:144: error: ‘::fgetwc’ has not been declared
/usr/include/c++/4.4/cwchar:145: error: ‘::fgetws’ has not been declared
/usr/include/c++/4.4/cwchar:146: error: ‘::fputwc’ has not been declared
/usr/include/c++/4.4/cwchar:147: error: ‘::fputws’ has not been declared
/usr/include/c++/4.4/cwchar:148: error: ‘::fwide’ has not been declared
/usr/include/c++/4.4/cwchar:149: error: ‘::fwprintf’ has not been declared
/usr/include/c++/4.4/cwchar:150: error: ‘::fwscanf’ has not been declared
/usr/include/c++/4.4/cwchar:151: error: ‘::getwc’ has not been declared
/usr/include/c++/4.4/cwchar:152: error: ‘::getwchar’ has not been declared
/usr/include/c++/4.4/cwchar:153: error: ‘::mbrlen’ has not been declared
/usr/include/c++/4.4/cwchar:154: error: ‘::mbrtowc’ has not been declared
/usr/include/c++/4.4/cwchar:155: error: ‘::mbsinit’ has not been declared
/usr/include/c++/4.4/cwchar:156: error: ‘::mbsrtowcs’ has not been declared
/usr/include/c++/4.4/cwchar:157: error: ‘::putwc’ has not been declared
/usr/include/c++/4.4/cwchar:158: error: ‘::putwchar’ has not been declared
/usr/include/c++/4.4/cwchar:159: error: ‘::swprintf’ has not been declared
/usr/include/c++/4.4/cwchar:160: error: ‘::swscanf’ has not been declared
/usr/include/c++/4.4/cwchar:161: error: ‘::ungetwc’ has not been declared
/usr/include/c++/4.4/cwchar:162: error: ‘::vfwprintf’ has not been declared
/usr/include/c++/4.4/cwchar:164: error: ‘::vfwscanf’ has not been declared
/usr/include/c++/4.4/cwchar:166: error: ‘::vswprintf’ has not been declared
/usr/include/c++/4.4/cwchar:168: error: ‘::vswscanf’ has not been declared
/usr/include/c++/4.4/cwchar:170: error: ‘::vwprintf’ has not been declared
/usr/include/c++/4.4/cwchar:172: error: ‘::vwscanf’ has not been declared
/usr/include/c++/4.4/cwchar:174: error: ‘::wcrtomb’ has not been declared
/usr/include/c++/4.4/cwchar:175: error: ‘::wcscat’ has not been declared
/usr/include/c++/4.4/cwchar:176: error: ‘::wcscmp’ has not been declared
/usr/include/c++/4.4/cwchar:177: error: ‘::wcscoll’ has not been declared
/usr/include/c++/4.4/cwchar:178: error: ‘::wcscpy’ has not been declared
/usr/include/c++/4.4/cwchar:179: error: ‘::wcscspn’ has not been declared
/usr/include/c++/4.4/cwchar:180: error: ‘::wcsftime’ has not been declared
/usr/include/c++/4.4/cwchar:181: error: ‘::wcslen’ has not been declared
/usr/include/c++/4.4/cwchar:182: error: ‘::wcsncat’ has not been declared
/usr/include/c++/4.4/cwchar:183: error: ‘::wcsncmp’ has not been declared
/usr/include/c++/4.4/cwchar:184: error: ‘::wcsncpy’ has not been declared
/usr/include/c++/4.4/cwchar:185: error: ‘::wcsrtombs’ has not been declared
/usr/include/c++/4.4/cwchar:186: error: ‘::wcsspn’ has not been declared
/usr/include/c++/4.4/cwchar:187: error: ‘::wcstod’ has not been declared
/usr/include/c++/4.4/cwchar:189: error: ‘::wcstof’ has not been declared
/usr/include/c++/4.4/cwchar:191: error: ‘::wcstok’ has not been declared
/usr/include/c++/4.4/cwchar:192: error: ‘::wcstol’ has not been declared
/usr/include/c++/4.4/cwchar:193: error: ‘::wcstoul’ has not been declared
/usr/include/c++/4.4/cwchar:194: error: ‘::wcsxfrm’ has not been declared
/usr/include/c++/4.4/cwchar:195: error: ‘::wctob’ has not been declared
/usr/include/c++/4.4/cwchar:196: error: ‘::wmemcmp’ has not been declared
/usr/include/c++/4.4/cwchar:197: error: ‘::wmemcpy’ has not been declared
/usr/include/c++/4.4/cwchar:198: error: ‘::wmemmove’ has not been declared
Process terminated with status 1 (0 minutes, 5 seconds)
50 errors, 0 warnings
 
« Last Edit: 15 November 2010, 20:22:00 by notsogood »

kukac2

  • Guest
Re: Code::Blocks
« Reply #5 on: 17 November 2010, 17:36:36 »
Well, I use CB 10.15, and I use C++ for console applications.

I'm not sure why did you remove the main.c, I use the primary source files for coding :)

What I found strange from your description, that you mentioned main.c, which is a C coded sourcefile, and your compiler complains about BMPReader.cpp, which is a C++ source file.

Looking at your error messages, it seems something messed up with the C and the C++ languages. Make sure, that if your write in C, you don't compile it with C++. I don't know why, but if you are writing in C, (which I presume from your source file's extension), but the compiler tries to search for C++ includes.

notsogood

  • Guest
Re: Code::Blocks - I still don't understand
« Reply #6 on: 17 November 2010, 20:20:45 »
Strange versioning codeblocks have, it seems like 10.05 is the version right after 8.02
(and 10.05 was released some weeks after ubuntu10.04, I only have the version before it)
Perhaps I should try to find a ubunturepository with the newer version of codeblocks.

I guess you missunderstood me, I haven't coded c (and haven't changed any code at all
after checking out megaglest from svn) and megaglest is coded in c++
The "main.c" was autogenerated by codeclocks when doing 'create new project'

I certainly want to be able to compile megaglest before I change any of its code
and I will not add any files to megaglest.

> What I found strange from your description, that you mentioned main.c, which is a C coded sourcefile,
> and your compiler complains about BMPReader.cpp, which is a C++ source file.

Yes I dont know why codeblocks generated the 'main.c' file,
I assume it can be usefull for people that really start to code a new program
(I am only trying to compile an existing one but without 'jam' that it is normally compile with)

> Looking at your error messages, it seems something messed up with the C and the C++ languages.

I didn't see any option during create project where I could specify that the
project is strictly C++ and not c

What I don't understand is how I should specify correctly what libraries my project uses
(since it seems that I have to do that manually somehow? while I would prefer that
the compiler finds all libraries that is #include < ..... > included in the source code automaticly)

I guess that I allso must specify some #defines (that the automgenerated jam maker otherwise do)
becasue Megaglest can be compiled in other systems like windows and macintosh too.

Anyway, the thing that stops compiling seems to be the this code in ubuntus /usr/include/c++/4.4/cwchar :
Code: [Select]
#if _GLIBCXX_HAVE_WCHAR_H
#include <wchar.h>
#endif

#ifndef _GLIBCXX_CWCHAR
#define _GLIBCXX_CWCHAR 1

// Need to do a bit of trickery here with mbstate_t as char_traits
// assumes it is in wchar.h, regardless of wchar_t specializations.
#ifndef _GLIBCXX_HAVE_MBSTATE_T
extern "C"
{
  typedef struct
  {
    int __fill[6];
  } mbstate_t;
}
#endif

_GLIBCXX_BEGIN_NAMESPACE(std)

  using ::mbstate_t;

_GLIBCXX_END_NAMESPACE

where it says that "'::mbstate_t’ has not been declared"
(but it is defined in /usr/include/wchar.h "typedef __mbstate_t mbstate_t;" or?)

I have no idea what mbstate_t is though, I guess I would have
more hope if I undersstanded this :-/
wchar.h seems to be about unicode anyway.

There is also a file 'wchar.h' in megaglest own source directories that (only) contains this:
Code: [Select]
#define __WCHAR_MIN (-2147483647 - 1)
#define __WCHAR_MAX (2147483647)
I'm not sure what to do about that.


will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Code::Blocks
« Reply #7 on: 17 November 2010, 21:18:31 »
I am not a CB user, but you point out there is a wchar file there; you should ensure that your sourcecode directories are 'user includes' and not 'system includes'?

kukac2

  • Guest
Re: Code::Blocks
« Reply #8 on: 18 November 2010, 15:11:36 »
When you create a new project, CB should ask what language you want to do it. If main.c is created, then you are writing in C. If main.cpp is created, you are writing in C++.

Code: [Select]
#include <iostream>

using namespace std;

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

The most basic code in C++ looks like this, while in C

Code: [Select]
#include <stdio.h>
#include <stdlib.h>

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

These should be able to run by default settings.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Code::Blocks
« Reply #9 on: 20 November 2010, 01:05:26 »
I'm also not a CB user, but most compilers have an option to create an empty project. Yours is making a file automatically, so if CB has an empty project option (I've never seen one without said option!), you haven't chosen it. What kukac said is probably very helpful too.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

notsogood

  • Guest
Re: Code::Blocks
« Reply #10 on: 20 November 2010, 02:55:56 »
I am finally being able to compile megaglest in code::blocks now (by studying the output from jam -n
and trying to mimic that as close as possible trying to find right spot to put right thing in code::blocks)
and the game works  :O
I'll write more tomorrow what I set in the options for megaglest and the shared_lib.

I haven't nailed how to compile streflop yet though, so I'm still linking to the jam-made one.
I will try to understand the mysteries of streflop tomorrow.

btw, I assume there is some logical reason why glew directory is included by jam (-Ishared_lib/sources/../include/glew)
even though there is no such directory?


 

anything