Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Dec 18, 2017 11:03 am

All times are UTC




Post new topic  Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Build issues on OSX
PostPosted: Tue Feb 14, 2017 11:43 pm 
Offline
Engineer
Engineer

Joined: Tue Feb 14, 2017 10:06 pm
Posts: 5
Hi,

I just cloned trunk from git.openttd.org
Attempted to build it, and was greeted by an error message at what seemed like the final linking step about the symbols iconv and open_iconv.

It seems that config.lib script doesn't detect the need to link with libiconv, so I made a patch for it:
https://gist.github.com/GBuella/ddcadef ... 3d1b510d39
( I didn't try this on other OS's )

Also, the configure script allows a build without even finding the iconv header -- iconv seems to be used in src/os/unix/unix.cpp
Probably this should be fixed as well.

About the patch:
The reason it didn't detect the need for -liconv, is that it didn't even find the header file in the first place. I removed the code looking for the header file with a test that just compiles a file #include-ing iconv.h -- clang installed with xcode knows about the correct sysroot, and finds iconv.h

On system:
MacOS Sierra 10.12.2, with newest Xcode installed, iconv.h happens to be at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/iconv.h

I also tried to register an account in the bugtracker, but I didn't recieve a validation email yet...

Cheers,
Tej


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Wed Feb 15, 2017 5:39 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 28, 2003 6:52 pm
Posts: 1146
I also have a similar problem on Sierra: https://www.tt-forums.net/viewtopic.php?f=33&t=75390


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Thu Feb 16, 2017 11:47 am 
Offline
Engineer
Engineer

Joined: Tue Feb 14, 2017 10:06 pm
Posts: 5
Snail wrote:
I also have a similar problem on Sierra: https://www.tt-forums.net/viewtopic.php?f=33&t=75390


Hi, I looked at that thread, and the patches.
It seems to me, that current trunk already has those patches, and more.
You might be trying to build on older version.
If you didn't yet, pull the current code, and try to build that. Compilation worked for me with no warnings at all, with a single argument given to configure (nolzma, or nolzo2, I don't remember which one).
I only ran into problem with linking, so I had to make it detect the need for -liconv.


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Thu Feb 16, 2017 10:37 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 31, 2007 2:23 pm
Posts: 4438
Location: Standing by the jams
tej wrote:
Compilation worked for me with no warnings at all, with a single argument given to configure (nolzma, or nolzo2, I don't remember which one).


Do you have anything installed from Macports or Brew? I need to upgrade to Sierra, and I am curious what deps might be needed to get OpenTTD to build. ;)

