Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Building C::B 8.02 + mingw = 'NULL' not declared  (Read 4607 times)

0 Members and 1 Guest are viewing this topic.

antto

  • Newbie
  • *
  • Posts: 4
    • View Profile
Building C::B 8.02 + mingw = 'NULL' not declared
« on: October 06, 2011, 08:52:22 am »
hello

while building the sfml-graphics lib (release static_win32)
got this error in: include\SFML\System\ResourcePtr.inl

i suppose NULL should have a value of 0
can i just #define NULL 0
or is it too dirty?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #1 on: October 06, 2011, 09:05:29 am »
#include <cstddef> before any SFML header.
Laurent Gomila - SFML developer

antto

  • Newbie
  • *
  • Posts: 4
    • View Profile
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #2 on: October 06, 2011, 09:26:16 am »
hi Laurent, thanks for the fast respons
now, i'm not sure where exactly i should include cstddef

i tryied two things:

1) in a dirty way defined NULL 0 in the ResourcePtr.inl
2) in the same directory in Resource.hpp added #include <cstddef> before the line where Resource.inl and ResourcePtr.inl are included

both lead to the same result
d:\toolz\codeblocks8\mingw\bin\..\lib\gcc\mingw32\4.6.1\..\..\..\..\include\wchar.h|105|error: 'size_t' has not been declared|
 :?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #3 on: October 06, 2011, 09:33:28 am »
Include it in your own code, before any #include <SFML/Xxx.hpp> that you have.
Laurent Gomila - SFML developer

antto

  • Newbie
  • *
  • Posts: 4
    • View Profile
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #4 on: October 06, 2011, 09:56:22 am »
i have this error while trying to build the lib itself
i haven't yet got to the point of using SFML in my own project

downloaded the "full sdk 1.6 for windows and codeblocks / mingw" .zip from the website
then unzipped it, and went to the build directory
from there i opened each .cbp project file one by one and build the Release Static_win32 target
window built fine
system too
main too
(so i got 3 libs in SFML\lib\mingw\ (lib***.a))
but got this problem while building the graphics lib

correct me if i'm wrong
i thought i have to build all the libs before i can use SFML
i want to use static linking (no dll)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #5 on: October 06, 2011, 10:07:00 am »
Quote
i thought i have to build all the libs before i can use SFML

Why?
Official releases contain precompiled binaries.
Laurent Gomila - SFML developer

antto

  • Newbie
  • *
  • Posts: 4
    • View Profile
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #6 on: October 06, 2011, 10:22:53 am »
ah, ok ;]
i'm still kinda new to all this ;]

rflood89

  • Newbie
  • *
  • Posts: 1
    • View Profile
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #7 on: December 15, 2011, 05:51:37 pm »
Quote from: "Laurent"
Quote
i thought i have to build all the libs before i can use SFML

Why?
Official releases contain precompiled binaries.


I have downloaded the source aswell since I wish to build SFML as a static library and the OP is right there is some problem with building from source in reference to NULL not being declared. As to your "Why?" response shouldnt the library be built first and linked second (like every other library I have used) your answer just doesn't make sense to me, I dont wish to compile my app with the whole source of sfml each time thats obsurd even with a makefile this still seems excessive and whats the point of shared libraries if the source of the library needs to be linked in at compile time? or am I missing something really obvious.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #8 on: December 15, 2011, 08:56:54 pm »
Quote
I have downloaded the source aswell since I wish to build SFML as a static library

Static libraries don't make sense on Linux. And on Windows, static builds are provided directly in the downloadable SDKs.
So basically there's no good reason for building SFML static libs yourself.

Quote
As to your "Why?" response shouldnt the library be built first and linked second (like every other library I have used) your answer just doesn't make sense to me, I dont wish to compile my app with the whole source of sfml each time thats obsurd even with a makefile this still seems excessive and whats the point of shared libraries if the source of the library needs to be linked in at compile time? or am I missing something really obvious.

I just said that compiling SFML is not necessary because it's already compiled in the downloadable SDKs. I didn't mean that you should include SFML sources in your app, that wouldn't make sense at all.
Laurent Gomila - SFML developer

dave_ottley

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #9 on: December 15, 2012, 11:43:02 am »
Laurent,

This is my first post here. I want to congratulate you on an incredible framework. However, there is a great reason to compile from source. If you use the precompiled libs, you have to use GCC 4.4. If you want to use some new C++ 11 features you will have to move up and/or if you just want to move up to GCC 4.7.1 you will have to recompile from source. Why? Because the ABI is not 100% compatible. I tried it without recompiling the libraries and got some fatal crashes.

I fixed the null problem by just inserting
#include <cstddef> into your .cpp file, and it worked great.

However, I am now having some more problems, but not really with your code, but in wchar.h. It says that size_t is not defined. I'm pretty sure this is a C++11 / C++98 incompatibility but if you have any insight, I would be greatly appreciative. Thanks.

-Dave Ottley

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10838
    • View Profile
    • development blog
    • Email
Re: Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #10 on: December 15, 2012, 12:07:32 pm »
You are aware that you answered to an over one year old thread and that Code::Blocks in the meantime is at version 12.11 and if chosen ships with TDM-GCC 4.7.1?
If not, now you know it and the whole problem doesn't exist anymore. :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

dave_ottley

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #11 on: December 15, 2012, 12:46:27 pm »
It should be noted that this problem still exists in its original form. I solved it by including
#include <cstddef>

in every .cpp (it is VERY important not to do this in the .hpp files) for which the NULL error was generated. I hope this will be of some help to some newbies out there somewhere, someday.

-Dave Ottley

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: Building C::B 8.02 + mingw = 'NULL' not declared
« Reply #12 on: December 15, 2012, 06:40:39 pm »
Note as well that this problem doesn't occur in version 10.0, so it's pretty much useless by now.

If you wish to help you can choose fresher topics, since these old ones are either left unresolved for over a year (maybe even resolved, just not outright stated) or have already been clearly resolved ages ago, not to mention that thread necromancing isn't exactly right in most forums.
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

 

anything