Compiling for Unix

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

Compiling for Unix

Postby Pradu » 08 May 2007, 20:20

Hi all. Let me let you know that I'm not at all experienced with making Unix compiles. For Buzz I've been making "Unix" compiles on Ubuntu. For some reason this compile will not work on someone else's computer which runs under Suse; but when a compile was made on the Suse computer, it ran fine. This is the makefile I use to compile Buzz under Unix:
Code: Select all
#Makefile for Buzz
CC = gcc
LD = gcc
CFLAGS = -g -x c -std=c99 -DNDEBUG -D_POSIX -O3 -w
LDFLAGS = -s -pthread
RM = /bin/rm -f
OBJS = bitinstructions.o board.o book.o consolecolors.o eval.o hash.o log.o magicmoves.o main.o movegen.o moveordering.o mt19937-64.o recog.o search.o thread.o timemanager.o xboard.o
PROG = Buzz

$(PROG): $(OBJS)
   $(LD) $(LDFLAGS) $(OBJS) -o $(PROG)

%.o: %.c
   $(CC) $(CFLAGS) -c $<

clean:
   -rm *.o *~

Does anyone know why an Ubuntu compile won't work on Suse? Also is it possible to make a generic "UNIX" compile that will work on MacOS, Linux, Solaris, ect. as long as they all run on the same processor?
User avatar
Pradu
 
Posts: 343
Joined: 12 Jan 2005, 19:17
Location: Chandler, Arizona, USA

Re: Compiling for Unix

Postby Sven Schüle » 08 May 2007, 22:25

Hi Pradu,

there are many possible reasons including different installed versions of glibc or pthread library, or similar things. Also using -g and -O3 together might produce surprising results. Maybe -O3 optimizes in a machine-specific way?

Posting error messages you get might be helpful.

Which Ubuntu and Suse versions are involved?

On your last question: no, a "generic UNIX compile" which runs on completely different UNIX systems is not possible in general. Executables have different formats on the various UNIX systems, and there may also be many other reasons, e.g. availability of system libraries.

Sven
User avatar
Sven Schüle
 
Posts: 240
Joined: 26 Sep 2004, 20:19
Location: Berlin, Germany

Re: Compiling for Unix

Postby Pradu » 08 May 2007, 23:27

Sven Schüle wrote:Hi Pradu,

there are many possible reasons including different installed versions of glibc or pthread library, or similar things. Also using -g and -O3 together might produce surprising results. Maybe -O3 optimizes in a machine-specific way?

Is there anyway to dynamically link to these standard libraries? Oh and I just want to compile for x86 and x86_64 platforms that support SSE1,2,3 and MMX so I'm assuming that the same platform is used and that O3 won't optimize differently for different OS. Here's a link to Buzz sources with makefile if it helps to find out what goes wrong. I think POSIX thread support should be available on all popular UNIX OSs today but perhaps different versions supported could cause problems I guess?

Posting error messages you get might be helpful.
Memory Access Error for Ubuntu compile on Suse.

Which Ubuntu and Suse versions are involved?

SuSE 10.2
Ubuntu 7.04

On your last question: no, a "generic UNIX compile" which runs on completely different UNIX systems is not possible in general. Executables have different formats on the various UNIX systems, and there may also be many other reasons, e.g. availability of system libraries.

Sven

Ah that blows :\. So I suppose I must make various compiles for the various UNIX OS's. Are you aware if GCC can cross-compile for different OSs? I have so far only found cross-compilation options for different types of processors.
User avatar
Pradu
 
Posts: 343
Joined: 12 Jan 2005, 19:17
Location: Chandler, Arizona, USA

Re: Compiling for Unix

Postby Bryan Hofmann » 09 May 2007, 00:55

Pradu wrote:Hi all. Let me let you know that I'm not at all experienced with making Unix compiles. For Buzz I've been making "Unix" compiles on Ubuntu. For some reason this compile will not work on someone else's computer which runs under Suse; but when a compile was made on the Suse computer, it ran fine. This is the makefile I use to compile Buzz under Unix:
Code: Select all
#Makefile for Buzz
CC = gcc
LD = gcc
CFLAGS = -g -x c -std=c99 -DNDEBUG -D_POSIX -O3 -w
LDFLAGS = -s -pthread
RM = /bin/rm -f
OBJS = bitinstructions.o board.o book.o consolecolors.o eval.o hash.o log.o magicmoves.o main.o movegen.o moveordering.o mt19937-64.o recog.o search.o thread.o timemanager.o xboard.o
PROG = Buzz

$(PROG): $(OBJS)
   $(LD) $(LDFLAGS) $(OBJS) -o $(PROG)

%.o: %.c
   $(CC) $(CFLAGS) -c $<

clean:
   -rm *.o *~

Does anyone know why an Ubuntu compile won't work on Suse? Also is it possible to make a generic "UNIX" compile that will work on MacOS, Linux, Solaris, ect. as long as they all run on the same processor?


You will need to add -static to your CFLAGS so it will statically link the LIBS as different flavors of Linux use different versions of of the LIBs.


Bryan
Bryan Hofmann
 
Posts: 98
Joined: 02 Oct 2004, 20:26
Location: USA


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 21 guests