_________________
FIRS Industry Replacement Set (Released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (Finished)
Squid Ate FISH (ships) (Released) | CHIPS Has Improved Players' Stations (Finished)
Iron Horse (trains, released) | Termite (tracks for Iron Horse, released) | Busy Bee (game script, released)

Road Hog (road vehicles, released)


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Sat Feb 18, 2017 6:52 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 28, 2003 6:52 pm
Posts: 1146
Thanks, Tej! It looks like your patch did the trick :D I could compile and run OTTD on my OS X Sierra (10.12.3).

So I downloaded you patch and applied it with the following command:

Code:
patch -p0 < config.lib.patch


after copying your "config.lib.patch" in the directory I put the "trunk" files in.
It looks like "config.lib" was successfully patched, however I got this output:

Code:
patching file config.lib
patch unexpectedly ends in middle of line
Hunk #5 succeeded at 2942 with fuzz 1.


Then I ran "./configure", which still gave me the usual "clang" error message:

Code:
clang: error: unsupported option '-dumpspecs'
clang: error: no input files
clang: error: unsupported option '-dumpspecs'
clang: error: no input files


I then launched the "make" command, and this time it seemed to be successful! Linking went on without errors, however I got a huge number of warnings (attached).
OpenTTD started correctly, and it looks like games work OK (including sound and music). The only thing I had to do, was to move to the latest version of "libpng" (i.e. version 16 : I had to install a new version of grfcodec, because my previous one only worked with libpng14).

Thank you very much for your patch. I guess it could be put in trunk, to help other people compile on Sierra.


Attachments:
File comment: lots of warnings...
openttd_warnings_sierra.txt [957.08 KiB]
Downloaded 16 times
Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Sun Feb 19, 2017 2:14 am 
Offline
Engineer
Engineer

Joined: Tue Feb 14, 2017 10:06 pm
Posts: 5
The "patch unexpectedly ends in middle of line" might indicate, that the newest trunk has already changed after I made this patch.
BTW, my configure command is:

Code:
CC=clang CXX=clang++ ./configure --without-liblzo2


Without specifying the CC and CXX variables, the commands cc and c++ should be used, but...
I'm used to configure scripts originating from GNU being horrible. They usually just try to use gcc instead of cc, cuz why not...
I have some older gcc installed (I think I built it from source sometime ago, and doesn't know the right sysroot), and without specifying CC and CXX, this gcc is used.
I can see the configure script detecting:
Code:
checking build cc... gcc
checking host cc... gcc
checking build c++... gcc
checking host c++... gcc

This is absolutely ridiculos, the host cc is obviously clang, not gcc:
Code:
$ cc -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.3.0

So is the host c++:
Code:
$ c++ -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.3.0

So perhaps something goes wrong in your case as well, some gcc install with which doesn't work well, or it is trying to feed gcc arguments to clang ( I recall by default the gcc command is just an alias to clang, cuz apple also likes messing up things sometimes...)

When I specify CC and CXX:
Code:
$ CC=clang CXX=clang++ ./configure --without-liblzo2
...
checking build cc... clang
checking host cc... clang
checking build c++... clang++
checking host c++... clang++
...


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Sun Feb 19, 2017 2:26 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 28, 2003 6:52 pm
Posts: 1146
tej wrote:
BTW, my configure command is:

Code:
CC=clang CXX=clang++ ./configure --without-liblzo2

You mean I should enter this line in the Terminal? When I do, I get this error message:

Code:
CC=clang: Command not found.

Perhaps I'm using a wrong syntax?

tej wrote:
I can see the configure script detecting:
Code:
checking build cc... gcc
checking host cc... gcc
checking build c++... gcc
checking host c++... gcc


When I configured, I got the following:

Code:
checking build cc... gcc
checking host cc... gcc
checking build c++... g++
checking host c++... g++


tej wrote:
When I specify CC and CXX:
Code:
$ CC=clang CXX=clang++ ./configure --without-liblzo2
...
checking build cc... clang
checking host cc... clang
checking build c++... clang++
checking host c++... clang++
...

I wonder why this syntax doesn't work for me.


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Sun Feb 19, 2017 2:27 am 
Offline
Engineer
Engineer

Joined: Tue Feb 14, 2017 10:06 pm
Posts: 5
I found some clues in the config.lib file, that might explain why you see those warnings and I don't see them:
Code:
if [ `basename $1 | cut -c 1-3` = "icc" ]; then
   # Enable some things only for certain ICC versions
   ....
elif [ `basename $1 | grep 'clang'` ]; then
   # Enable some things only for certain clang versions
   flags="$flags -Wall -W -Wextra"

   # warning: unused parameter '...'
   flags="$flags -Wno-unused-parameter"

   # warning: expression result unused
   flags="$flags -Wno-unused-value"

   # warning: multi-character character constant
   flags="$flags -Wno-multichar"
   
   # more warning stuff,etc....
else
        # Enable some things only for certain GCC versions
        flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef"
   flags="$flags -Wwrite-strings -Wpointer-arith"
   flags="$flags -W -Wno-unused-parameter -Wredundant-decls"
   flags="$flags -Wformat=2 -Wformat-security"


The above code snippet suggest, the misdetection of the compiler can result in different warnings issued.
On your machine is the gcc command an alias to clang, or do you also have a gcc installed from somewhere?
The output of this should probably contain either the string LLVM, or the string GCC:
Code:
$ gcc -v


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Sun Feb 19, 2017 2:41 am 
Offline
Engineer
Engineer

Joined: Tue Feb 14, 2017 10:06 pm
Posts: 5
Quote:
I wonder why this syntax doesn't work for me.


Strange, you might want to try it this way:

Code:
./configure --without-liblzo2  CC=clang CXX=clang++


Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Sun Feb 19, 2017 6:33 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 28, 2003 6:52 pm
Posts: 1146
tej wrote:
The above code snippet suggest, the misdetection of the compiler can result in different warnings issued.
On your machine is the gcc command an alias to clang, or do you also have a gcc installed from somewhere?
The output of this should probably contain either the string LLVM, or the string GCC:
Code:
$ gcc -v

This is what I'm getting:
Code:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


tej wrote:
Quote:
I wonder why this syntax doesn't work for me.


Strange, you might want to try it this way:

Code:
./configure --without-liblzo2  CC=clang CXX=clang++


This works: now configuration gets done without that "clang" error.
When I compile, I'm still getting some warnings, but fewer than before. Attached. (The game seems to work fine)


Attachments:
File comment: warning messages while compiling
openttd_warnings_sierra0.txt [70.17 KiB]
Downloaded 12 times
Top
   
 Post subject: Re: Build issues on OSX
PostPosted: Sun Feb 19, 2017 9:22 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 31, 2007 2:23 pm
Posts: 4438
Location: Standing by the jams
Would one of you update the wiki page about compiling on OS X? :) https://wiki.openttd.org/Compiling_on_M ... osemite.29

I kept it updated for Yosemite and Mavericks, but I don't have Sierra yet, and I don't like to put advice there that I haven't tested for myself. ;)

The OS X port isn't officially maintained, so the strategy is approximately:
1. some of the core devs try to keep the OS X port working without much/any access to OS X machines
2. hope kind strangers provide valid patches
3. keep the wiki up to date with advice about ./configure parameters are needed, and any advice on deps (the wiki is a central location, rather than digging through multiple threads or flyspray tickets)

:)

_________________
FIRS Industry Replacement Set (Released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (Finished)
Squid Ate FISH (ships) (Released) | CHIPS Has Improved Players' Stations (Finished)
Iron Horse (trains, released) | Termite (tracks for Iron Horse, released) | Busy Bee (game script, released)

Road Hog (road vehicles, released)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.