[gecode-users] Compilation problems with latest Xcode

Torsten Anders Torsten.Anders at beds.ac.uk
Thu Dec 12 13:09:10 CET 2013


On 3 Nov 2013, at 23:01, Guido Tack <tack at gecode.org> wrote:
> I can reproduce the linker issue related to the branch function, and I currently don’t know what the problem might be.


Has anybody perhaps managed to get Gecode programs compiled with the latest Xcode (5.0.2)?

If I create a project with the first example of the tutorial (http://www.gecode.org/doc/4.2.0/MPG/send-more-money.cpp), and add the Gecode framework, then the build fails as detailed below. 

Interestingly, using the minimal flags of the tutorial as follows does work. So, this may not be a problem of the compiler clang, but Xcode -- possibly one of the many flags set by Xcode automatically gets in the way?
 
clang++ -O3 -c send-more-money.cpp
clang++ -framework gecode -o send-more-money send-more-money.cpp

By contrast, for the Xcode project send-more-money, where the actual sources are in the file main.cpp, Xcode generates the following call with the shown error message. I have difficulties understanding this call (I am now to C++) to identify where the problem may be. Anyway, I noticed that the flag  -framework geocode is there.

Any help?

Ld /Users/torsten/Library/Developer/Xcode/DerivedData/send-more-money-auavgbgssaurbrdkynwwzauevqbu/Build/Products/Debug/send-more-money normal x86_64
    cd /Users/torsten/c_cpp/Gecode/send-more-money
    setenv MACOSX_DEPLOYMENT_TARGET 10.8
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/torsten/Library/Developer/Xcode/DerivedData/send-more-money-auavgbgssaurbrdkynwwzauevqbu/Build/Products/Debug -F/Users/torsten/Library/Developer/Xcode/DerivedData/send-more-money-auavgbgssaurbrdkynwwzauevqbu/Build/Products/Debug -F/Library/Frameworks -filelist /Users/torsten/Library/Developer/Xcode/DerivedData/send-more-money-auavgbgssaurbrdkynwwzauevqbu/Build/Intermediates/send-more-money.build/Debug/send-more-money.build/Objects-normal/x86_64/send-more-money.LinkFileList -mmacosx-version-min=10.8 -stdlib=libc++ -framework gecode -Xlinker -dependency_info -Xlinker /Users/torsten/Library/Developer/Xcode/DerivedData/send-more-money-auavgbgssaurbrdkynwwzauevqbu/Build/Intermediates/send-more-money.build/Debug/send-more-money.build/Objects-normal/x86_64/send-more-money_dependency_info.dat -o /Users/torsten/Library/Developer/Xcode/DerivedData/send-more-money-auavgbgssaurbrdkynwwzauevqbu/Build/Products/Debug/send-more-money
 
Undefined symbols for architecture x86_64:
  "Gecode::branch(Gecode::Home, Gecode::IntVarArgs const&, Gecode::IntVarBranch, Gecode::IntValBranch, bool (*)(Gecode::Space const&, Gecode::IntVar, int), void (*)(Gecode::Space const&, Gecode::BrancherHandle const&, unsigned int, Gecode::IntVar, int, int const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&))", referenced from:
      SendMoreMoney::SendMoreMoney() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Best wishes,
Torsten

PS: I am using MacOS 10.8.5


--
Dr Torsten Anders
Course Leader, Music Technology
University of Bedfordshire
Park Square, Room A315
http://www.torsten-anders.de




On 3 Nov 2013, at 23:01, Guido Tack <tack at gecode.org> wrote:
> The linker problems in your second example can be fixed by using clang++ instead of clang (so that the standard C++ library gets linked).  However I can reproduce the linker issue related to the branch function, and I currently don’t know what the problem might be.  We’re preparing a new release at the moment, and I’ll try to get this fixed as soon as possible.
> 
> Cheers,
> Guido
> 
> On 4 Nov 2013, at 9:29 am, Torsten Anders <Torsten.Anders at beds.ac.uk> wrote:
> 
>> Dear Guido,
>> 
>> Thanks a lot for your help! After removing /usr/local/gecode (ignored by uninstall.sh -- likely too old), I could compile and run send-more-money.cpp successfully with g++ at the command line as described in the tutorial. Great! 
>> 
>> However, I would like to use Gecode with an IDE. I tried configuring Xcode as described in your tutorial, but still ran into linking problems. I added the geocode framework (not shown in the list, had to directly move to the path /Library/Frameworks/gecode.framework. For Xcode, the Gecode tutorial recommends "You may have to edit your project settings to choose Mac OS 10.6 as the base SDK." With the current version Xcode 5.01 that is not possible anymore. Anyway, regardless whether or not it is set to my system 10.8, I get linker errors from clang.
>> 
>> Undefined symbols for architecture x86_64:
>> "Gecode::branch(Gecode::Home, Gecode::IntVarArgs const&, Gecode::IntVarBranch, Gecode::IntValBranch, bool (*)(Gecode::Space const&, Gecode::IntVar, int), void (*)(Gecode::Space const&, Gecode::BrancherHandle const&, unsigned int, Gecode::IntVar, int, int const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&))", referenced from:
>>    SendMoreMoney::SendMoreMoney() in main.o
>> ld: symbol(s) not found for architecture x86_64
>> 
>> With Eclipse I have similar problems.
>> 
>> To better understand the problem I tried command line calls for clang with the same arguments as for g++ given in your tutorial, and got the more detailed error message below. Not sure whether my flags are exactly the same in Xcode as well, but the error looks at least similar. 
>> 
>> Any idea what I could be missing? Thanks a lot! 
>> 
>> Best wishes,
>> Torsten
>> 
>> 
>> The following silently results in an *.o file.
>> 
>> $ clang -O3 -c send-more-money.cpp
>> 
>> $ clang -framework gecode -o send-more-money send-more-money.cpp
>> Undefined symbols for architecture x86_64:
>> "std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::str() const", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
>>    SendMoreMoney::print() const in send-more-money-cyceYe.o
>> "std::ostream::operator<<(int)", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::ios_base::Init::Init()", referenced from:
>>    ___cxx_global_var_init in send-more-money-cyceYe.o
>> "std::ios_base::Init::~Init()", referenced from:
>>    ___cxx_global_var_init in send-more-money-cyceYe.o
>> "std::basic_ios<char, std::char_traits<char> >::copyfmt(std::basic_ios<char, std::char_traits<char> > const&)", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::exception::~exception()", referenced from:
>>    Gecode::Exception::~Exception() in send-more-money-cyceYe.o
>> "std::cout", referenced from:
>>    SendMoreMoney::print() const in send-more-money-cyceYe.o
>> "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
>>    SendMoreMoney::print() const in send-more-money-cyceYe.o
>> "std::terminate()", referenced from:
>>    ___clang_call_terminate in send-more-money-cyceYe.o
>> "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::Int::print_view<char, std::char_traits<char>, Gecode::Int::IntView>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::Int::IntView const&) in send-more-money-cyceYe.o
>> "vtable for __cxxabiv1::__class_type_info", referenced from:
>>    typeinfo for Gecode::SharedHandle::Object in send-more-money-cyceYe.o
>>    typeinfo for Gecode::ActorLink in send-more-money-cyceYe.o
>>    typeinfo for Gecode::Choice in send-more-money-cyceYe.o
>>    typeinfo for Gecode::Search::Stop in send-more-money-cyceYe.o
>>    typeinfo for Gecode::Search::Cutoff in send-more-money-cyceYe.o
>> NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
>> "vtable for __cxxabiv1::__si_class_type_info", referenced from:
>>    typeinfo for Gecode::Rnd::IMP in send-more-money-cyceYe.o
>>    typeinfo for Gecode::PosChoice in send-more-money-cyceYe.o
>>    typeinfo for Gecode::DFA::DFAI in send-more-money-cyceYe.o
>>    typeinfo for SendMoreMoney in send-more-money-cyceYe.o
>>    typeinfo for Gecode::MemoryExhausted in send-more-money-cyceYe.o
>> NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
>> "vtable for __cxxabiv1::__vmi_class_type_info", referenced from:
>>    typeinfo for Gecode::Actor in send-more-money-cyceYe.o
>> NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
>> "operator delete(void*)", referenced from:
>>    Gecode::MemoryExhausted::~MemoryExhausted() in send-more-money-cyceYe.o
>> "___cxa_allocate_exception", referenced from:
>>    _main in send-more-money-cyceYe.o
>>    SendMoreMoney::SendMoreMoney() in send-more-money-cyceYe.o
>>    SendMoreMoney::copy(bool) in send-more-money-cyceYe.o
>>    Gecode::IntVarArgs::IntVarArgs(int) in send-more-money-cyceYe.o
>>    Gecode::VarArgArray<Gecode::IntVar>::VarArgArray(Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>> "___cxa_begin_catch", referenced from:
>>    ___clang_call_terminate in send-more-money-cyceYe.o
>> "___cxa_free_exception", referenced from:
>>    _main in send-more-money-cyceYe.o
>>    SendMoreMoney::SendMoreMoney() in send-more-money-cyceYe.o
>>    SendMoreMoney::copy(bool) in send-more-money-cyceYe.o
>>    Gecode::IntVarArgs::IntVarArgs(int) in send-more-money-cyceYe.o
>>    Gecode::VarArgArray<Gecode::IntVar>::VarArgArray(Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>> "___cxa_pure_virtual", referenced from:
>>    vtable for Gecode::SharedHandle::Object in send-more-money-cyceYe.o
>>    vtable for Gecode::Actor in send-more-money-cyceYe.o
>>    vtable for Gecode::Choice in send-more-money-cyceYe.o
>>    vtable for Gecode::Search::Stop in send-more-money-cyceYe.o
>>    vtable for Gecode::Search::Cutoff in send-more-money-cyceYe.o
>> "___cxa_throw", referenced from:
>>    _main in send-more-money-cyceYe.o
>>    SendMoreMoney::SendMoreMoney() in send-more-money-cyceYe.o
>>    SendMoreMoney::copy(bool) in send-more-money-cyceYe.o
>>    Gecode::IntVarArgs::IntVarArgs(int) in send-more-money-cyceYe.o
>>    Gecode::VarArgArray<Gecode::IntVar>::VarArgArray(Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>> "___dynamic_cast", referenced from:
>>    _main in send-more-money-cyceYe.o
>> "___gxx_personality_v0", referenced from:
>>    _main in send-more-money-cyceYe.o
>>    Gecode::SharedHandle::Object::~Object() in send-more-money-cyceYe.o
>>    Gecode::Rnd::IMP::~IMP() in send-more-money-cyceYe.o
>>    Gecode::DFA::DFAI::~DFAI() in send-more-money-cyceYe.o
>>    Gecode::DFA::DFAI::~DFAI() in send-more-money-cyceYe.o
>>    Gecode::PosChoice::~PosChoice() in send-more-money-cyceYe.o
>>    std::basic_ostream<char, std::char_traits<char> >& Gecode::operator<<<char, std::char_traits<char>, Gecode::IntVar>(std::basic_ostream<char, std::char_traits<char> >&, Gecode::VarArray<Gecode::IntVar> const&) in send-more-money-cyceYe.o
>>    ...
>> ld: symbol(s) not found for architecture x86_64
>> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>> Torstens-MacBook-Pro:tmp torsten$ 
>> 
>> 
>> 
>> 
>> Undefined symbols for architecture x86_64:
>> "Gecode::branch(Gecode::Home, Gecode::IntVarArgs const&, Gecode::IntVarBranch, Gecode::IntValBranch, bool (*)(Gecode::Space const&, Gecode::IntVar, int), void (*)(Gecode::Space const&, Gecode::BrancherHandle const&, unsigned int, Gecode::IntVar, int, int const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&))", referenced from:
>>    SendMoreMoney::SendMoreMoney() in main.o
>> ld: symbol(s) not found for architecture x86_64
>> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>> 
>> 
>> 
>> 
>> 
>> On 2 Nov 2013, at 23:20, Guido Tack <tack at gecode.org>
>> wrote:
>> 
>>> Hi Torsten,
>>> 
>>> you seem to have an older version of Gecode installed in /usr/local (that's what the clang error messages point to).
>>> 
>>> The 35 is the "library version", which is simply incremented with each release and doesn't follow the major.minor.patch scheme.
>>> 
>>> Cheers,
>>> Guido
>>> 
>>> On 3 Nov 2013, at 4:11 am, Torsten Anders <Torsten.Anders at beds.ac.uk> wrote:
>>> 
>>>> On 2 Nov 2013, at 09:13, Torsten Anders <torsten.anders at beds.ac.uk> wrote:
>>>>> Dear Gecoders,
>>>>> 
>>>>> I am trying to run some ready-made Gecode examples on a Mac without success. For example, with the first example from the tutorial (http://www.gecode.org/doc/4.2.0/MPG/send-more-money.cpp) in run into several errors, for example, 
>>>>> 
>>>>> 'INT_VAL_SPLIT_MIN' cannot be used as a function	
>>>>> 'INT_VAR_SIZE_MIN' cannot be used as a function	
>>>>> 
>>>>> As these errors appear for several examples, it appears to me there is something fundamentally wrong. This might well be some installation error on my part. Nevertheless, help is appreciated -- I simply do not know where to start addressing such a problem.  
>>>>> 
>>>>> BTW: I just installed Gecode version 4.2 (binaries Gecode-4.2.0.dmg) on my Mac, after uninstalling some older version. I was surprised to find that /Library/Frameworks/gecode.framework/Versions/ contains a folder named "35" -- I would have expected it to be named "42", for version 4.2, but that could of course be simply a wrong guess on my part.   
>>>>> 
>>>>> Best wishes,
>>>>> Torsten
>>>> 
>>>> 
>>>> I tried to better isolate the problem. Both g++ (gcc) 4.2.1 and clang 5.0 report problems with the example send-more-money.cpp (http://www.gecode.org/doc/4.2.0/MPG/send-more-money.cpp), but the errors differ. The details are below. 
>>>> 
>>>> What am I missing?  
>>>> 
>>>> Best wishes,
>>>> Torsten
>>>> 
>>>> $ g++ -O3 -c send-more-money.cpp
>>>> send-more-money.cpp: In constructor ‘SendMoreMoney::SendMoreMoney()’:
>>>> send-more-money.cpp:55: error: ‘INT_VAR_SIZE_MIN’ cannot be used as a function
>>>> send-more-money.cpp:55: error: ‘INT_VAL_MIN’ cannot be used as a function
>>>> 
>>>> $ g++ --version
>>>> i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
>>>> Copyright (C) 2007 Free Software Foundation, Inc.
>>>> 
>>>> 
>>>> $ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -O3 -c send-more-money.cpp
>>>> In file included from send-more-money.cpp:28:
>>>> In file included from /usr/local/include/gecode/int.hh:50:
>>>> In file included from /usr/local/include/gecode/iter.hh:97:
>>>> /usr/local/include/gecode/iter/ranges-scale.hpp:197:27: error: reference to
>>>>  non-static member function must be called; did you mean to call it with no
>>>>  arguments?
>>>>  static_cast<UnsVal>(max - min + 1);
>>>>                      ^~~
>>>> /usr/local/include/gecode/iter/ranges-scale.hpp:197:33: error: reference to
>>>>  non-static member function must be called; did you mean to call it with no
>>>>  arguments?
>>>>  static_cast<UnsVal>(max - min + 1);
>>>>                            ^~~
>>>> send-more-money.cpp:55:42: error: called object type 'int' is not a function or
>>>>  function pointer
>>>>    branch(*this, l, INT_VAR_SIZE_MIN(), INT_VAL_MIN());
>>>>                     ~~~~~~~~~~~~~~~~^
>>>> 3 errors generated.
>>>> 
>>>> $ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --version
>>>> Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
>>>> 
>>>> 
>>>>> --
>>>>> Dr Torsten Anders
>>>>> Course Leader, Music Technology
>>>>> University of Bedfordshire
>>>>> Park Square, Room A315
>>>>> http://www.torsten-anders.de
>>>> 
>>>> _______________________________________________
>>>> Gecode users mailing list
>>>> users at gecode.org
>>>> https://www.gecode.org/mailman/listinfo/gecode-users
>>> 
>> 
>> 
>> _______________________________________________
>> Gecode users mailing list
>> users at gecode.org
>> https://www.gecode.org/mailman/listinfo/gecode-users
> 




More information about the users mailing list