2012-04-07 13 views
0

エラーが発生します。clang/LLVMを使用してLDFLAGS経由で.dylibをリンクする

ソースファイル参照の一つ:私は、リンクしようとし、以下のMakefileで働いています

#include <libxml/parser.h> 

LDFLAGS =-l../../usr/local/sys/usr/lib/libxml2.dylib 

パスが正しいように表示され、ファイルがあります。 IDEから

エラーの詳細: http://clip2net.com/clip/m0/1333837472-clip-29kb.png http://clip2net.com/clip/m0/1333837744-clip-32kb.png

私が間違って何をしているのですか?

############################################################################# 
# Makefile for iPhone application (X) 
############################################################################# 

# Define here the name of your project's main executable, and the name of the 
# build directory where the generated binaries and resources will go. 
NAME = X 
OUTDIR = X.app 

# Define here the minimal iOS version's MAJOR number (iOS3, iOS4 or iOS5) 
IOSMINVER = 5 

# List here your project's resource files. They can be files or directories. 
RES = Info.plist icon.png 

# Define here the compile options and the linker options for your project. 
CFLAGS = -W -Wall -O2 -Icocos2dx/include -Icocos2dx/platform -Icocos2dx/platform/ios -Icocos2dx/effects -Icocos2dx/cocoa -Icocos2dx/support -Icocos2dx/support/image_support -Icocos2dx/support/data_support -Icocos2dx/support/zip_support -Icocos2dx/extensions -Icocos2dx 
LDFLAGS =-l../../usr/local/sys/usr/lib/libxml2.2.dylib 

############################################################################# 
# Except for specific projects, you shouldn't need to change anything below 
############################################################################# 

