Compile Problem

Questions, problems and discussion about compiling FreeOrion.

Moderator: Oberlus

Message
Author
User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Compile Problem

#16 Post by MatGB »

Doofus here decided his clone was ina stupid place, so decided to put it somewhere else. And rather than cut/paste, I recloned it. d'oh! Not the best time of day to be doing that.

Quad core machine, but only 8gig RAM, that's near the top of the things I want to upgrade when I've got more money, so I reread things and went up to j3 instead of j2. This, so far, is working, but we'll see, thanks for the help guys.
cd git
mkdir freeorion.build
cd freeorion.build
ln -s ../freeorion/default .
cmake ../freeorion
make -j3
Re the Wiki, definitely need to get it updated, do we remove the Ogre/Bullet references entirely, or say that it's not needed as per release 0.4.5 or anything taken from the Git repo? Also, one of the listed dependencies I notice is Subversion, I assume that's no longer needed?
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

AndrewW
Juggernaut
Posts: 791
Joined: Mon Feb 04, 2013 10:15 pm

Re: Compile Problem

#17 Post by AndrewW »

MatGB wrote:Quad core machine, but only 8gig RAM, that's near the top of the things I want to upgrade when I've got more money, so I reread things and went up to j3 instead of j2. This, so far, is working, but we'll see, thanks for the help guys.
Most stuff doesn't need more then 8gb. You can always run top (command line) and see how much memory is available and how much the various programs are taking.
MatGB wrote:Re the Wiki, definitely need to get it updated, do we remove the Ogre/Bullet references entirely, or say that it's not needed as per release 0.4.5 or anything taken from the Git repo? Also, one of the listed dependencies I notice is Subversion, I assume that's no longer needed?
Correct, Subversion is no longer needed.

Yes that needs updating, maybe a separate section for older versions?

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Compile Problem

#18 Post by adrian_broher »

Having the compile instructions in the wiki is rather stupid, imo. A section within the README.md or a separate INSTALL.md would be always synchronous to the actual checked out code.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Compile Problem

#19 Post by Dilvish »

AndrewW wrote:Yes that needs updating, maybe a separate section for older versions?
I've updated it some earlier today. I saw no point in keeping anything about SVN or older versions of the code.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

AndrewW
Juggernaut
Posts: 791
Joined: Mon Feb 04, 2013 10:15 pm

Re: Compile Problem

#20 Post by AndrewW »

Removed the old build and did a new one (testing things), didn't work within the directory structure:

Code: Select all

