SFML community forums

General => SFML projects => Topic started by: MonkeyKnight on April 18, 2012, 01:51:15 am

Title: Thor 2.0 cmake build error OS X 10.7
Post by: MonkeyKnight on April 18, 2012, 01:51:15 am
I am not positive I have posted this in the correct place.

I am having an issue getting cmake to generate makefiles properly.

SFML_DIR-NOTFOUND

The location that I have SFML2 installed at is (default) /usr/local.

The location that I have SFML2 sources is: /home/nick/src/SFML2

I have pointed SFML_DIR at:
/usr/local/
/home/nick/src/SFML2/
/usr/local/include/SFML/


They all end up the same:

(http://s7.postimage.org/p5gn7kpq3/cmake_Thor2.png)


I have searched the SFML2 source dir for SFMLConfig.cmake and for sfml-config.cmake, but have not found either file.


Thank you for any help!
 
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Erebus on April 18, 2012, 03:10:55 am
The file you need (I think at least) is FindSFML.cmake and its located in the SFML source dir under cmake/Modules.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on April 18, 2012, 11:56:56 am
I have pointed SFML_DIR at:
You need to set SFMLDIR, not SFML_DIR. Hopefully Laurent renames this variable to SFML_ROOT, the underscore leads to confusion again and again.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Laurent on April 18, 2012, 12:27:05 pm
There would be no confusion if people read the error message carefully.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Astrof on April 18, 2012, 03:24:16 pm
There would be no confusion if people read the error message carefully.

I wouldn't say no confusion; I'd maybe say less confusion.  When I read SFMLDIR and SFML_DIR to my mind they're the same thing.  Most people just see a general pattern of letters so SFMLDIR, SFML_DIR, SFML-DIR, etc all would be about the same unless read consciously and super carefully. 
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Laurent on April 18, 2012, 03:35:37 pm
Yeah, I guess it would be much better if CMake didn't display instructions about something that is not supposed to be used (the SFML_DIR directory containing a configuration file -- I'm not using that at all).

But anyway, I'll change the name of the variable, yes.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: MonkeyKnight on April 18, 2012, 03:52:59 pm
For this case, I certainly see SFMLDIR and SFML_DIR as two different variables.

But it appears that I have SFMLDIR set, no?

If /usr/local contains the directories local and lib, which contain the sfml headers and sfml libs respectively. Wouldn't this satisfy the cake file?


Code: [Select]
Nicholass-MacBook-Pro:local nick$ cd /usr/local/
Nicholass-MacBook-Pro:local nick$ ls lib | grep sfml
libsfml-audio-s.a
libsfml-audio.2.0.dylib
libsfml-audio.2.dylib
libsfml-audio.dylib
libsfml-graphics-s.a
libsfml-graphics.2.0.dylib
libsfml-graphics.2.dylib
libsfml-graphics.dylib
libsfml-network-s.a
libsfml-network.2.0.dylib
libsfml-network.2.dylib
libsfml-network.dylib
libsfml-system-s.a
libsfml-system.2.0.dylib
libsfml-system.2.dylib
libsfml-system.dylib
libsfml-window-s.a
libsfml-window.2.0.dylib
libsfml-window.2.dylib
libsfml-window.dylib
Nicholass-MacBook-Pro:local nick$ ls include/ | grep SFML
SFML
Nicholass-MacBook-Pro:local nick$


The file you need (I think at least) is FindSFML.cmake and its located in the SFML source dir under cmake/Modules.

I have also tried to set both SFMLDIR and SFML_DIR to: /Users/nick/src/SFML2/cmake/Modules with the same results.


Thanks in advance.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Laurent on April 18, 2012, 04:00:14 pm
Quote
But it appears that I have SFMLDIR set, no?
Yes, but SFMLDIR alone won't do anything, it is used by FindSFML.cmake.

Quote
I have also tried to set both SFMLDIR and SFML_DIR to: /Users/nick/src/SFML2/cmake/Modules with the same results.
Look at what the CMake error message says: its the CMAKE_MODULE_PATH variable which is used to locate the FindSFML.cmake file.

I think it would be much easier if Thor included it directly in its sources ;)
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: MonkeyKnight on April 18, 2012, 06:06:19 pm
I apologize for my cmake ignorance. I hardly use cmake.

I am over that hurdle, but now others...

Thanks for all your help.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on April 19, 2012, 05:10:57 pm
I think it would be much easier if Thor included it directly in its sources ;)
You mean the FindSFML.cmake file? That's a good idea, but I have to keep it up-to-date with SFML. Just like the rest of the library ;)

How can I make sure it is used by my scripts? CMAKE_MODULE_PATH might be needed for other modules...

By the way, thanks for the help in this thread and the SFML_ROOT change!
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Laurent on April 19, 2012, 06:08:35 pm
Quote
You mean the FindSFML.cmake file? That's a good idea, but I have to keep it up-to-date with SFML
Hopefully it won't change anymore after the SFML 2 release.

Quote
How can I make sure it is used by my scripts? CMAKE_MODULE_PATH might be needed for other modules...
Can't CMAKE_MODULE_PATH contain multiple paths? If not, setting it in your CMakeLists.txt files will override the user value anyway, and hopefully it will stay local to the current file.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: MonkeyKnight on April 20, 2012, 03:44:50 am
Greetings fellas.


I have been away for a bit. I have now come across these errors in the build process:

