<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.finkproject.org/index.php?action=history&amp;feed=atom&amp;title=Fink%3APorting_Notes</id>
	<title>Fink:Porting Notes - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.finkproject.org/index.php?action=history&amp;feed=atom&amp;title=Fink%3APorting_Notes"/>
	<link rel="alternate" type="text/html" href="https://wiki.finkproject.org/index.php?title=Fink:Porting_Notes&amp;action=history"/>
	<updated>2026-04-30T01:35:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.13</generator>
	<entry>
		<id>https://wiki.finkproject.org/index.php?title=Fink:Porting_Notes&amp;diff=51&amp;oldid=prev</id>
		<title>Dmacks: /* Common Libtool Linking Problems */</title>
		<link rel="alternate" type="text/html" href="https://wiki.finkproject.org/index.php?title=Fink:Porting_Notes&amp;diff=51&amp;oldid=prev"/>
		<updated>2007-01-26T23:18:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Common Libtool Linking Problems&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Fink_Header}}&lt;br /&gt;
&lt;br /&gt;
This page explains some of the common 'gotchas' encountered when porting packages to OS X. It is not inclusive, and is only meant to be a list of the more commonly encountered changes that need to be done to packages.&lt;br /&gt;
&lt;br /&gt;
===Compiler Flags===&lt;br /&gt;
&lt;br /&gt;
The following flags are not valid on Darwin:&lt;br /&gt;
&lt;br /&gt;
* '-undefined suppress'&lt;br /&gt;
&lt;br /&gt;
===Nested Functions in GCC 4.0.1 (XCode 2.2)===&lt;br /&gt;
&lt;br /&gt;
See [[Fink:Package_issues#Nested_functions_issue_from_XCode_2.2_.28gcc-4.0.1.29]]&lt;br /&gt;
and also [http://developer.apple.com/technotes/tn2006/tn2161.html Apple's Technical Note on Nested Functions].&lt;br /&gt;
&lt;br /&gt;
===The &amp;quot;head&amp;quot; command===&lt;br /&gt;
&lt;br /&gt;
The program &amp;quot;&amp;lt;code&amp;gt;head&amp;lt;/code&amp;gt;&amp;quot; from [http://pdb.finkproject.org/pdb/package.php/textutils &amp;lt;code&amp;gt;Textutils&amp;lt;/code&amp;gt;] builds differently in 10.3 and 10.4, even though they are the same upstream version.  The 10.4 build seems to be stricter in failing with the format &amp;quot;&amp;lt;code&amp;gt;head -1&amp;lt;/code&amp;gt;&amp;quot;.  If your code uses head, make sure you use the &amp;quot;&amp;lt;code&amp;gt;head -n 1&amp;lt;/code&amp;gt;&amp;quot; format, which is more explicit.&lt;br /&gt;
&lt;br /&gt;
===The _environ symbol===&lt;br /&gt;
&lt;br /&gt;
The missing &amp;lt;code&amp;gt;_environ&amp;lt;/code&amp;gt; symbol is a common problem when porting to OS&lt;br /&gt;
X. Here's the standard patch used in several fink packages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;+#ifdef __APPLE__&lt;br /&gt;
+#include &amp;lt;crt_externs.h&amp;gt;&lt;br /&gt;
+#define environ (*_NSGetEnviron())&lt;br /&gt;
+#else&lt;br /&gt;
 extern char **environ;&lt;br /&gt;
+#endif&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A more portable solution is to have &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; check for the presence of that header and symbol directly--&amp;quot;test for the actual feature instead of attempting to divine the features from the platform&amp;quot;. Add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;AC_CHECK_HEADERS(crt_externs.h)&lt;br /&gt;
AC_CHECK_FUNCS(_NSGetEnviron)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to &amp;lt;code&amp;gt;configure.ac&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;configure.in&amp;lt;/code&amp;gt; and use this patch for the source file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;+#ifdef HAVE_CRT_EXTERNS_H&lt;br /&gt;
+#include &amp;lt;crt_externs.h&amp;gt;&lt;br /&gt;
+#endif&lt;br /&gt;
+#ifdef HAVE__NSGETENVIRON&lt;br /&gt;
+#define environ (*_NSGetEnviron())&lt;br /&gt;
+#else&lt;br /&gt;
 extern char **environ;&lt;br /&gt;
+#endif&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to implement the results of the AC_CHECK_* tests.&lt;br /&gt;
&lt;br /&gt;
An alternative portable solution is to [http://bugzilla.gnome.org/show_bug.cgi?id=124277 rewrite the code] to use &amp;lt;code&amp;gt;g_listenv()&amp;lt;/code&amp;gt; (requires glib &amp;gt;= 2.8.0).&lt;br /&gt;
&lt;br /&gt;
===Common Libtool Linking Problems===&lt;br /&gt;
&lt;br /&gt;
There are several commonly-encountered library linking problems that have relatively simple solutions.&lt;br /&gt;
&lt;br /&gt;
# On older libtool, relinking fails. This patch solves it:&amp;lt;pre&amp;gt;perl -pi -e 's/need_relink=yes/need_relink=no/g' ltmain.sh&amp;lt;/pre&amp;gt;&lt;br /&gt;
# An installed copy of the library is passed to the linker instead of the one being (re)built. That is, even if libfoo, which supplies /sw/lib/libfoo.dylib, is installed, building the libfoo package again should link other files against the libfoo shared library in the local build directory. A command like &amp;lt;code&amp;gt;gcc -o libfoo-demo -L/sw/lib -L. -lfoo&amp;lt;/code&amp;gt; is wrong, and should instead be &amp;lt;code&amp;gt;gcc -o libfoo-demo -L/sw/lib ./libfoo.dylib&amp;lt;/code&amp;gt; (i.e., explicit filename instead of gcc search paths). There are several possible causes:&lt;br /&gt;
## A bug in older libtool. This patch solves it:&amp;lt;pre&amp;gt;perl -pi -e 's/hardcode_direct=yes/hardcode_direct=no/g' configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
## Bugs in packages' makefiles. They pass &amp;lt;code&amp;gt;LDFLAGS=-L$(build_dir) -lfoo&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;LDFLAGS=$(build_dir)/libfoo.dylib&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;LIBADD=$(build_dir)/libfoo.la&amp;lt;/code&amp;gt;)&lt;br /&gt;
## Package maintainers' using some variant of the broken LDFLAGS syntax to fix some other problem.&lt;br /&gt;
&lt;br /&gt;
[[Category: Fink|Porting Notes]]&lt;br /&gt;
[[Category: Fink_Documentation|Porting Notes]]&lt;br /&gt;
&lt;br /&gt;
{{Fink_Header}}&lt;/div&gt;</summary>
		<author><name>Dmacks</name></author>
	</entry>
</feed>