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

After struggling with this same problem and following all the accepted answers of updating build settings, clearing the linker search path, etc.. I finally discovered an answer that worked for me. Before building, make sure you select right type (iPhone Simulator) instead of iOS Device. Then rebuild. Otherwise, you’re trying to use a library built … Read more

undefined reference to `strlwr’

strlwr() is not standard C function. Probably it’s provided by one implementation while the other compiler you use don’t. You can easily implement it yourself: #include <string.h> #include<ctype.h> char *strlwr(char *str) { unsigned char *p = (unsigned char *)str; while (*p) { *p = tolower((unsigned char)*p); p++; } return str; }

Multiple definition of … linker error

Don’t define variables in headers. Put declarations in header and definitions in one of the .c files. In config.h extern const char *names[]; In some .c file: const char *names[] = { “brian”, “stefan”, “steve” }; If you put a definition of a global variable in a header file, then this definition will go to … Read more

Error when compiling some simple c++ code

Normally this sort of failure happens when compiling your C++ code by invoking the C front-end. The gcc you execute understands and compiles the file as C++, but doesn’t link it with the C++ libraries. Example: $ gcc example.cpp Undefined symbols for architecture x86_64: “std::cout”, referenced from: _main in ccLTUBHJ.o “std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> … Read more

C error: undefined reference to function, but it IS defined

How are you doing the compiling and linking? You’ll need to specify both files, something like: gcc testpoint.c point.c …so that it knows to link the functions from both together. With the code as it’s written right now, however, you’ll then run into the opposite problem: multiple definitions of main. You’ll need/want to eliminate one … Read more