Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Problem compiling software developed on linux on OSX
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem compiling software developed on linux on OSX



On May 22, 2006, at 5:21 PM, Gavin Sherlock wrote:

Hi,

I'm trying to compile some software for OSX, that was developed on linux (tarball available at http://microarray.org/data/download/g2c-1.0.tar.gz) , and ran into a number of problems, some of which I solved (or appeared to solve), but I'm now stuck. Any help would be greatly appreciated. The problems I encountered thus far were:

1.   The first problem is when it tries to compile dust.c:

ccsr-2255b-g5 1002 % make all
compiling g2c.c
compiling g2clib.c
compiling gopt.c
compiling blast.c
compiling complementation.c
compiling complexity.c
compiling dust.c
dust.c:2:20: error: malloc.h: No such file or directory
make: *** [dust.o ] Error 1

This is easy to get around - just remove the line:

#include <malloc.h>

from dust.c, as I think the malloc functions are provided from stdlib.h on OSX.

And any other POSIX compliant OS:

	http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html>

The code is actually wrong to include <malloc.h> on Linux.


2.  There was a problem with the -lexpat rule:

ccsr-2255b-g5 1004 % make all
compiling dust.c
compiling energy.c
compiling energy_data.c
compiling fasta.c
compiling lzw.c
compiling nucleotide.c
compiling util.c
compiling self.c
compiling SmithWaterman.c
compiling wublast.c
checking adt.a
ar rv ../adt.a FragmentSequence.o FragmentSequenceGroup.o GenomeTag.o
IndexValue.o Integer.o MatchingSequence.o MatchingSequenceLine.o
PositionEvidence.o
ar: creating archive ../adt.a
a - FragmentSequence.o
a - FragmentSequenceGroup.o
a - GenomeTag.o
a - IndexValue.o
a - Integer.o
a - MatchingSequence.o
a - MatchingSequenceLine.o
a - PositionEvidence.o
ranlib ../adt.a
checking util.a
ar rv ../util.a sht.o list.o Hashtable.o
ar: creating archive ../util.a
a - sht.o
a - list.o
a - Hashtable.o
ranlib ../util.a
making g2c
compiling readWuBlast.c
making readwu
make: *** No rule to make target `-lexpat', needed by `libg2c.so'.
Stop.

The -lexpat rule is in the makefile at:

LIBG2C_OBJS = g2clib.o \
blast.o complementation.o complexity.o dust.o \
energy.o energy_data.o fasta.o lzw.o nucleotide.o util.o \
self.o SmithWaterman.o wublast.o -lexpat \
${ADT_LIB} ${UTIL_LIB}


I'm presuming that it needs to link on the expat libraries for XML parsing. I have expat 2.0 installed, with the following files on my system:

/usr/local/lib/libexpat.a
/usr/local/include/expat.h
/usr/local/include/expat_external.h

To get around this, I simply copied libexpat.a to my working directory.

Or you can specify it on the library include path with the option "-L/ usr/local/lib". There should be an LDFLAGS you can set for this, and it's also probably a configure option.



3.  -shared problem

ccsr-2255b-g5 1016 % cp /usr/local/lib/libexpat.a ./
ccsr-2255b-g5 1017 % make clean
.
.
.
ccsr-2255b-g5 1020 % make all
.
.
.
making g2c
compiling readWuBlast.c
making readwu
making libg2c.so
powerpc-apple-darwin8-gcc-4.0.1: unrecognized option '-shared'
/usr/bin/ld: Undefined symbols:
_main
collect2: ld returned 1 exit status
make: *** [libg2c.so] Error 1

Looking into Apple's docs, I found -dynamic is the replacement for - shared on OSX (see http://developer.apple.com/technotes/tn2002/tn2071.html#Section5), but still no success when I replace the option:

making libg2c.so
/usr/bin/ld: Undefined symbols:
_main
collect2: ld returned 1 exit status
make: *** [libg2c.so] Error 1


If you could include the entire compilation line for one of the .o files, that would be helpful.

A common cause of this is missing -fPIC or trying to use 'ld' directly instead of using "g++" or "gcc" as the linker (whichever is appropriate), but without the compilation line you are using, there's no way to know what options you're adding that you shouldn't, or are missing that you need to add.

-- Terry


I then tried -dynamiclib instead (I have no idea if I should do this), which got me past the last error, but now this resulted in a different error:


.
.
.
making g2c
compiling readWuBlast.c
making readwu
making libg2c.so
ld: common symbols not allowed with MH_DYLIB output format with the - multi_module option
energy_data.o definition of common _WC_Matrix (size 2500)
energy_data.o definition of common _bulge (size 124)
energy_data.o definition of common _loop (size 124)
lzw.o definition of common _append_character (size 4)
lzw.o definition of common _code_value (size 4)
lzw.o definition of common _decode_stack (size 4000)
lzw.o definition of common _prefix_code (size 4)
wublast.o definition of common _token (size 1024)
/usr/bin/libtool: internal link edit command failed
make: *** [libg2c.so] Error 1


and now I'm well and truly stuck.

I'm on 10.4.6 on PowerPC, with the latest version of XCode. gcc -- version says:

ccsr-2255b-g5 1066 % gcc --version
powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5247)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Many thanks for any help,
Cheers,
Gavin

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Unix-porting mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Problem compiling software developed on linux on OSX (From: Gavin Sherlock <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.