c++ error

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

c++ error

Post by mhull »

While cross-compiling polyglot, i get preprocessor errors in stdlib.h, math.h which flag the "#if __GLIBC_USE (IEC_60559_BFP_EXT)" statements:

Code: Select all

In file included from /opt/cross/m68k-linux/include/c++/6.3.0/cstdlib:75:0,
                 from adapter.cpp:9:
/opt/cross/m68k-linux/include/stdlib.h:183:17: error: missing binary operator before token "("
 #if __GLIBC_USE (IEC_60559_BFP_EXT)
                 ^
stdlib.h excerpt:

Code: Select all

/* Convert a floating-point number to a string.  */
#if __GLIBC_USE (IEC_60559_BFP_EXT)
extern int strfromd (char *__dest, size_t __size, const char *__format,
                     double __f)
     __THROW __nonnull ((3));

extern int strfromf (char *__dest, size_t __size, const char *__format,
                     float __f)
     __THROW __nonnull ((3));

extern int strfroml (char *__dest, size_t __size, const char *__format,
                     long double __f)
     __THROW __nonnull ((3));
#endif

Has anyone seen this problem before?
Matthew Hull
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: c++ error

Post by stegemma »

Maybe __GLIBC_USE has not been previously defined?
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: c++ error

Post by mhull »

stegemma wrote:Maybe __GLIBC_USE has not been previously defined?
That's sounds about right. Probably a stdlib.h/math.h version issue. I'll see if I can hack around it.
Matthew Hull
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: c++ error

Post by mhull »

CROSS-COMPILING POLYGLOT FOR M68K

stegemma wrote:Maybe __GLIBC_USE has not been previously defined?
I created hack.h to define vacant macro variables:

Code: Select all

#define __GLIBC_USE
#define IEC_60559_BFP_EXT 0
Then included hack.h on the command line:

Code: Select all

m68k-linux-g++ -imacros hack.h -O2 -m68030 -o polyglot *.cpp
...getting past that problem.
Matthew Hull
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: c++ error

Post by mhull »

CROSS-COMPILING POLYGLOT FOR M68K

Next ERROR is:

Code: Select all

In file included from /usr/include/sys/select.h:30:0,
                 from /usr/include/sys/types.h:219,
                 from /opt/cross/m68k-linux/include/stdlib.h:291,
                 from /opt/cross/m68k-linux/include/c++/6.3.0/cstdlib:75,
                 from adapter.cpp:9:
adapter.cpp: In function ‘void adapter_loop()’:
adapter.cpp:198:4: error: impossible constraint in ‘asm’
    FD_ZERO(set);
    ^
In file included from /usr/include/sys/select.h:30:0,
                 from /usr/include/sys/types.h:219,
                 from /opt/cross/m68k-linux/include/stdlib.h:291,
                 from /opt/cross/m68k-linux/include/c++/6.3.0/cstdlib:75,
                 from posix.cpp:7:
posix.cpp: In function ‘bool input_available()’:
posix.cpp:33:4: error: impossible constraint in ‘asm’
    FD_ZERO(set);
Matthew Hull
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: c++ error

Post by syzygy »

Looks like your cross compiler is including default system headers from /usr/include/sys/ where it should be looking in /opt/cross/m68k-linux/include/sys/ or so.
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: c++ error

Post by mhull »

syzygy wrote:Looks like your cross compiler is including default system headers from /usr/include/sys/ where it should be looking in /opt/cross/m68k-linux/include/sys/ or so.
Fixed with:

m68k-linux-g++ -O3 -m68030 -o polyglot -imacros hack.h -I/opt/cross/m68k-linux/include/ *.cpp
Matthew Hull
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: c++ error

Post by mhull »

CROSS-COMPILING POLYGLOT FOR M68K

I used the -I/opt/cross/m68k-linux/include/ on the c++ command line to prevent reference to /usr/include. But I needed the leveldb includes from there so I created a soft link to the /usr/include/leveldb in /opt/cross/m68k-linux/include.

Don't know if that's entirely kosher. At any rate, I'm getting into this error which is a bit beyond my current expertise.

Code: Select all

/tmp/ccxazsPe.o: In function `book_insert(char const*, char const*)':
book_make.cpp:(.text+0xc22): undefined reference to `leveldb::Options::Options()'
book_make.cpp&#58;(.text+0xc72&#41;&#58; undefined reference to `leveldb&#58;&#58;DB&#58;&#58;Open&#40;leveldb&#58;&#58;Options const&, std&#58;&#58;__cxx11&#58;&#58;basic_string<char, std&#58;&#58;char_traits<char>, std&#58;&#58;allocator<char> > const&, leveldb&#58;&#58;DB**)'
collect2&#58; error&#58; ld returned 1 exit status
Matthew Hull
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: c++ error

Post by kbhearn »

that looks like a missing library - probably need a -lleveldb

edit: and probably need to cross-compile the library as well
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: c++ error

Post by hgm »

Which version of Polyglot are you compiling? The one I am used to doesn't contain the symbol 'leveldb' anywhwere in its sources. (And it doesn't have any .cpp files either, btw.)