Code: [Select]
/Users/nick/src/Thor/src/ActionOperations.cpp:114:89: error: no member named 'bind' in namespace 'std'; did you mean 'find'?
                std::remove_copy_if(newEvents.begin(), newEvents.end(), std::back_inserter(out), std::bind(&ActionNode::filterOut, ...
                                                                                                 ~~~~~^~~~
                                                                                                      find 


Code: [Select]
[  3%] Building CXX object src/CMakeFiles/thor.dir/Action.cpp.o
In file included from /Users/nick/src/Thor/src/Action.cpp:26:
In file included from /Users/nick/src/Thor/include/Thor/Events/Action.hpp:32:
In file included from /Users/nick/src/Thor/include/Thor/Detail/ActionOperations.hpp:32:
In file included from /Users/nick/src/Thor/extlibs/aurora/include/Aurora/SmartPtr/CopiedPtr.hpp:32:
In file included from /Users/nick/src/Thor/extlibs/aurora/include/Aurora/SmartPtr/PtrFunctors.hpp:32:
/Users/nick/src/Thor/extlibs/aurora/include/Aurora/Tools/Metaprogramming.hpp:31:10: fatal error: 'type_traits' file not found
#include <type_traits>
         ^
1 error generated.
make[2]: *** [src/CMakeFiles/thor.dir/Action.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/thor.dir/all] Error 2
make: *** [all] Error 2



After some googlin' around, I edited CMakeLists.txt, adding at line 80:

*Keep in mind I am a complete cmake noob.*

Code: [Select]
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#    set(MACOSX 1)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++0x -U__STRICT_ANSI__ ")
endif()

When I try to compile now, it fixes the above errors - However generates more

Here is my compiler output:

Code: [Select]
[ 46%] Building CXX object src/CMakeFiles/thor.dir/Distributions.cpp.o
0  clang             0x0000000101e8b3e2 _ZL15PrintStackTracePv + 34
1  clang             0x0000000101e8b869 _ZL13SignalHandleri + 553
2  libsystem_c.dylib 0x00007fff8c56ccfa _sigtramp + 26
3  clang             0x00000001010058c6 clang::Decl::getAvailability(std::string*) const + 582
4  clang             0x00000001010349d6 clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) + 1606
5  clang             0x0000000101033bca clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*, true>, clang::prec::Level) + 570
6  clang             0x000000010102d06b clang::Parser::ParseAssignmentExpression() + 171
7  clang             0x000000010102cfa1 clang::Parser::ParseExpression() + 17
8  clang             0x00000001010824ae clang::Parser::ParseExprStatement(clang::ParsedAttributes&) + 46
9  clang             0x000000010102ca3c clang::Parser::ParseStatementOrDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, bool) + 1564
10 clang             0x000000010102bd59 clang::Parser::ParseCompoundStatementBody(bool) + 409
11 clang             0x000000010102bb4f clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 159
12 clang             0x0000000101577a26 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) + 454
13 clang             0x0000000101527aac clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) + 140
14 clang             0x000000010152174e clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, unsigned int, clang::Decl*) + 2590
15 clang             0x0000000100ff113e clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, bool) + 4478
16 clang             0x0000000100fef2d1 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext) + 3553
17 clang             0x000000010156205c clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 620
18 clang             0x0000000101561064 clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 756
19 clang             0x0000000101560d3f clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 351
20 clang             0x0000000100fedf08 clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 472
21 clang             0x0000000100fed79f clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::Parser::ParsingDeclSpec*) + 1423
22 clang             0x000000010153561d clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation, std::allocator<clang::SourceLocation> >&, std::vector<clang::IdentifierInfo*, std::allocator<clang::IdentifierInfo*> >&, std::vector<clang::SourceLocation, std::allocator<clang::SourceLocation> >&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::Parser::BalancedDelimiterTracker&) + 205
23 clang             0x0000000101534802 clang::Parser::ParseNamespace(unsigned int, clang::SourceLocation&, clang::SourceLocation) + 3074
24 clang             0x0000000100fee032 clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 770
25 clang             0x0000000100fed79f clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::Parser::ParsingDeclSpec*) + 1423
26 clang             0x0000000100fed199 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 249
27 clang             0x0000000100fd00a5 clang::ParseAST(clang::Sema&, bool) + 325
28 clang             0x0000000100fcebd7 clang::CodeGenAction::ExecuteAction() + 855
29 clang             0x0000000100fa113f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 879
30 clang             0x0000000100f9fdcb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2683
31 clang             0x0000000100f925ce cc1_main(char const**, char const**, char const*, void*) + 5086
32 clang             0x0000000100f6cdd8 main + 648
33 clang             0x0000000100f6cb44 start + 52
34 clang             0x0000000000000043 start + 18446744069398410547
Stack dump:
0. Program arguments: /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.7.3 -emit-obj -disable-free -disable-llvm-verifier -main-file-name Distributions.cpp -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 128.2 -coverage-file CMakeFiles/thor.dir/Distributions.cpp.o -resource-dir /usr/bin/../lib/clang/3.1 -D thor_EXPORTS -D THOR_EXPORTS -D AURORA_HAS_CPP11 -U __STRICT_ANSI__ -D NDEBUG -I /Users/nick/src/Thor/include -I /Users/nick/src/Thor/extlibs/aurora/include -I /usr/local/include -F/Library/Frameworks -fmodule-cache-path /var/folders/89/g_q7hkb564395stb6j4z3dlr0000gn/T/clang-module-cache -stdlib=libc++ -O3 -std=c++0x -fdeprecated-macro -fdebug-compilation-dir /Users/nick/src/Thor/nBuild/src -ferror-limit 19 -fmessage-length 170 -stack-protector 1 -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/thor.dir/Distributions.cpp.o -x c++ /Users/nick/src/Thor/src/Distributions.cpp
1. /Users/nick/src/Thor/include/Thor/Math/Distribution.hpp:68:41: current parser token ';'
2. /Users/nick/src/Thor/include/Thor/Math/Distribution.hpp:37:1: parsing namespace 'thor'
3. /Users/nick/src/Thor/include/Thor/Math/Distribution.hpp:48:1: parsing struct/union/class body 'Distribution'
4. /Users/nick/src/Thor/include/Thor/Math/Distribution.hpp:65:3: parsing function body 'Distribution<T>'
5. /Users/nick/src/Thor/include/Thor/Math/Distribution.hpp:65:3: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/89/g_q7hkb564395stb6j4z3dlr0000gn/T/Distributions-m9S8I2.ii
clang: note: diagnostic msg: /var/folders/89/g_q7hkb564395stb6j4z3dlr0000gn/T/Distributions-m9S8I2.sh
make[2]: *** [src/CMakeFiles/thor.dir/Distributions.cpp.o] Error 254
make[1]: *** [src/CMakeFiles/thor.dir/all] Error 2
make: *** [all] Error 2


This is clang puking all over me, isn't it?





Here is the output of the makefile generation
Code: [Select]
The C compiler identification is GNU
The CXX compiler identification is Clang
Checking whether C compiler has -isysroot
Checking whether C compiler has -isysroot - yes
Checking whether C compiler supports OSX deployment target flag
Checking whether C compiler supports OSX deployment target flag - yes
Found SFML: /usr/local/include
Configuring done
Generating done

Here are the versions of clang and gcc
Code: [Select]
Nicholass-MacBook-Pro:~ nick$ clang --version
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix

Nicholass-MacBook-Pro:~ nick$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Nicholass-MacBook-Pro:~ nick$


Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 02, 2012, 10:36:43 pm
I'm posting here because I'm having more or less the same issue as MonkeyKnight. I'm using the latest SFML and Thor sources from the Git repositories on OS X 10.8. I want to install Thor to use the BigTexture class.

I didn't get any issue with the CMake configuration (actually CMake didn't even tell me anything about some SFML*DIR variable), but it's failing at build time:
Code: [Select]
[  4%] Building CXX object src/CMakeFiles/thor.dir/Action.cpp.o
In file included from /Users/ceylo/Development/Thor/src/Action.cpp:26:
In file included from /Users/ceylo/Development/Thor/include/Thor/Events/Action.hpp:32:
In file included from /Users/ceylo/Development/Thor/include/Thor/Events/Detail/ActionOperations.hpp:32:
In file included from /Users/ceylo/Development/Thor/extlibs/aurora/include/Aurora/SmartPtr/CopiedPtr.hpp:32:
In file included from /Users/ceylo/Development/Thor/extlibs/aurora/include/Aurora/SmartPtr/PtrFunctors.hpp:32:
/Users/ceylo/Development/Thor/extlibs/aurora/include/Aurora/Tools/Metaprogramming.hpp:31:10: fatal error: 'type_traits' file not found
#include <type_traits>

To "fix" this I had to apply the following patch:
Code: [Select]
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d46f1ae..f617a7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,9 +72,9 @@ endif()
 
 
 # C++11 support
-if(CMAKE_COMPILER_IS_GNUCXX)
-       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-endif()
+#if(CMAKE_COMPILER_IS_GNUCXX)
+       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++")
+#endif()
 
 
 # Variable for install directory
Note that the default compiler on OS X is now Clang, which is why I also commented out the check for g++. CMake uses Clang unless it's asked not to.

However I get these errors now:
Code: [Select]
[ 40%] Building CXX object src/CMakeFiles/thor.dir/ConcaveShape.cpp.o
In file included from /Users/ceylo/Development/Thor/src/ConcaveShape.cpp:28:
In file included from /Users/ceylo/Development/Thor/include/Thor/Math/Triangulation.hpp:39:
/usr/bin/../lib/c++/v1/list:212:9: error: field has incomplete type 'thor::detail::AdvancedTriangle'
    _Tp __value_;
        ^
/usr/bin/../lib/c++/v1/type_traits:1889:54: note: in instantiation of template class 'std::__1::__list_node<thor::detail::AdvancedTriangle, void *>' requested here
decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...)), true_type())
                                                     ^
/usr/bin/../lib/c++/v1/type_traits:1890:1: note: while substituting deduced template arguments into function template '__is_constructible_test' [with _Tp =
      std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>, _Args = <no value>]
__is_constructible_test(_Tp&&, _Args&& ...);
^
/usr/bin/../lib/c++/v1/type_traits:1949:14: note: in instantiation of template class 'std::__1::__is_constructible<false,
      std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>, std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>
      &&>' requested here
    : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
             ^
/usr/bin/../lib/c++/v1/type_traits:1975:14: note: in instantiation of template class 'std::__1::__is_constructible_void_check<false,
      std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>, std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>
      &&>' requested here
    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
             ^
/usr/bin/../lib/c++/v1/type_traits:2455:34: note: in instantiation of template class
      'std::__1::is_constructible<std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>,
      std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>> &&>' requested here
    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
                                 ^
