0
votes

So I am trying to use a C library in a Objective-C, iPhone project. I am getting this linker error when I try to compile:

file was built for unsupported file format which is not the architecture being linked (i386)

I build this library using the standard

./configure make

Which architecture should I build this with to work with iPhone project? Thanks! Update

I updated the Makefile and added -arch i386 to the CFLAGS line. When I run make I now this get this error:

Compiling spammer.c gcc -o spammer spammer.o ../src/libircclient.a -lpthread ld: warning: in ../src/libircclient.a, file was built for unsupported file format which is not the architecture being linked (x86_64)

Does this mean I need to edit another makefile somewhere??

2

2 Answers

1
votes

It likely was built for x86_64 which is the default. You need to modify the library so that it's compiled for i386 and will match your application.

Typically you do that by setting the CFLAGS environment variable to -arch i386 before running configure. Make sure to do a "make dist clean" first though. If that doesn't work, you can also hand-edit the Makefile after configure creates it and add -arch i386 to the CFLAGS= line.

0
votes

This error:

Compiling spammer.c gcc -o spammer spammer.o ../src/libircclient.a -lpthread ld: warning: in ../src/libircclient.a, file was built for unsupported file format which is not the architecture being linked (x86_64)

Comes when building the examples and that's not really what you want right?

Do a make in the SRC folder and building with -arch i386 or -arch arvm7 will work.