[100%] Building CXX object client/human/CMakeFiles/freeorion.dir/__/__/UI/TextBrowseWnd.cpp.o
Linking CXX executable ../../freeorion
CMakeFiles/freeorion.dir/chmain.cpp.o: In function `mainConfigOptionsSetup(std::vector<std::string, std::allocator<std::string> > const&)':
chmain.cpp:(.text+0xe4d): undefined reference to `FreeOrionVersionString()'
chmain.cpp:(.text+0x1781): undefined reference to `FreeOrionVersionString()'
CMakeFiles/freeorion.dir/chmain.cpp.o: In function `mainSetupAndRun()':
chmain.cpp:(.text+0x376f): undefined reference to `FreeOrionVersionString()'
CMakeFiles/freeorion.dir/__/__/UI/IntroScreen.cpp.o: In function `IntroScreen::IntroScreen()':
IntroScreen.cpp:(.text+0x359f): undefined reference to `FreeOrionVersionString()'
collect2: error: ld returned 1 exit status
client/human/CMakeFiles/freeorion.dir/build.make:1729: recipe for target 'freeorion' failed
make[2]: *** [freeorion] Error 1
CMakeFiles/Makefile2:413: recipe for target 'client/human/CMakeFiles/freeorion.dir/all' failed
make[1]: *** [client/human/CMakeFiles/freeorion.dir/all] Error 2
Makefile:137: recipe for target 'all' failed
make: *** [all] Error 2
Worked fine building outside the directory structure though...

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Compile Problem

#21 Post by Dilvish »

AndrewW wrote:Removed the old build and did a new one (testing things), didn't work within the directory structure:
Just to be clear, by "within the directory structure" you mean not using a special build directory at all, correct? Because I thought you had indicated above that using one like freeorion/build/ worked for you.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

AndrewW
Juggernaut
Posts: 791
Joined: Mon Feb 04, 2013 10:15 pm

Re: Compile Problem

#22 Post by AndrewW »

Dilvish wrote:Just to be clear, by "within the directory structure" you mean not using a special build directory at all, correct? Because I thought you had indicated above that using one like freeorion/build/ worked for you.
Meaning using a directory under the freeorion directory. It did work, but did a completely new build, removing the old stuff first and it didn't. Putting a new build directory outside the freeorion directory worked this time.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Compile Problem

#23 Post by Dilvish »

AndrewW wrote:Putting a new build directory outside the freeorion directory worked this time.
Weird.. isn't that what you had tried *first* and it didn't work, before I suggested trying a build folder within the freeorion folder? Did you do anything different this time than that first time?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

AndrewW
Juggernaut
Posts: 791
Joined: Mon Feb 04, 2013 10:15 pm

Re: Compile Problem

#24 Post by AndrewW »

Dilvish wrote:Weird.. isn't that what you had tried *first* and it didn't work, before I suggested trying a build folder within the freeorion folder? Did you do anything different this time than that first time?
Correct that is the way I tried it initially. Not that I'm aware of.

I have no idea why this time it works this way around and the other time it didn't, but worked the other way around. Wanted to mention my results, not trying to explain why as I don't have an explanation. Note, didn't need to create any links this time either.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Compile Problem

#25 Post by MatGB »

For what it's worth, the first time I thought it had compiled properly I couldn't find anything to get the game going, Cmake hadn't given me any error messages and it all looked good. I remade it, no change, then I redid Cmake then remade it, and this time I got executables that were clearly executables in teh build folder (I know what to look for next time).

It appears sometimes simply doing it again makes a difference, but I've, obviously, zero clue why doing it again makes a difference.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Compile Problem

#26 Post by adrian_broher »

MatGB wrote:For what it's worth, the first time I thought it had compiled properly I couldn't find anything to get the game going.
Please be more specific. Also the configure/compile output always is a good indicator on what is happening or going wrong, so please post it.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Compile Problem

#27 Post by MatGB »

Specifically, there were no executables for freeorion, freeoriond or freeorionca. But, this was the first time I'd *ever* tried to compile something on Linux and I had no idea what Linux executables even looked like or where they were meant to be. It was only after I'd messed around, including using sudo apt get to install the current Release version from the Ubuntu repo (which wasn't what I thought I was doing) that I had a vague idea what to look for and then reran Cmake then Make, this time, despite doing everything identically, it worked fine.
Also the configure/compile output always is a good indicator on what is happening or going wrong, so please post it.
Given I've rerun the commands subsequently, will the old output still exist? If so, where do I look?
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Compile Problem

#28 Post by adrian_broher »

MatGB wrote:Specifically, there were no executables for freeorion, freeoriond or freeorionca. But, this was the first time I'd *ever* tried to compile something on Linux and I had no idea what Linux executables even looked like or where they were meant to be.
Well, okay. I will give you a little breakdown of the steps then.

Starting from the commands you used:

change directory to the directory called 'git'

Code: Select all

cd git
make a directory called 'freeorion.build' inside the git directory.

Code: Select all

mkdir freeorion.build
Again, change directory to the new created directory 'freeorion.build'

Code: Select all

cd freeorion.build
Create a (soft) symbolic link to the default directory of the freeorion source inside the freeorion.build directory.
A symbolic link is a transparent way to point a file/directory to another file/directory.
This is because freeorion expects all the data files at a certain place.
Instead you could copy the default directory into the freeorion.build directory, but then changes inside the default directory originated in the source wouldn't reflect inside the build directory.

Code: Select all

ln -s ../freeorion/default .
Configure your build from the sources located inside ../freeorion.
This is a more complex step, as it does serveral steps
1. It creates the build system, which is by default 'make', you can choose other build systems and, for example create a build system based on Xcode (only on MacOSX) or Visual Studio (only on Windows).
2. It checks if all prerequisites are satisfied. This means that all libraries and programs used are installed.
3. It generates platform specific code files from template files. For example it creates the Version.cpp file by asking GIT what the version of currently checked out source code is.
As the name says, this would be the place to configure you build, e.g. where to install the result, what library versions to use and so on. Most of the time no configuration is needed for FO.

Code: Select all

cmake ../freeorion
This is where you actually compile the code into the FO executables and libraries. The -j3 parameter says that the make build system should try to run 3 jobs in parallel. As a rule of thumb you run as many jobs as you have processors/cores (or less if you need a processor/core for other purposes).

Code: Select all

make -j3
After a successful compile the executables 'freeorion', 'freeorionca' and 'freeoriond' are placed within the 'freeorion.build' directory. On unix-ish systems there is no file extension indicating that an executable is executable, but rather a file permission that indicates this. Also important to note is that you haven't installed the application yet (which doesn't prevent you from running it, though, but more later).

Here is a listing of my freeorion build directory:

Code: Select all

$ ls -l 
insgesamt 57144
drwxrwxr-x.  4 adrian adrian     4096  8. Mai 22:49 client
-rw-rw-r--.  1 adrian adrian    38490  7. Jun 22:54 CMakeCache.txt
drwxrwxr-x.  7 adrian adrian     4096  8. Jun 15:10 CMakeFiles
-rw-rw-r--.  1 adrian adrian     5821  4. Jun 17:52 cmake_install.cmake
-rw-r--r--.  1 adrian adrian     5952  7. Jun 22:54 CPackConfig.cmake
-rw-r--r--.  1 adrian adrian     5487  7. Jun 22:54 CPackSourceConfig.cmake
lrwxrwxrwx.  1 adrian adrian       25 11. Mai 20:26 default -> ../freeorion.git/default/
-rwxrwxr-x.  1 adrian adrian  6359107  8. Jun 15:10 freeorion
-rwxrwxr-x.  1 adrian adrian  3196517  8. Jun 15:10 freeorionca
-rwxrwxr-x.  1 adrian adrian  3666331  8. Jun 15:10 freeoriond
drwxrwxr-x.  5 adrian adrian     4096  7. Jun 22:54 GG
-rwxrwxr-x.  1 adrian adrian 10461276  8. Jun 15:10 libfreeorioncommon.so
-rw-rw-r--.  1 adrian adrian 23637040  5. Jun 15:07 libfreeorionparse.a
-rwxrwxr-x.  1 adrian adrian  6473240  8. Jun 15:09 libfreeorionparse.so
-rwxrwxr-x.  1 adrian adrian   238069  4. Jun 17:53 libGiGiSDL.so
-rwxrwxr-x.  1 adrian adrian  4299976  4. Jun 17:53 libGiGi.so
-rw-rw-r--.  1 adrian adrian    65960  7. Jun 22:54 Makefile
drwxrwxr-x.  3 adrian adrian     4096  7. Jun 22:54 parse
drwxrwxr-x.  3 adrian adrian     4096  7. Jun 22:54 server
The '-l' parameter tells ls that it should output the listing in tabular form. The first column, indicates the permissions of a file. Permissions are a whole chapter on it's own, so I skip that for now. The important part is the 'x', which means that the file is executable.

It was only after I'd messed around, including using sudo apt get to install the current Release version from the Ubuntu repo (which wasn't what I thought I was doing) that I had a vague idea what to look for and then reran Cmake then Make, this time, despite doing everything identically, it worked fine.
Now here comes the part that probably caused problems for you. When executing a command on the command line like 'ls' the shell searches certain directories for this executable and execute it if found. The directories search are controlled by the 'PATH' environment variable. However the current directory '.' is by default not in this search path (and should not be for security purposes).

This means even if I'm in the freeorion build directory and there is a freeorion executable and I run

Code: Select all

freeorion
the shell will respond with something along the lines:

Code: Select all

freeorion: Command not found
or, if you have installed freeorion on the system it would run this installed version, but not the version you compiled.

But you can tell the shell to explicit run the executable inside the directory by typing in:

Code: Select all

./freeorion
Which literally translates into "execute the file 'freeorion' inside the current directory (. is the shorthand for that)".
Given I've rerun the commands subsequently, will the old output still exist? If so, where do I look?
I was assuming that had save it somewhere. No, by default the only output by make and cmake is written to the console. This output is destroyed whenever you close the console.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Compile Problem

#29 Post by MatGB »

That is incredibly helpful, thank you. Some of it I already (sort of) knew, or had guessed, but seeing all the abbreviations with examples makes the point a lot clearer.
I was assuming that had save it somewhere.
Someday, I will get into the habit of doing this, someday. I didn't even manage to save a copy of the game I was playing late last night where I discovered an edge case scripting bug that should be an easy fix but'll need testing, ah well.

Still, I now have my executables, know what I'm doing (sort of) and am learning things. This is good.

Some of the above probably ought to be in the wiki, when I'm feeling less fragile I'll see what I can do, need to remember my password for it first though ;-)
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Cpeosphoros
Space Kraken
Posts: 124
Joined: Sat Jan 30, 2016 11:29 am

Re: Compile Problem

#30 Post by Cpeosphoros »

Dilvish wrote:

Code: Select all

sudo apt-get install libglew-dev
should do it; I didn't do anything fancy for my install of it.
Necroing this. That line of code should be in the Wiki page, together with the other "apt-get install" statements. I was trying to compile on a Linux Mint box and had a hard time with a "Couldn't find GLEW" message.

So, what I did (retroactively adding the missing apt-get install), and went very smooth, was:

Code: Select all

sudo apt-get install build-essential git pkg-config libltdl-dev cmake libboost-all-dev
sudo apt-get install python2.7-dev libfreetype6-dev libsdl2-dev libvorbis-dev libtiff4-dev libopenal-dev
sudo apt-get install libglew-dev

cd git
git clone git://github.com/freeorion/freeorion
cd freeorion
mkdir freeorion.build
cd freeorion.build
ln -s ../default .
cmake ..
make -j9
./freeorion
I had to "mine" that sequence of commands from various places in the wiki and this forum. I think it should be all together in an easily accessible place in the wiki.
Last edited by Cpeosphoros on Wed Nov 15, 2017 12:12 pm, edited 1 time in total.
All contributions are released under GPL or LGPL v2 or later, or under appropriate Creative Commons licence, consistent with project guidelines.

Post Reply