/usr/bin/../lib/c++/v1/type_traits:2590:14: note: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 to see all)
    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
             ^
/usr/bin/../lib/c++/v1/memory:2219:20: note: in instantiation of template class
      'std::__1::is_nothrow_move_constructible<std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>>' requested here
                   is_nothrow_move_constructible<_T2>::value)
                   ^
/usr/bin/../lib/c++/v1/__config:253:34: note: expanded from macro '_NOEXCEPT_'
#  define _NOEXCEPT_(x) noexcept(x)
                                 ^
/usr/bin/../lib/c++/v1/memory:2386:15: note: in instantiation of template class 'std::__1::__libcpp_compressed_pair_imp<unsigned long,
      std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>, 2>' requested here
    : private __libcpp_compressed_pair_imp<_T1, _T2>
              ^
/usr/bin/../lib/c++/v1/list:513:52: note: in instantiation of template class 'std::__1::__compressed_pair<unsigned long,
      std::__1::allocator<std::__1::__list_node<thor::detail::AdvancedTriangle, void *>>>' requested here
    __compressed_pair<size_type, __node_allocator> __size_alloc_;
                                                   ^
/usr/bin/../lib/c++/v1/list:770:15: note: in instantiation of template class 'std::__1::__list_imp<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle>>' requested here
    : private __list_imp<_Tp, _Alloc>
              ^
/Users/ceylo/Development/Thor/include/Thor/Math/Detail/Triangulation.inl:59:10: note: in instantiation of template class 'std::__1::list<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle>>' requested here
        typedef TriangleList::iterator                                                  TriangleIterator;
                ^
/Users/ceylo/Development/Thor/include/Thor/Math/Detail/Triangulation.inl:32:8: note: forward declaration of 'thor::detail::AdvancedTriangle'
        class AdvancedTriangle;
              ^
In file included from /Users/ceylo/Development/Thor/src/ConcaveShape.cpp:28:
In file included from /Users/ceylo/Development/Thor/include/Thor/Math/Triangulation.hpp:39:
/usr/bin/../lib/c++/v1/list:203:19: error: static_cast from 'std::__1::__list_node_base<thor::detail::AdvancedTriangle, void *> *' to 'pointer' (aka
      'std::__1::__list_node<thor::detail::AdvancedTriangle, void *> *') is not allowed
        : __prev_(static_cast<pointer>(this)),
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/c++/v1/list:529:5: note: in instantiation of member function 'std::__1::__list_node_base<thor::detail::AdvancedTriangle, void *>::__list_node_base'
      requested here
    __list_imp()
    ^
/usr/bin/../lib/c++/v1/list:795:5: note: in instantiation of member function 'std::__1::__list_imp<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle> >::__list_imp' requested here
    list()
    ^
/Users/ceylo/Development/Thor/include/Thor/Math/Detail/Triangulation.inl:399:16: note: in instantiation of member function 'std::__1::list<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle> >::list' requested here
                TriangleList    triangles;
                                ^
