# libtorrent doesn't compile since Ports update to 0.13.2



## anders (Jul 15, 2012)

Since libtorrent was updated from 0.12.9 to 0.13.2 in the Ports tree a while back, I've been unable to compile it. In the output, I can spot the warning 
	
	



```
configure: WARNING: unrecognized options: --with-openssl
```
 and several warnings similar to 
	
	



```
file_list.cc:405:3: warning: passing NULL to non-pointer argument 4 of 'void torrent::log_group::internal_print(const torrent::HashString*, const char*, const void*, size_t, const char*, ...)' [-Wconversion-null]
```
 (although the file name and line number varies). Later, it dies with the words 
	
	



```
libtool: compile:  g++46 -DHAVE_CONFIG_H -I. -I../../.. -I. -I./.. -I./../.. -I../../.. -O2 -pipe -march=native -mmmx -msse -msse2 -msse3 -mssse3 -fno-strict-aliasing -DNDEBUG -fvisibility=hidden -D_THREAD_SAFE -pthread -I/usr/include -I/usr/local/include/sigc++-2.0 -I/usr/local/lib/sigc++-2.0/include -MT option_strings.lo -MD -MP -MF .deps/option_strings.Tpo -c option_strings.cc  -fPIC -DPIC -o .libs/option_strings.o
In file included from ./../../torrent/connection_manager.h:45:0,
                 from option_strings.cc:43:
/usr/include/netinet/in_systm.h:49:9: error: 'u_int16_t' does not name a type
/usr/include/netinet/in_systm.h:50:9: error: 'u_int32_t' does not name a type
/usr/include/netinet/in_systm.h:52:9: error: 'u_int32_t' does not name a type
In file included from ./../../torrent/connection_manager.h:46:0,
                 from option_strings.cc:43:
/usr/include/netinet/ip.h:51:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:58:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:59:2: error: 'u_short' does not name a type
/usr/include/netinet/ip.h:60:2: error: 'u_short' does not name a type
/usr/include/netinet/ip.h:61:2: error: 'u_short' does not name a type
/usr/include/netinet/ip.h:66:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:67:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:68:2: error: 'u_short' does not name a type
/usr/include/netinet/ip.h:141:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:142:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:143:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:145:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:192:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:193:2: error: 'u_char' does not name a type
/usr/include/netinet/ip.h:194:2: error: 'u_short' does not name a type
*** Error code 1

Stop in /usr/ports/net-p2p/libtorrent/work/libtorrent-0.13.2/src/torrent/utils.
*** Error code 1

Stop in /usr/ports/net-p2p/libtorrent/work/libtorrent-0.13.2/src/torrent.
*** Error code 1

Stop in /usr/ports/net-p2p/libtorrent/work/libtorrent-0.13.2/src.
*** Error code 1

Stop in /usr/ports/net-p2p/libtorrent/work/libtorrent-0.13.2.
*** Error code 1

Stop in /usr/ports/net-p2p/libtorrent/work/libtorrent-0.13.2.
*** Error code 1

Stop in /usr/ports/net-p2p/libtorrent.
*** Error code 1

Stop in /usr/ports/net-p2p/libtorrent.

===>>> make failed for net-p2p/libtorrent
===>>> Aborting update

===>>> Update for net-p2p/libtorrent failed
===>>> Aborting update

Terminated

===>>> You can restart from the point of failure with this command line:
       portmaster <flags> devel/automake net-p2p/rtorrent
```

I have been running FreeBSD since December 2011, and my version is 9.0-RELEASE. I've replaced the default compiler with gcc46, and introduced the user-defined options "-O2 -pipe -march=native -mmmx -msse -msse2 -msse3 -mssse3 -fno-strict-aliasing". In other words, I'm a newbie but had started to gain some confidence since everything seemed to work like a charm up until now.

Since this is my home server, located more than 7000 km from where I work, my connection is crappy and I always update using a screen session to be able to reconnect/resume after losing connection:
`$ screen sudo portsnap fetch update # I've also tried 'fetch extract'`
`$ screen sudo portmaster -a`

I've searched a lot but never found anyone else with the same problem. Could someone please give me a hint on where to look for a solution? Have I messed up things with the Ports, my compiler version, compiler settings, the tools I use to update, the fact that I execute everything through screen, or something else? Thanks!


----------



## SirDice (Jul 16, 2012)

anders said:
			
		

> I've replaced the default compiler with gcc46, and introduced the user-defined options "-O2 -pipe -march=native -mmmx -msse -msse2 -msse3 -mssse3 -fno-strict-aliasing".


Remove those and try again.


----------



## anders (Jul 18, 2012)

SirDice said:
			
		

> Remove those and try again.



