Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: GCC/Linux and FirstOne(), again.

Author: Robert Hyatt

Date: 11:56:59 10/21/00

Go up one level in this thread


On October 21, 2000 at 12:30:39, Frank Phillips wrote:

>[Bob Hyatt Wrote in response to how to use Eugene's FirstOne() etc assembly code
>in Linux
>
>All you really need to do is compile the .s file separately, which produces
>a .o file.  Then use those procedures in your C program calls.  IE there is a
>FirstOne(), LastOne() function.  You could change the names in the .s file if
>you want, of course.
>
>Then just link that .o file in with your regular C and you should be ready to
>rumble...]
>
>
>Despite having read most HOWTOs I could find, I am still missing something
>simple.
>Linking X86.o to the rest of the program does not work, giving errors that seem
>to
>indicate the function cannot be found even though the function type is defined.
>
>int FirstOne(BITBOARD);
>main()
>{
>FirstOne(1);
>return;
>}
>
>The above compiles with gcc -c -o main.o  main.cpp
>
>The X86.s is compile with asm -o X86.o X86.s
>But  gcc -o prog main.o X86.o  fails with the following type of error
>main.o(.text+0x250): undefined reference to `FirstOne(unsigned long long)'
>
>Very strange because this _appears_ to be what is done in Crafty by the
>Makefile.
>
>Frank


You can't quite call it from c++ programs like that, due to the way the compiler
mangles function names to handle overloading.  If your code was pure C, what
you have should work fine.  If you compile it with c++, the compiler will cause
trouble.  You can declare the function as an extern C function to get around
this...

Not really doing much C/C++ interoperability stuff here, I can't tell you
exactly what to do to fix this, but it ought to be easy..



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.