compilation trouble with 0.87 linux/ubuntu 10.04

compilation trouble with 0.87 linux/ubuntu 10.04

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
cherub
Posts: 12
Joined: 08 Mar 2012, 18:52

compilation trouble with 0.87 linux/ubuntu 10.04

Post by cherub »

Hi,

(dear admin: please move this to right place, if this isn't.)

This a spring-compilation-newbie question about a specific problem during compilation/linking with v0.87 on Ubuntu 10.04.

I just wanted to get my feet a little bit more wet and tried to compile spring myself. So I downloaded the "last stable release" from git via

Code: Select all

git clone -b master git://github.com/spring/spring
Since I did this today, the VERSION string inside reads "0.87". After some additions of dev-libraries I managed to get cmake to run without errors.
So after creating a build directory and running

Code: Select all

cmake $path_to_cmakelists.txt
make
I got the following error:

Code: Select all

 CMakeFiles/engine-default.dir/__/__/System/Object.cpp.o: In function `Threading::AtomicCounterInt64::operator++()':
~/spring/rts/System/Platform/Threading.h:111: undefined reference to `__sync_fetch_and_add_8'
~/spring/rts/System/Platform/Threading.h:111: undefined reference to `__sync_fetch_and_add_8'
(note ~/spring is the directory of the git checkout)

I checked the file Threading.h and was slightly surprised that this function doesn't exist; the name is different. The line reads

Code: Select all

111          return __sync_fetch_and_add(&num, boost::int64_t(1)); 
(see e.g. here for other reference).

After some research (google, forum, dev pages) without fruition I thought I might ask here. What's going wrong and how can I fix it?

The system is more or less vanilla Ubuntu 10.04.4 (gcc 4.4.3-4ubuntu5, boost1.40, etc.).

Anybody an idea?
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by abma »

http://stackoverflow.com/questions/7994 ... -and-add-4

this suggests to use a newer gcc... :-/

i'm not sure, koshi (current ubuntu package maintainer) has maybe a better idea.


Note: its 87.0 not 0.87.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by jK »

the stackoverflow suggests it is related to this:
https://github.com/spring/spring/commit ... d2f00b6983

(there is a bug in the cmake files of 87.0 causing not to pass "-march=i686")
Last edited by jK on 09 Mar 2012, 09:54, edited 1 time in total.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by abma »

damn, i wanted to commit that only into develop, i'm a bit confused why its in release/master... :-/
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by hoijui »

hotfix release?
(see RC13 here)
or would that cause sync incompatibility?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by jK »

abma wrote:damn, i wanted to commit that only into develop, i'm a bit confused why its in release/master... :-/
you did but that was after 86.0, with 87.0 it went into release again
hoijui wrote:hotfix release?
(see RC13 here)
or would that cause sync incompatibility?
Better hope not. A hotfix might be needed if multiple ppl are affected (the guy here, will later no matter what use the official debian/ubuntu binary)
cherub
Posts: 12
Joined: 08 Mar 2012, 18:52

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by cherub »

Hi,

sorry for the wrong zero positioning (0.87 -> 87.0).

It seems this:
jK wrote:[...](there is a bug in the cmake files of 87.0, causing to not pass "-march=i686")
is actually "seen" by cmake. I noticed it during invocation:

Code: Select all

 -- Checking to see if CXX compiler accepts flag -march i686
-- Checking to see if CXX compiler accepts flag -march i686 - no
INFO-march i686 flag not accepted
But it's only INFO level, not ERROR. On this machine I can't check whether the flag is passed or not, since its gcc can't handle it (for the reason given by abma).

Currently I'm trying to get another gcc version installed on the system (which fails for some other reason); when (or if...) that's done, I can try to compile spring again.
jK wrote:[...](the guy here, will later no matter what use the official debian/ubuntu binary)
You're probably right, but still I'd like to be able to compile the thing myself and get my hands a little dirtier. I'd like to take a closer look at some things (e.g. like profiling, understand how the lua binding works)

cheers, cherub
cherub
Posts: 12
Joined: 08 Mar 2012, 18:52

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by cherub »

Hi,

reading, thinking and understanding helps sometimes.

First I tried to build 87.0 with a newer gcc version (4.6.3), simply to see if the flag works. It didn't, because the wrong syntax in the cmake file, as jk pointed out. I applied the change -- tada, it worked.
Then I tried to build spring with the Ubuntu built-in compiler (4.4.3), which also worked; the cmake error disappeared, compilation and linking went fine. I could run spring.

So, everything's green now. There's only one thing I needed to tweak:
I tried to run spring from the build directory (I didn't see right away how to change the install directory, so I refrained from `make instal`). It didn't work, since it still needed manual linking of the freefont (FreeSansBold.otf). This might be no problem, if `make install` is done; but I didn't see any (soft-)link command.

Thanks for the help.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by hoijui »

Code: Select all

cmake \
	-DSPRING_DATADIR="${INSTALL_DIR}" \
	-DCMAKE_INSTALL_PREFIX="" \
	-DBINDIR=. -DLIBDIR=. -DMANDIR=. -DDATADIR=.

make

make install DESTDIR=${INSTALL_DIR}
set INSTALL_DIR to where you want to install and.. yeah about liek that. i extracted these lines out of my build scripts.. not sure if this is really allyou need, but i think so. add your own special stuff of course.
User avatar
kolben
Posts: 22
Joined: 09 Sep 2010, 09:01

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by kolben »

ubuntu lts 10.04 here, had same problem:
[...]/Threading.h:111: undefined reference to `__sync_fetch_and_add_8'

have i done that right:

first i entered "cmake ."
then i edited "CMakeCache.txt"
inserted "i686" on end of line:
MARCH_FLAG:STRING=

then run "make" - and it worked.

after that i wondered "hey, i got an athlon. why optimize for i686?"
so i changed to something else, i tried "k8" for an athlon
all architecture options are found here:
http://gcc.gnu.org/onlinedocs/gcc/i386- ... tions.html



worked too - but i haven't noticed any differences.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: compilation trouble with 0.87 linux/ubuntu 10.04

Post by jK »

Some sse-optimizations are a damn lot faster when optimizing for with the correct athlon flag (mostly you want `amdfam10`), but it's nothing you will notice ingame (even when the code runs 10-100x faster, the code is just <1% of the total).
Post Reply

Return to “Engine”