Thanks for you advice! Wasn't sure whether you meant the new compilers or the flags. I can conclude that libtorrent can be compiled with those flags but not with gcc46 (by the way, I noticed that only the flags "-march=native -mmmx -msse -msse2 -msse3 -mssse3" were added by me, the others were added elsewhere but identified as user-defined).

I already had an exception for xmlrpc-c-devel in /etc/make.conf. Now I added an additional if-statement, and the entire thing looks like this now:

```
.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc46)
.if empty(.CURDIR:M/usr/ports/net/xmlrpc-c-devel*)
.if empty(.CURDIR:M/usr/ports/net-p2p/libtorrent*) && empty(.CURDIR:M/usr/ports/net-p2p/rtorrent*)
CC=gcc46
CXX=g++46
CPP=cpp46
CFLAGS+=-march=native -mmmx -msse -msse2 -msse3 -mssse3
.endif
.endif
.endif
```

Now, all three ports xmlrpc-c-devel, libtorrent and rtorrent are compiled with the default compiler and settings. For the first two, there are no longer any errors (although the first warning I mentioned is still present). However, rtorrent fails:

```
checking for libtorrent... yes
checking for XMLRPC-C... failed
configure: error: Could not compile XMLRPC-C test.
===>  Script "configure" failed unexpectedly.
Please report the problem to flz@FreeBSD.org [maintainer] and attach the
"/usr/ports/net-p2p/rtorrent/work/rtorrent-0.9.2/config.log" including the
output of the failure of your make command. Also, it might be a good idea to
provide an overview of all packages installed on your system (e.g. an `ls
/var/db/pkg`).
*** Error code 1

Stop in /usr/ports/net-p2p/rtorrent.
*** Error code 1

Stop in /usr/ports/net-p2p/rtorrent.

===>>> make failed for net-p2p/rtorrent
===>>> Aborting update

===>>> Update for net-p2p/rtorrent failed
===>>> Aborting update
```

The log file that was mentioned contains

```
configure:17896: checking for XMLRPC-C
configure:17930: c++ -o conftest -O2 -pipe -fno-strict-aliasing -DNDEBUG -D_THREAD_SAFE   -I/usr/local/include/sigc++-2.0 -I/usr/local/lib/sigc++-2.0/include   -I/usr/local/include   -I/usr/local/include   -I/usr/local/include    -pthread conftest.cpp  -lncursesw  -L/usr/local/lib -lsigc-2.0   -L/usr/local/lib -lcurl   -L/usr/local/lib -ltorrent   -L/usr/local/lib  -Wl,-rpath,/usr/local/lib  -lxmlrpc_server -lxmlrpc  -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_util  >&5
/usr/local/lib/libsigc-2.0.so: undefined reference to `std::__detail::_List_node_base::_M_unhook()@GLIBCXX_3.4.15'
/usr/local/lib/libsigc-2.0.so: undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)@GLIBCXX_3.4.15'
configure:17930: $? = 1
```

I've tried recompiling xmlrpc-c-devel, but it's still not working. I guess it's a problem with the different versions of certain libraries, right? I've earlier adjusted libmap.conf, but libsigc-2.0.so is not listed there and it has worked fine up until now.


----------



## SirDice (Jul 18, 2012)

Don't muck about with CFLAGS unless you know what you are doing. Compiler optimization is already done where it's possible. Mucking about with the flags usually causes more harm than good.


----------



## anders (Jul 19, 2012)

SirDice said:
			
		

> Don't muck about with CFLAGS unless you know what you are doing. Compiler optimization is already done where it's possible. Mucking about with the flags usually causes more harm than good.



Well, I was an assembly language programmer for years, and my intention was to affect the instruction set only. I carefully studied all documentation I could find before making these alterations, and on my architecture, -march=native sets architecture and tuning to atom, and flips on the -mcx16, -mmovbe and -msahf flags, which are just additional CPU instructions supported on my machine. The same thing goes for -mmmx, -msse, -msse2, -msse3 and -mssse3. They're just additional CPU instructions, and are not supposed to affect anything else.

Still, you might be correct that I don't have a clue what these flags are really doing, and I took your advice, commented out my changes to CFLAGS and recompiled all my ports, with rtorrent last. I was out of luck, however, and the same error message remains.


----------



## anders (Jul 19, 2012)

I managed to solve this by removing every trace of gcc46 from my Ports configuration. In other words, I commented out every line that I had inserted into /etc/make.conf, and the entire file /etc/libmap.conf. These were the places that the FreeBSD documentation had told me to edit in the section about using a newer version of GCC.

My conclusion is that my CFLAGS had nothing to do with it, and that something conflicted with the version of GCC that I had installed. Still, I'd like to figure out what. I find it strange that rtorrent failed to compile even though I made an exception for it, and tried to compile it with the default GCC version.


----------