# Define which compiler to use and what are the mandatory compiler and linker 
# options to build stuff for iOS. Here, use the ARM cross-compiler for iOS, 
# define IPHONE globally and link against all available frameworks. 
CC = clang 
LD = link 
CFLAGS += -ccc-host-triple arm-apple-darwin -march=armv6 --sysroot ../../usr/local/sys -integrated-as -fdiagnostics-format=msvc -fconstant-cfstrings -DIPHONE -D__IPHONE_OS_VERSION_MIN_REQUIRED=$(IOSMINVER)0000 
LDFLAGS += -lstdc++ $(addprefix -framework , $(notdir $(basename $(wildcard /Frameworks/iOS$(IOSMINVER)/*)))) 

# List here your source files. The current rule means: ask the shell to build 
# a one-liner list of all files in the current directory and its subdirectories 
# ending with either .c, .cc, .cpp, .cxx, .m, .mm, .mx or .mxx. 
SRC = $(shell find . \(-name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" -o -name "*.m" -o -name "*.mm" -o -name "*.mx" -o -name "*.mxx" \) -printf '%p ') 

# Define where the object files should go - currently, just aside the source 
# files themselves. We take the source file's basename and just append .o. 
OBJ = $(addsuffix .o, $(basename $(SRC))) 

################### 
# Rules definitions 

# This rule is the default rule that is called when you type "make". It runs 
# the specified other rules in that order: removing generated output from 
# previous builds, compiling all source files into object files, linking them 
# all together, codesigning the generated file, copying resources in place 
# and then displaying a success message. 
all: prune $(OBJ) link codesign resources checksum ipa deb end 

# The following rule removes the generated output from any previous builds 
prune: 
    @echo " + Pruning compilation results..." 
    @rm -f $(OUTDIR)/$(NAME) 

# The following rules compile any .c/.cc/.cpp/.cxx/.m/.mm/.mx/.mxx file it 
# finds in object files (.o). This is to handle source files in different 
# languages: C/C++ (with .c* extension), and Objective-C (.m*). 
%.o: %.c 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 
%.o: %.cc 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 
%.o: %.cpp 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 
%.o: %.cxx 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 
%.o: %.m 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 
%.o: %.mm 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 
%.o: %.mx 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 
%.o: %.mxx 
    @echo " + Compiling $<..."; $(CC) $(CFLAGS) -o [email protected] -c $< 

# The following rule first ensures the output directory exists, creates it if 
# necessary, then links the compiled .o files together in that directory 
link: 
    @echo " + Linking project files..." 
    @test -d $(OUTDIR) || mkdir -p $(OUTDIR) 
    @$(LD) $(LDFLAGS) -o $(OUTDIR)/$(NAME) $(OBJ) 

# The following rule calls Saurik's ldid code pseudo-signing tool to generate 
# the SHA checksums needed for the generated binary to run on jailbroken iOS. 
codesign: 
    @echo " + Pseudo-signing code..." 
    @ldid -S $(OUTDIR)/$(NAME) 
    @rm -f $(OUTDIR)/.$(NAME).cs 

# The following rule takes all the specified resource items one after the 
# other (whether they are files or directories) ; files are copied in place 
# and directories are recursively copied only if they don't exist already. 
resources: 
    @echo " + Copying resources..." 
    @for item in $(RES); do \ 
     if [ -d $$item ]; then test -d $(OUTDIR)/$$item || cp -r $$item $(OUTDIR)/; chmod +r $(OUTDIR)/$$item; \ 
     else cp $$item $(OUTDIR)/; chmod +r $(OUTDIR)/$$item; \ 
     fi; \ 
    done 
    @chmod +x $(OUTDIR) 
    @chmod -R +r $(OUTDIR) 
    @chmod +x $(OUTDIR)/$(NAME) 

# The following rule takes all files in the target directory and builds the 
# _CodeSignature/CodeResource XML file with their SHA1 hashes. 
checksum: 
    @echo " + Generating _CodeSignature directory..." 
    @echo -n APPL???? > $(OUTDIR)/PkgInfo 
    @codesigner $(OUTDIR) > .CodeResources.$(NAME) 
    @test -d $(OUTDIR)/_CodeSignature || mkdir -p $(OUTDIR)/_CodeSignature 
    @mv .CodeResources.$(NAME) $(OUTDIR)/_CodeSignature/CodeResources 
    @test -L $(OUTDIR)/CodeResources || ln -s _CodeSignature/CodeResources $(OUTDIR)/CodeResources 

# The following rule builds an IPA file out of the compiled app directory. 
ipa: 
    @echo " + Building iTunes package..." 
    @test -d Packages || mkdir Packages 
    @rm -f Packages/$(NAME).ipa 
    @test -d Payload || mkdir Payload 
    @mv -f $(OUTDIR) Payload 
    @cp -f iTunesArtwork.jpg iTunesArtwork 
    @chmod +r iTunesArtwork 
    @zip -y -r Packages/$(NAME).ipa Payload iTunesArtwork -x \*.log \*.lastbuildstate \*successfulbuild > /dev/null 
    @rm -f iTunesArtwork 
    @mv -f Payload/$(OUTDIR) . 
    @rmdir Payload 

# The following rule builds a Cydia package out of the compiled app directory. 
deb: 
    @echo " + Building Cydia package..." 
    @test -d Packages || mkdir Packages 
    @rm -f Packages/$(NAME).deb 
    @test -d $(NAME) || mkdir $(NAME) 
    @test -d $(NAME)/Applications || mkdir $(NAME)/Applications 
    @mv -f $(OUTDIR) $(NAME)/Applications 
    @test -d $(NAME)/DEBIAN || mkdir $(NAME)/DEBIAN 
    @cp -f cydia-package.cfg $(NAME)/DEBIAN/control 
    @chmod +r $(NAME)/DEBIAN/control 
    @echo "#!/bin/bash" > $(NAME)/DEBIAN/postinst 
    @echo "rm -f /Applications/$(OUTDIR)/*.log /Applications/$(OUTDIR)/*.lastbuildstate /Applications/$(OUTDIR)/*.successfulbuild" >> $(NAME)/DEBIAN/postinst 
    @echo "chown -R root:admin \"/Applications/$(OUTDIR)\"" >> $(NAME)/DEBIAN/postinst 
    @echo "find \"/Applications/$(OUTDIR)\"|while read ITEM; do if [ -d \"\$$ITEM\" ]; then chmod 755 \"\$$ITEM\"; else chmod 644 \"\$$ITEM\"; fi; done" >> $(NAME)/DEBIAN/postinst 
    @echo "chmod +x \"/Applications/$(OUTDIR)/$(NAME)\"" >> $(NAME)/DEBIAN/postinst 
    @echo "su -c /usr/bin/uicache mobile 2> /dev/null" >> $(NAME)/DEBIAN/postinst 
    @echo "exit 0" >> $(NAME)/DEBIAN/postinst 
    @chmod +r+x $(NAME)/DEBIAN/postinst 
    @dpkg-deb -b $(NAME) > /dev/null 2>&1 
    @mv -f $(NAME).deb Packages 
    @mv -f $(NAME)/Applications/$(OUTDIR) . 
    @rm -rf $(NAME) 

# This simple rule displays the success message after a successful build 
end: 
    @echo " + Done. Output directory is \"$(OUTDIR)\", iTunes package is \"Packages\$(NAME).ipa\", Cydia package is \"Packages\$(NAME).deb\"." 

# This rule removes generated object files from the project and also temporary 
# files ending with ~ or #. 
clean: 
    @echo " + Cleaning project intermediate files..." 
    @rm -f $(OBJ) *~ *\# 
    @echo " + Done." 

# This rule removes all generated output from any previous builds so as to 
# leave an intact source tree (useful for generating source tree releases). 
distclean: clean 
    @echo " + Cleaning project output files..." 
    @rm -rf $(OUTDIR) 
    @echo " + Done." 
+0

問題は何ですか? –

答えて

5

実際には2つの問題があります。試してみることをお勧めします:

-I../../usr/local/sys/usr/includeをCFLAGSに追加してヘッダーを探します。

変更-L../../usr/local/sys/usr/libからLDFLAGSLIBS=-lxml2を追加し$(LD) $(LDFLAGS) -o $(OUTDIR)/$(NAME) $(OBJ) $(LIBS)にリンカーの呼び出しを変更する(すなわち、端部においてリンカーコマンド行の先頭に-L-lを追加)。

+0

ダニエル、答えてくれてありがとう。しかし、同じ問題。 あなたが正しく提案したことをやっていますか? http://pastebin.com/Nu5VCHKE –

+0

'../../ usr/local/sys/usr/include'に' parser.h'ファイルを含む 'libxml'ディレクトリがありますか?あなたはどこかに 'parser.h'ファイルを持っていますか? libxml2のインストール方法に応じて '-I'を' include'のいくつかのサブディレクトリに向けることができます。 –

3

-lは、ライブラリ名のみを指定するためのものです。ライブラリも探さされる場所のディレクトリを追加するために使用-L:

LDFLAGS += -L../../usr/local/sys/usr/lib -lxml2 

は、この情報がお役に立てば幸いです。

+0

ありがとう、それはそれをクリアします。でも同じ結果: http://clip2net.com/clip/m0/1333840844-clip-29kb.png –

+0

@private質問に問題があります。他のウェブサイトへのリンクではありません –

+0

確かに、私はlibxmlにリンクしようとしています私の.ccpファイルの1つにそれが含まれているからです。これまでの提案はありません。 .cppをコンパイルしようとすると、clangに対して実行されているMakefileのLDFLAGSで指定されているlibxml/parser.hを見つけることができません。 エラー: 'libxml/parser.h'ファイルが見つかりません –

関連する問題