/Users/ceylo/Development/Thor/include/Thor/Math/Detail/Triangulation.inl:457:9: note: in instantiation of function template specialization
      'thor::detail::triangulateImpl<std::__1::__wrap_iter<const sf::Vector2<float> *>, thor::ConcaveShape::TriangleGenerator,
      thor::detail::PolygonOutputTrDetails<std::__1::back_insert_iterator<std::__1::vector<thor::Edge<const sf::Vector2<float>>, std::__1::allocator<thor::Edge<const
      sf::Vector2<float>>>>>, const sf::Vector2<float>> >' requested here
        return detail::triangulateImpl(verticesBegin, verticesEnd, trianglesOut,
               ^
/Users/ceylo/Development/Thor/src/ConcaveShape.cpp:241:2: note: in instantiation of function template specialization 'thor::triangulatePolygon<std::__1::__wrap_iter<const
      sf::Vector2<float> *>, thor::ConcaveShape::TriangleGenerator, std::__1::back_insert_iterator<std::__1::vector<thor::Edge<const sf::Vector2<float>>,
      std::__1::allocator<thor::Edge<const sf::Vector2<float>>>>> >' requested here
        triangulatePolygon(mPoints.begin(), mPoints.end(), TriangleGenerator(mTriangleShapes, mFillColor), std::back_inserter(mEdges));
        ^
In file included from /Users/ceylo/Development/Thor/src/ConcaveShape.cpp:28:
In file included from /Users/ceylo/Development/Thor/include/Thor/Math/Triangulation.hpp:39:
/usr/bin/../lib/c++/v1/list:204:19: error: static_cast from 'std::__1::__list_node_base<thor::detail::AdvancedTriangle, void *> *' to 'pointer' (aka
      'std::__1::__list_node<thor::detail::AdvancedTriangle, void *> *') is not allowed
          __next_(static_cast<pointer>(this))
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/c++/v1/list:678:30: error: static_cast from '__node_base *' (aka '__list_node_base<value_type, __void_pointer> *') to '__node_pointer' (aka
      'std::__1::__list_node<thor::detail::AdvancedTriangle, void *> *') is not allowed
        __node_pointer __l = static_cast<__node_pointer>(&__end_);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/c++/v1/list:664:5: note: in instantiation of member function 'std::__1::__list_imp<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle> >::clear' requested here
    clear();
    ^
/usr/bin/../lib/c++/v1/list:769:23: note: in instantiation of member function 'std::__1::__list_imp<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle> >::~__list_imp' requested here
class _LIBCPP_VISIBLE list
                      ^
/Users/ceylo/Development/Thor/include/Thor/Math/Detail/Triangulation.inl:457:9: note: in instantiation of function template specialization
      'thor::detail::triangulateImpl<std::__1::__wrap_iter<const sf::Vector2<float> *>, thor::ConcaveShape::TriangleGenerator,
      thor::detail::PolygonOutputTrDetails<std::__1::back_insert_iterator<std::__1::vector<thor::Edge<const sf::Vector2<float>>, std::__1::allocator<thor::Edge<const
      sf::Vector2<float>>>>>, const sf::Vector2<float>> >' requested here
        return detail::triangulateImpl(verticesBegin, verticesEnd, trianglesOut,
               ^
/Users/ceylo/Development/Thor/src/ConcaveShape.cpp:241:2: note: in instantiation of function template specialization 'thor::triangulatePolygon<std::__1::__wrap_iter<const
      sf::Vector2<float> *>, thor::ConcaveShape::TriangleGenerator, std::__1::back_insert_iterator<std::__1::vector<thor::Edge<const sf::Vector2<float>>,
      std::__1::allocator<thor::Edge<const sf::Vector2<float>>>>> >' requested here
        triangulatePolygon(mPoints.begin(), mPoints.end(), TriangleGenerator(mTriangleShapes, mFillColor), std::back_inserter(mEdges));
        ^
In file included from /Users/ceylo/Development/Thor/src/ConcaveShape.cpp:28:
In file included from /Users/ceylo/Development/Thor/include/Thor/Math/Triangulation.hpp:39:
/usr/bin/../lib/c++/v1/list:561:25: error: static_cast from '__node_base *' (aka '__list_node_base<value_type, __void_pointer> *') to '__node_pointer' (aka
      'std::__1::__list_node<thor::detail::AdvancedTriangle, void *> *') is not allowed
        return iterator(static_cast<__node_pointer>(&__end_));
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/c++/v1/list:866:59: note: in instantiation of member function 'std::__1::__list_imp<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle> >::end' requested here
          iterator end() _NOEXCEPT          {return base::end();}
                                                          ^
/Users/ceylo/Development/Thor/include/Thor/Math/Detail/Triangulation.inl:421:70: note: in instantiation of member function 'std::__1::list<thor::detail::AdvancedTriangle,
      std::__1::allocator<thor::detail::AdvancedTriangle> >::end' requested here
                return transformTriangles<UserVertex>(triangles.begin(), triangles.end(), trianglesOut);
                                                                                   ^
/Users/ceylo/Development/Thor/include/Thor/Math/Detail/Triangulation.inl:457:9: note: in instantiation of function template specialization
      'thor::detail::triangulateImpl<std::__1::__wrap_iter<const sf::Vector2<float> *>, thor::ConcaveShape::TriangleGenerator,
      thor::detail::PolygonOutputTrDetails<std::__1::back_insert_iterator<std::__1::vector<thor::Edge<const sf::Vector2<float>>, std::__1::allocator<thor::Edge<const
      sf::Vector2<float>>>>>, const sf::Vector2<float>> >' requested here
        return detail::triangulateImpl(verticesBegin, verticesEnd, trianglesOut,
               ^
/Users/ceylo/Development/Thor/src/ConcaveShape.cpp:241:2: note: in instantiation of function template specialization 'thor::triangulatePolygon<std::__1::__wrap_iter<const
      sf::Vector2<float> *>, thor::ConcaveShape::TriangleGenerator, std::__1::back_insert_iterator<std::__1::vector<thor::Edge<const sf::Vector2<float>>,
      std::__1::allocator<thor::Edge<const sf::Vector2<float>>>>> >' requested here
        triangulatePolygon(mPoints.begin(), mPoints.end(), TriangleGenerator(mTriangleShapes, mFillColor), std::back_inserter(mEdges));
        ^
5 errors generated.
make[2]: *** [src/CMakeFiles/thor.dir/ConcaveShape.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/thor.dir/all] Error 2
make: *** [all] Error 2

I don't know if this could help but here is the C++11 support status for Clang: http://clang.llvm.org/cxx_status.html
And `clang -v` outputs the following:
Code: [Select]
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.1.0
Thread model: posix

I'd grateful if anyone knew how to fix this or if it should be fixed in Thor's sources.
Thanks!

Ceylo
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 02, 2012, 11:44:18 pm
I haven't ever tested Thor with Clang, I'm not even sure if it can be installed easily on Windows. Can you tell me more about the CMake flag -stdlib=libc++ you added? Is it Clang-specific?

Concerning the other error message, it looks like std::list<thor::detail::AdvancedTriangle> is used with an undefined AdvancedTriangle. The file Triangulation.inl refers to this type as follows:
class AdvancedTriangle;                            //  (32) incomplete type, declaration
typedef std::list<AdvancedTriangle> TriangleList;  //  (55) incomplete, maybe problematic
typedef TriangleList::iterator TriangleIterator;   //  (59) incomplete, maybe problematic
class THOR_API AdvancedTriangle ... { ... };       // (134) class definition

Okay, apparently the old standard completely forbids incomplete types in the STL:
Quote from: C++ standard 2003, §17.4.3.6/2
In particular, the effects are undefined [...] if an incomplete type (3.9) is used as a template argument when instantiating a template component.

The new standard however contains an interesting change:
Quote from: C++ FDIS 2011 (n3290), §17.6.4.8/2
In particular, the effects are undefined [...] if an incomplete type (3.9) is used as a template argument when instantiating a template component, unless specifically allowed for that component.
So, further research is necessary :D

Reordering dependencies in Thor's source might be quite difficult, maybe I have to introduce other classes just to workaround that... :-\
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 03, 2012, 12:23:15 am
I added the flag after reading this: http://stackoverflow.com/questions/9345271/xcode-4-3-and-c11-include-paths
Which I found after searching for the "fatal error: 'type_traits' file not found" error message.

And GCC isn't a better option here as the one provided with Apple development tools is GCC 4.2, which doesn't even recognize the -std=c++0x and -stdlib=libc++ parameters. I could build the latest GCC but this isn't a easy solution for OS X users.

As for running Clang on Windows, I don't think it's easy at the moment. The best you could do if you want to test it yourself is running it with Linux.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 03, 2012, 04:44:06 pm
I've just been building GCC 4.7. I still had to comment out the check for CMAKE_COMPILER_IS_GNUCXX and I added the following a bit after the beginning of the CMakeLists.txt file:
Code: [Select]
INCLUDE (CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Generic)
CMAKE_FORCE_C_COMPILER   (gcc4.7 GCC)
CMAKE_FORCE_CXX_COMPILER (g++4.7 GXX)
Then I could successfully build Thor. I was also surprised to see the program "works" although I built it with Clang whereas Thor was built with GCC, especially considering that Clang can't build Thor at the moment.

However BigTexture isn't working as expected: it can load image file that sf::Texture is already able to handle but if I try to load an image whose size is greater than 4096 pixels wide, it displays garbage. I used the following code:
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Fractales", sf::Style::Close);
    window.setFramerateLimit(60);
   
    thor::BigSprite spr;
    thor::BigTexture tex;
   
    if (!tex.loadFromFile("test.png"))
    {
        std::cout << "error loading image file" << std::endl;
        return 1;
    }
   
    spr.setTexture(tex);
   
    sf::View view = window.getDefaultView();
    view.zoom(10);
    window.setView(view);
   
    while (window.isOpen())
    {
        sf::Event ev;
       
        while (window.pollEvent(ev))
        {
            if (ev.type == sf::Event::Closed or
                (ev.type == sf::Event::KeyPressed and ev.key.code == sf::Keyboard::Escape))
            {
                window.close();
            }
        }
       
        window.clear();
        window.draw(spr);
        window.display();
    }
   
    return 0;
}
It does look like the texture limit isn't correctly retrieved, but maybe there's something wrong on SFML's side.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 03, 2012, 05:38:03 pm
I still had to comment out the check for CMAKE_COMPILER_IS_GNUCXX
Why exactly? What happens if you leave the configuration file unchanged? I haven't tested g++ version 4.7 yet, but 4.6 works for me...

However BigTexture isn't working as expected: it can load image file that sf::Texture is already able to handle but if I try to load an image whose size is greater than 4096 pixels wide, it displays garbage.
Hm, I have used thor::BigTexture successfully in Airport. Also I tested quickly for a 10000x5600 image (with a texture limit of 8192), it is displayed correctly.

But maybe there is a problem with Macs, I have never tested it there. What do you mean with garbage? What does sf::Texture::getMaximumSize() return?
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 03, 2012, 05:55:48 pm
Why exactly? What happens if you leave the configuration file unchanged? I haven't tested g++ version 4.7 yet, but 4.6 works for me...
Because otherwise the -std=c++0x flag isn't used, because the test fails. And without the flag the compiler complains that you're using C++11 features. I guess this is because I forced it to use "some" compiler and CMake does not know whether it's a GNU C++ compiler, thus CMAKE_COMPILER_IS_GNUCXX becomes unreliable.

Hm, I have used thor::BigTexture successfully in Airport. Also I tested quickly for a 10000x5600 image (with a texture limit of 8192), it seems to be displayed correctly.

But maybe there is a problem with Macs, I have never tested it there. What do you mean with garbage? What does sf::Texture::getMaximumSize() return?
sf::Texture::getMaximumSize() returns 8192, and Apple specs say the max texture size for my graphics card is indeed 8192 (see MAX_TEXTURE_SIZE for HD Graphics 3000 (https://developer.apple.com/graphicsimaging/opengl/capabilities/index.html)) but texture won't display on my laptop if they're bigger than 4096 pixels wide. In Thor's sources I divided all of your results for sf::Texture::getMaximumSize() by 2 and it allowed me to use BigTexture for any image size.

What I mean with garbage is this:

(http://lucas.soltic.perso.luminy.univmed.fr/downloads/garby_fractal.png)

instead of this:

(http://lucas.soltic.perso.luminy.univmed.fr/downloads/correct_fractal.png)

In these pictures the texture size is 10800x9600.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 03, 2012, 08:28:50 pm
I guess this is because I forced it to use "some" compiler and CMake does not know whether it's a GNU C++ compiler, thus CMAKE_COMPILER_IS_GNUCXX becomes unreliable.
That's annoying. Do you think I can do something about it? Looks rather like a CMake bug if g++ isn't recognized correctly (or the corresponding variables are not set). In this case we should perhaps write a bug report...

sf::Texture::getMaximumSize() returns 8192, and Apple specs say the max texture size for my graphics card is indeed 8192 [...] but texture won't display on my laptop if they're bigger than 4096 pixels wide..
Have you tried to create a texture of 8000x8000 pixels (or the like) directly with SFML? Thor relies on the texture limit returned by sf::Texture::getMaximumSize(). I assumed it to be correct, no idea why your graphics has problems with a texture size that it officially should support :-\

By the way, thanks a lot for your feedback, Ceylo. I really appreciate people who take the time to test Thor on other systems.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 03, 2012, 08:47:16 pm
That's annoying. Do you think I can do something about it? Looks rather like a CMake bug if g++ isn't recognized correctly (or the corresponding variables are not set). In this case we should perhaps write a bug report...
You should not bother with this, as I had to rebuild GCC. I don't think you'll see much OS X users doing so. What would be really useful is fixing Thor so that it can be built with Clang.

Have you tried to create a texture of 8000x8000 pixels (or the like) directly with SFML? Thor relies on the texture limit returned by sf::Texture::getMaximumSize(). I assumed it to be correct, no idea why your graphics has problems with a texture size that it officially should support :-\

By the way, thanks a lot for your feedback, Ceylo. I really appreciate people who take the time to test Thor on other systems.
Yes I have also tried to use big textures (like 6000x6000) directly with SFML, and I'm having the same issue. That's why I thought I had reached my CG texture size limit, which is also why I've been looking for a BigTexture class, that I found in Thor.

I don't know either why I can only load textures that are half the officially supported size. I didn't notice anything weird in SFML's Texture implementation. But anyway, SFML or my drivers are buggy, not Thor :) .

Anyway, the purpose was to render fractals at huge resolutions so that I could zoom in and enjoy the result (ok, I was also kinda proud of seeing multithreaded rendering in action ;D), but I don't think it's the way to go. I'd better rendering efficiently at 1:1 scale and re-render the zoomed in areas. With this way, as long as SFML can handle textures of at most the screen size it's ok.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 04, 2012, 10:42:51 am
I just saw this thread today, so here are a few general thoughts :

SFML still use Legacy OpenGL profile (and not Core) so the GC specifications are here : https://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1080.html (I didn't compare the two specs but I guess there are some differences between the two. However MAX_TEXTURE_SIZE has the same value in both specs.)

Quote
But anyway, SFML or my drivers are buggy, not Thor  .
I'm betting it's OS X's fault since the related code (https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Texture.cpp#L474-482) is really simple.  :P

If you have plenty of time you could open on issue on Apple's bug tracker (https://developer.apple.com/bugreporter/). However if you don't want to I would totally understand as it took them one whole year to answer one of my issue (https://github.com/SFML/SFML/issues/5), and by answer I mean "we won't fix this"...


C++11 with clang on Mac indeed needs libc++ to work. With SFML (§C++11) (http://www.sfml-dev.org/tutorials/2.0/start-osx.php) you can simply edit your cmake cache; in fact the user should not have to edit any files. Something similar can probably be done in Thor.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 04, 2012, 11:30:14 am
What would be really useful is fixing Thor so that it can be built with Clang.
Indeed. I need to reorganize bigger parts of the Triangulation code, it may take some time until I find a clean solution.

C++11 with clang on Mac indeed needs libc++ to work. With SFML (§C++11) (http://www.sfml-dev.org/tutorials/2.0/start-osx.php) you can simply edit your cmake cache; in fact the user should not have to edit any files. Something similar can probably be done in Thor.
Okay, good to know. It would still be interesting to recognize Clang automatically, but I don't know how (there is no corresponding CMake variable (http://www.cmake.org/Wiki/CMake_Useful_Variables)).

Anyway, it sucks completely that CMake, claimed to be a cross-platform make tool, always requires compiler-specific case differentiations in order to work correctly. This partially defeats its original purpose...
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Laurent on September 04, 2012, 12:27:35 pm
Quote
It would still be interesting to recognize Clang automatically, but I don't know how (there is no corresponding CMake variable).
You can check the compiler ID (CMAKE_COMPILER_ID?).
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 04, 2012, 12:53:39 pm
If you have plenty of time you could open on issue on Apple's bug tracker (https://developer.apple.com/bugreporter/). However if you don't want to I would totally understand as it took them one whole year to answer one of my issue (https://github.com/SFML/SFML/issues/5), and by answer I mean "we won't fix this"...
First I'm trying to load a texture without using SFML to see what happens. I must have forgotten something though because for now I only get a white square on a red background ::) . Once it works I'll test with much bigger sizes. If anyone sees what's wrong here...
    // init function
    glClearColor(1, 0, 0, 1);
   
    unsigned width = 128;
    unsigned heigth = 128;
    unsigned char *data = malloc(width * heigth * 4);
    assert(data != NULL);
   
    for (unsigned x = 0; x < width;x++)
    {
        for (unsigned y = 0; y < heigth;y++)
        {
            if ((y * width + x) % 2 == 0)
            {
                data[(y * width + x) * 4 + 0] = 0;
                data[(y * width + x) * 4 + 1] = 0;
                data[(y * width + x) * 4 + 2] = 255;
                data[(y * width + x) * 4 + 3] = 255;
            }
            else
            {
                data[(y * width + x) * 4 + 0] = 255;
                data[(y * width + x) * 4 + 1] = 0;
                data[(y * width + x) * 4 + 2] = 0;
                data[(y * width + x) * 4 + 3] = 255;
            }
        }
    }
   
    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &textureId);
    glBindTexture(GL_TEXTURE_2D, textureId);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, heigth, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
 

    // draw function
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
    glBindTexture(GL_TEXTURE_2D, textureId);
   
    glPushMatrix();
    glTranslatef(0.1, 0.1, 0);
    glScalef(0.8, 0.8, 0.8);
   
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
    glTexCoord2f(1.0f, 0.0f); glVertex2f( 1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
    glTexCoord2f(1.0f, 1.0f); glVertex2f( 1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f,  1.0f);  // Top Left Of The Texture and Quad
    glEnd();
   
    glPopMatrix();
   
    [[self.glView openGLContext] flushBuffer];
 
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 04, 2012, 06:38:25 pm
Laurent, thanks for the hint.

Ceylo, can you tell me what the following CMake code outputs for Clang?
message("CMake compiler = [${CMAKE_CXX_COMPILER}]")
message("CMake compiler ID = [${CMAKE_CXX_COMPILER_ID}]")

Concerning the OpenGL code, you don't call glMatrixMode(). And I think, also glLoadIdentity() before other transforms is necessary.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 04, 2012, 08:35:59 pm
CMake outputs this:
Code: [Select]
CMake compiler = [/usr/bin/c++]
CMake compiler ID = [Clang]

As for the OpenGL code... I tried what you said (although I'm not sure where to put these calls) but I still get a white square instead of my texture:
glClearColor(1, 0, 0, 1);

unsigned width = 128;
unsigned heigth = 128;
unsigned char *data = malloc(width * heigth * 4);
assert(data != NULL);

for (unsigned x = 0; x < width;x++)
{
    for (unsigned y = 0; y < heigth;y++)
    {
        if ((y * width + x) % 2 == 0)
        {
            data[(x * heigth + y) * 4 + 0] = 0;
            data[(x * heigth + y) * 4 + 1] = 0;
            data[(x * heigth + y) * 4 + 2] = 255;
            data[(x * heigth + y) * 4 + 3] = 255;
        }
        else
        {
            data[(x * heigth + y) * 4 + 0] = 255;
            data[(x * heigth + y) * 4 + 1] = 0;
            data[(x * heigth + y) * 4 + 2] = 0;
            data[(x * heigth + y) * 4 + 3] = 255;
        }
    }
}

glEnable(GL_TEXTURE_2D);
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, heigth, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glBindTexture(GL_TEXTURE_2D, textureId);

glRotatef(1, 0, 0, 5);
glPushMatrix();
glTranslatef(0.1, 0.1, 0);
glScalef(0.8, 0.8, 0.8);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f);  // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex2f( 1.0f, -1.0f);  // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex2f( 1.0f,  1.0f);  // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f,  1.0f);  // Top Left Of The Texture and Quad
glEnd();

glPopMatrix();

[[self.glView openGLContext] flushBuffer];

After checking the OpenGL errors I noticed it says "GL_INVALID_OPERATION, the specified operation is not allowed in the current state" (ok I copied SFML glCheck function ::) ) on the glEnd(); call but I don't know why...
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Laurent on September 04, 2012, 09:54:30 pm
Maybe you can post your full code so that we can test it?
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 05, 2012, 12:33:38 am
CMake outputs this:
Code: [Select]
CMake compiler = [/usr/bin/c++]
CMake compiler ID = [Clang]
Thanks, this allows me to check for "Clang" in my CMake scripts. I also heard they might change the ID in the future, but well, I don't have a better option ;)

Just to make sure Clang 3.1's problem is really related to recursive iterator types: Could you compile the following minimal code and tell me if there are error messages (and which ones)?
#include <list>

struct Triangle
{
    std::list<Triangle>::iterator i;
};

int main() {}
With the online compiler (http://llvm.org/demo/index.cgi) of Clang 3.0, the code compiles.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 05, 2012, 02:24:18 am
Just to make sure Clang 3.1's problem is really related to recursive iterator types: Could you compile the following minimal code and tell me if there are error messages (and which ones)?
It does compile fine without any error/warning message.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 05, 2012, 02:42:44 am
And here's a fully "working" sample code based on GLUT: http://pastebin.com/arkhyg7q
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 05, 2012, 10:21:52 pm
After trying several things, reading masses of stackoverflow topics and recompiling clang for Windows (which worked, but clang++.exe always yielded linker errors -- thanks for not mentioning this in the tutorial (http://clang.llvm.org/get_started.html)), I have finally found a version (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.1-release/) that works on Windows. It uses the GNU libstdc++ instead of libc++ however (I don't know if the latter has been ported to Windows, by the way I'll never understand why it's not possible to name standard libraries meaningfully). In the command line, clang++ --version outputs the following:
Quote
clang version 3.1 (tags/RELEASE_31/final 161181) (llvm/tags/RELEASE_31/final 161243)
Target: i686-w64-mingw32
Thread model: posix

I have tried to compile Thor with it, and the compiler crashed as a result of the SFINAE used in Math/Distribution.hpp. After removing that, everything compiled -- unfortunately. The triangulation code didn't raise any errors, so it's probably really the STL of libc++ which can't handle incomplete types.

For me, that's a little bit unfortunate, because I have no option to reproduce the errors. And the fact that the short code I posted works for your Apple Clang doesn't make it easier to find the source of the issue... :/
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 05, 2012, 11:37:53 pm
I don't really know what to say. I also find it weird that Apple's Clang says its version is 4.0 whereas LLVM website claims v3.1 has just been released. Plus the c++11 library doesn't seem to be available on Apple's opensource page (http://opensource.apple.com/release/mac-os-x-1081/).

I can't either help you as I don't understand what's wrong, I mostly do not know C++11 and I can't follow clang's error messages here (too much "redirections").

The best I can do is test other sample codes of yours, or give you SSH access to my laptop so that you can test as much as you want.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 06, 2012, 12:02:40 am
I found libc++: http://libcxx.llvm.org
However it only supports OS X so you won't be able to test it on your computer.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 06, 2012, 10:36:55 am
Thank you very much for your help. It looks at least like there is some effort (http://clang-developers.42468.n3.nabble.com/Libc-Windows-fixes-td3117479.html) to port libc++ on Windows. Hopefully it will be usable one day :)

Could you test this snippet? Comeau online doesn't compile this code.
#include <list>

struct Triangle;
typedef std::list<Triangle>::iterator Iterator;
 
struct Triangle
{
    Iterator i;
};

int main() {}

By the way, I have looked at your OpenGL code, but I haven't seen the mistake or been able to make it work... But my OpenGL experience is limited, someone else knows probably better :-\
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 06, 2012, 10:49:14 am
This code compiles fine with both GCC and Clang.

$ /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc-4.2 --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --version
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.1.0
Thread model: posix
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 06, 2012, 11:12:13 am
This code compiles fine with both GCC and Clang.
Not exactly.

It does compile fine using `clang++ cl.cpp -Wall -std=c++0x` but not with `clang++ cl.cpp -Wall -std=c++0x -stdlib=libc++`:
Code: [Select]
In file included from cl.cpp:1:
/usr/bin/../lib/c++/v1/list:212:9: error: field has incomplete type 'Triangle'
    _Tp __value_;
        ^
/usr/bin/../lib/c++/v1/type_traits:1889:54: note: in instantiation of template class 'std::__1::__list_node<Triangle, void *>' requested here
decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...)), true_type())
                                                     ^
/usr/bin/../lib/c++/v1/type_traits:1890:1: note: while substituting deduced template arguments into function template '__is_constructible_test'
      [with _Tp = std::__1::allocator<std::__1::__list_node<Triangle, void *>>, _Args = <no value>]
__is_constructible_test(_Tp&&, _Args&& ...);
^
/usr/bin/../lib/c++/v1/type_traits:1949:14: note: in instantiation of template class 'std::__1::__is_constructible<false,
      std::__1::allocator<std::__1::__list_node<Triangle, void *>>, std::__1::allocator<std::__1::__list_node<Triangle, void *>> &&>' requested
      here
    : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
             ^
/usr/bin/../lib/c++/v1/type_traits:1975:14: note: in instantiation of template class 'std::__1::__is_constructible_void_check<false,
      std::__1::allocator<std::__1::__list_node<Triangle, void *>>, std::__1::allocator<std::__1::__list_node<Triangle, void *>> &&>' requested
      here
    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
             ^
/usr/bin/../lib/c++/v1/type_traits:2455:34: note: in instantiation of template class
      'std::__1::is_constructible<std::__1::allocator<std::__1::__list_node<Triangle, void *>>,
      std::__1::allocator<std::__1::__list_node<Triangle, void *>> &&>' requested here
    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
                                 ^
/usr/bin/../lib/c++/v1/type_traits:2590:14: note: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 to see all)
    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
             ^
/usr/bin/../lib/c++/v1/memory:2219:20: note: in instantiation of template class
      'std::__1::is_nothrow_move_constructible<std::__1::allocator<std::__1::__list_node<Triangle, void *>>>' requested here
                   is_nothrow_move_constructible<_T2>::value)
                   ^
/usr/bin/../lib/c++/v1/__config:253:34: note: expanded from macro '_NOEXCEPT_'
#  define _NOEXCEPT_(x) noexcept(x)
                                 ^
/usr/bin/../lib/c++/v1/memory:2386:15: note: in instantiation of template class 'std::__1::__libcpp_compressed_pair_imp<unsigned long,
      std::__1::allocator<std::__1::__list_node<Triangle, void *>>, 2>' requested here
    : private __libcpp_compressed_pair_imp<_T1, _T2>
              ^
/usr/bin/../lib/c++/v1/list:513:52: note: in instantiation of template class 'std::__1::__compressed_pair<unsigned long,
      std::__1::allocator<std::__1::__list_node<Triangle, void *>>>' requested here
    __compressed_pair<size_type, __node_allocator> __size_alloc_;
                                                   ^
/usr/bin/../lib/c++/v1/list:770:15: note: in instantiation of template class 'std::__1::__list_imp<Triangle, std::__1::allocator<Triangle>>'
      requested here
    : private __list_imp<_Tp, _Alloc>
              ^
cl.cpp:4:14: note: in instantiation of template class 'std::__1::list<Triangle, std::__1::allocator<Triangle>>' requested here
typedef std::list<Triangle>::iterator Iterator;
             ^
cl.cpp:3:8: note: forward declaration of 'Triangle'
struct Triangle;
       ^
1 error generated.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 06, 2012, 11:16:30 am
Yes, indeed. I was trying to compile thor too and didn't understand why apparently same code didn't work for thor but did for this sample.. Sorry for the false positive. :/
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 06, 2012, 11:25:36 am
What's weird though is it'll build fine with `clang++ cl.cpp -Wall -stdlib=libc++`.

I also noticed that without -stdlib=libc++, when building Thor, clang will complain about the missing type_traits file but replacing
Code: [Select]
#include <type_traits>with
Code: [Select]
#include <tr1/type_traits>allows some errors to be fixed (by also using std::tr1 instead of std:: ). However other names like std::conditional don't seem to be fixable with that way as they're part of C++11.

Edit: note that your first sample code to test clang actually does not compile fine when using -std=c++0x and -stdlib=libc++. It works with one or the other but not both, so it was a false positive too.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 06, 2012, 11:35:14 am
This bug (http://llvm.org/bugs/show_bug.cgi?id=13471) seems to be exactly what we're looking at right now.

And this article (http://clang.llvm.org/compatibility.html#undep_incomplete) states that clang behaviour on this won't be changed. But comment #2 (http://llvm.org/bugs/show_bug.cgi?id=13471#c2) says otherwise. So I'm confused...

Maybe the workaround exposed by Howard Hinnant in comment #3 can be useful.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 06, 2012, 01:53:22 pm
Great, finally a reproducable error! Thank you both very much! :D

It isn't a bug in libc++. According to the C++ standard, the behavior of incomplete types as STL template parameters is undefined. It might also become an issue in other standard libraries as the implementation of C++11 features progresses. So I need to adapt Thor.

The question is just how: An additional indirection (either container of std::unique_ptrs or a custom iterator using Pimpl) is easy to implement, but requires dynamic memory management, which might become expensive if it is used all the time. In another forum someone mentioned Boost's intrusive containers (they allow conversion of pointers to iterators, so I can break the dependency cycle), and although I won't use Boost for Thor, the concept is interesting. But I'll probably stick to the indirection approach, optimizations are still possible.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 06, 2012, 09:45:51 pm
I pushed two changes: CMake adaption and Triangulation refactoring. Does the newest Thor revision work?
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 06, 2012, 10:03:41 pm
Haha, a little bit better, but now you got Clang to crash :P

Code: [Select]
[  4%] Building CXX object src/CMakeFiles/thor.dir/Emitter.cpp.o
0  clang             0x00000001010536f2 main + 17107682
1  clang             0x0000000101053b79 main + 17108841
2  libsystem_c.dylib 0x00007fff8881492a _sigtramp + 26
3  libsystem_c.dylib 0x00000000000000a0 _sigtramp + 18446603338225989520
4  clang             0x0000000100156017 main + 1389575
5  clang             0x00000001001555c0 main + 1386928
6  clang             0x00000001005b7c72 main + 5984354
7  clang             0x00000001001558e8 main + 1387736
8  clang             0x00000001005b80db main + 5985483
9  clang             0x00000001005b6a05 main + 5979637
10 clang             0x00000001005b51ec main + 5973468
11 clang             0x00000001005b4b67 main + 5971799
12 clang             0x00000001005bbff6 main + 6001638
13 clang             0x00000001005bbc3a main + 6000682
14 clang             0x00000001007e355a main + 8259914
15 clang             0x00000001005b6008 main + 5977080
16 clang             0x00000001005b4b67 main + 5971799
17 clang             0x000000010015543b main + 1386539
18 clang             0x00000001005b9078 main + 5989480
19 clang             0x00000001005b86f1 main + 5987041
20 clang             0x0000000100159254 main + 1402436
21 clang             0x0000000100158cbd main + 1401005
22 clang             0x0000000100503e83 main + 5247603
23 clang             0x00000001005bc864 main + 6003796
24 clang             0x000000010015851b main + 1399051
25 clang             0x00000001005b9567 main + 5990743
26 clang             0x000000010015559a main + 1386890
27 clang             0x000000010015539a main + 1386378
28 clang             0x000000010014c899 main + 1350793
29 clang             0x000000010014cd8b main + 1352059
30 clang             0x000000010014cc20 main + 1351696
31 clang             0x000000010014c7ca main + 1350586
32 clang             0x00000001005baa88 main + 5996152
33 clang             0x000000010013364b main + 1247803
34 clang             0x00000001005ba8f2 main + 5995746
35 clang             0x0000000100112b37 main + 1113895
36 clang             0x000000010018a627 main + 1604119
37 clang             0x000000010018a3b7 main + 1603495
38 clang             0x000000010018a0bd main + 1602733
39 clang             0x0000000100047606 main + 281078
40 clang             0x0000000100045bbe main + 274350
41 clang             0x0000000100044c01 main + 270321
42 clang             0x0000000100019ae2 main + 93906
43 clang             0x0000000100018748 main + 88888
44 clang             0x0000000100006438 main + 14376
45 clang             0x0000000100002e97 main + 647
46 clang             0x0000000100002c04
Stack dump:
0. Program arguments: /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -disable-free -disable-llvm-verifier -main-file-name Emitter.cpp -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 133.3 -coverage-file CMakeFiles/thor.dir/Emitter.cpp.o -resource-dir /usr/bin/../lib/clang/4.0 -D thor_EXPORTS -D THOR_EXPORTS -D NDEBUG -I /Users/ceylo/Development/Thor/include -I /Users/ceylo/Development/Thor/extlibs/aurora/include -F/Library/Frameworks -fmodule-cache-path /var/folders/8f/3bhx1ymn6jz6z2xr5hmq841h0000gn/T/clang-module-cache -stdlib=libc++ -O3 -std=c++0x -fdeprecated-macro -fdebug-compilation-dir /Users/ceylo/Development/Thor/src -ferror-limit 19 -fmessage-length 160 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/thor.dir/Emitter.cpp.o -x c++ /Users/ceylo/Development/Thor/src/Emitter.cpp
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. /Users/ceylo/Development/Thor/include/Thor/Math/Distribution.hpp:62:10: Generating code for declaration 'thor::Distribution<sf::Color>::Distribution'
4. /Users/ceylo/Development/Thor/include/Thor/Math/Distribution.hpp:65:3: LLVM IR generation of compound statement ('{}')
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/8f/3bhx1ymn6jz6z2xr5hmq841h0000gn/T/Emitter-P2fPFg.ii
clang: note: diagnostic msg: /var/folders/8f/3bhx1ymn6jz6z2xr5hmq841h0000gn/T/Emitter-P2fPFg.sh
make[2]: *** [src/CMakeFiles/thor.dir/Emitter.cpp.o] Error 254
make[1]: *** [src/CMakeFiles/thor.dir/all] Error 2
make: *** [all] Error 2
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 07, 2012, 08:21:25 am
Okay, but at least I can reproduce this error :)
Quote from: Nexus
and the compiler crashed as a result of the SFINAE used in Math/Distribution.hpp

Let's see if I can find the source of the problem ;)
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 07, 2012, 08:24:36 am
Commenting Distribution.hpp:68 (https://github.com/Bromeon/Thor/blob/master/include/Thor/Math/Distribution.hpp#L68) prevent clang from crashing. (And it seems that Random.cpp has other issues too.)

I'm currently trying to create a minimal code reproducing the issue. I let you know if I succeed (or failed).
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 07, 2012, 09:02:36 am
I have been able to come up with a minimal example:
struct Color {};

struct Distribution
{
        Distribution()
        {
                Color copy;
                auto fn = [copy] () { return copy; };
        }
};

int main()
{
        Distribution x;
}

The issue is not related to SFINAE. It rather looks like a compiler bug concerning lambda expressions that refer to local variables. If copy is a parameter, Clang doesn't crash.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 07, 2012, 09:13:26 am
Yes, it seems there is something going wrong with non basic types. However, I found a solution that seems to work :

#include <functional>
#include <type_traits>
#include <string>

template <typename T>
class Distribution {
    typedef std::function<T()> FactoryFn;

public:
//    template <typename U, class = typename std::enable_if<std::is_convertible<U, T>::value>::type>
//    Distribution(U cst)
    template <typename U>
    Distribution(U cst, typename std::enable_if<std::is_convertible<U, T>::value>::type* = 0)
    : m_factory()
    {
        T copy = cst;
//        m_factory = [copy] () { return copy; }; // FIX : replace this line
        m_factory = [cst] () { return cst; }; // with this one.
    }

private:
    FactoryFn m_factory;
};

struct Foo {
    char c, d;
    Foo() : c(0), d(0) { }
    Foo(char c, char d) : c(c), d(d) { }
};

struct Bar {
    char c, d;
    Bar() : c(0), d(0) { }
    Bar(char c, char d) : c(c), d(d) { }
    Bar(Bar const& bar) : c(bar.c), d(bar.d) { }
    Bar(Bar && bar) : c(std::move(bar.c)), d(std::move(bar.d)) { }
    Bar& operator=(Bar const bar) { c = bar.c; d = bar.d; return *this; }
    Bar& operator=(Bar && bar) { c = std::move(bar.c); d = std::move(bar.d); return *this; }
    ~Bar() { }
};

int main(int argc, const char * argv[])
{
    char someChar = 58;
    Distribution<int> distInt(someChar);

    std::string someString = "42";
//    Distribution<int> distInt2(someString); // Error, no matching ctor (as expected), no crash here

    Distribution<std::string> distStr(someString); // _WAS_ CRASHING HERE

    Distribution<float> distFloat(3.f);
    Distribution<double> distDouble(3.0);


    Foo someFoo = {'a', 'A'};
    Distribution<Foo> distFoo(someFoo); // _WAS_ CRASHING HERE

    Bar someBar = {'b', 'B'};
    Distribution<Bar> distBar(someBar); // _WAS_ CRASHING HERE

    [someBar]() { return someBar; }();

    return 0;
}
 

As you can see, before the fix, only basic types like int or double worked. Now, if we apply the fix everything works fine.

I test it out on Thor and clang doesn't crash anymore.  :)

Replace line 68 with
mFactory = [constant] () { return constant; };
and remove line 67 as it's no longer needed.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 07, 2012, 09:22:39 am
Previously I said there were error in Random.cpp. Here is the log :
[  4%] Building CXX object src/CMakeFiles/thor.dir/Random.cpp.o
In file included from /Users/hiura/Prog/Libraries/C++/SFML extra/Thor/git/Thor/src/Random.cpp:30:
In file included from /usr/bin/../lib/c++/v1/random:1641:
/usr/bin/../lib/c++/v1/algorithm:2510:54: error: no member named '_Max' in
      'thor::<anonymous>::Engine'
    static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
                                            ~~~~~~~~~^
/usr/bin/../lib/c++/v1/algorithm:2681:41: note: in instantiation of template class
      'std::__1::__independent_bits_engine<thor::<anonymous>::Engine, unsigned int>' requested here
        return static_cast<result_type>(_Eng(__g, _Dt)());
                                        ^
/usr/bin/../lib/c++/v1/algorithm:2647:17: note: in instantiation of function template specialization
      'std::__1::uniform_int_distribution<int>::operator()<thor::<anonymous>::Engine>' requested
      here
        {return (*this)(__g, __p_);}
                ^
/Users/hiura/Prog/Libraries/C++/SFML extra/Thor/git/Thor/src/Random.cpp:119:21: note: in
      instantiation of function template specialization
      'std::__1::uniform_int_distribution<int>::operator()<thor::<anonymous>::Engine>' requested
      here
        return distribution(globalEngine);
                           ^
In file included from /Users/hiura/Prog/Libraries/C++/SFML extra/Thor/git/Thor/src/Random.cpp:30:
/usr/bin/../lib/c++/v1/random:3524:51: error: no member named '_Max' in 'thor::<anonymous>::Engine'
    const size_t __logR = __log2<uint64_t, _URNG::_Max - _URNG::_Min + uint64_t(1)>::value;
                                           ~~~~~~~^
/usr/bin/../lib/c++/v1/random:3655:11: note: in instantiation of function template specialization
      'std::__1::generate_canonical<float, 24, thor::<anonymous>::Engine>' requested here
        * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
          ^
/usr/bin/../lib/c++/v1/__config:266:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/usr/bin/../lib/c++/v1/random:3619:17: note: in instantiation of function template specialization
      'std::__1::uniform_real_distribution<float>::operator()<thor::<anonymous>::Engine>' requested
      here
        {return (*this)(__g, __p_);}
                ^
/Users/hiura/Prog/Libraries/C++/SFML extra/Thor/git/Thor/src/Random.cpp:132:21: note: in
      instantiation of function template specialization
      'std::__1::uniform_real_distribution<float>::operator()<thor::<anonymous>::Engine>' requested
      here
        return distribution(globalEngine);
                           ^
In file included from /Users/hiura/Prog/Libraries/C++/SFML extra/Thor/git/Thor/src/Random.cpp:30:
/usr/bin/../lib/c++/v1/random:3526:34: error: no member named '_Max' in 'thor::<anonymous>::Engine'
    const _RealType _Rp = _URNG::_Max - _URNG::_Min + _RealType(1);
                          ~~~~~~~^
/usr/bin/../lib/c++/v1/random:3528:36: error: no member named '_Min' in 'thor::<anonymous>::Engine'
    _RealType _Sp = __g() - _URNG::_Min;
                            ~~~~~~~^
4 errors generated.
 

However, defining THOR_USE_STD_RANDOMENGINE solves that, i.e. adding -DTHOR_USE_STD_RANDOMENGINE to CMAKE_CXX_FLAGS.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 07, 2012, 09:25:52 am
Replace line 68 with
mFactory = [constant] () { return constant; };
and remove line 67 as it's no longer needed.

You didn't read the comment :P
// Convert to T first to avoid conversion happening at every function call.

But I think I can use a classical functor instead. Can you submit a bug report? Even if it takes a year, it's better than nothing ;)
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Hiura on September 07, 2012, 10:43:05 am
Yep, I missed that one  ::)

Bug reported.

Ho, and after compiling SFML with -stdlib=libc++, everything work!
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 07, 2012, 03:13:36 pm
I pushed the Distribution workaround.


error: no member named '_Max' in 'thor::<anonymous>::Engine'
error: no member named '_Min' in 'thor::<anonymous>::Engine'
_Max() and _Min() are not required for random number engines by the standard. The methods are called min() and max(), which I have implemented.

Another bug in libc++...


Ho, and after compiling SFML with -stdlib=libc++, everything work!
With the newest Thor revision, what changes are necessary to compile successfully? Only a #define THOR_USE_STD_RANDOMENGINE?
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 07, 2012, 03:45:19 pm
With the newest Thor revision, what changes are necessary to compile successfully? Only a #define THOR_USE_STD_RANDOMENGINE?
Yes :) .
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 07, 2012, 04:11:48 pm
Okay, fix implemented and pushed. I hope it's the last one for the moment :D
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 07, 2012, 04:15:51 pm
You removed the -stdlib=libc++, it doesn't work without it:
Code: [Select]
/Users/ceylo/Development/Thor/extlibs/aurora/include/Aurora/Tools/Metaprogramming.hpp:31:10: fatal error: 'type_traits' file not found
#include <type_traits>
         ^
1 error generated.

There's no other C++11 standard library installed so you have to specify libc++ if you want support for C++11.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 07, 2012, 04:50:13 pm
Oh, this was not my intention, it's corrected now.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Ceylo on September 07, 2012, 05:02:17 pm
Everything builds fine now :)

There's only this warning remaining (FYI only):
Code: [Select]
/Users/ceylo/Development/Thor/src/ActionOperations.cpp:63:11: warning: 17 enumeration values not handled in switch: 'Closed', 'Resized',
      'TextEntered'... [-Wswitch]
                switch (event.type)
                        ^
1 warning generated.
Title: Re: Thor 2.0 cmake build error OS X 10.7
Post by: Nexus on September 07, 2012, 05:09:00 pm
Yes, I also got it on Windows. I find the warning a little bit questionable, I don't want to write an empty default branch everytime I handle only some of the cases. But maybe it would be better practice, in case an enumerator is really forgotten.

Apart from that, I'm really glad it works now. Great thanks to both of you (Ceylo and Hiura) for helping me with feedback and testing Thor on Mac! :)