I tried compiler TCC(Tiny C compiler: https://bellard.org/tcc/) form source code:
$ pwd
/cygdrive/D/Download/tcc-0.9.27/tcc-0.9.27
Administrator#MS-QMYKYRDOTLFI /cygdrive/D/Download/tcc-0.9.27/tcc-0.9.27
$ ./configure
Binary directory C:/Program Files/tcc
TinyCC directory C:/Program Files/tcc
Library directory C:/Program Files/tcc/libtcc
Doc directory C:/Program Files/tcc/doc
Source path .
C compiler gcc (11.2)
Target OS CYGWIN_NT-10.0
CPU x86_64
Config WIN32
Creating config.mak and config.h
config.h is unchanged
after configutre, make, make install.
then, i run the fib.c, it show error message:
$ pwd
/cygdrive/c/Program Files/tcc/examples
Administrator#MS-QMYKYRDOTLFI /cygdrive/c/Program Files/tcc/examples
$ ../tcc.exe -run fib.c 12
tcc: error: -run is not available in a cross compiler
This is run on Windows 10, Cygwin64 Terminal.
I check the source code, in libtcc.c, there are these lines:
#ifndef TCC_IS_NATIVE
tcc_error("-run is not available in a cross compiler");
#endif
Maybem the reason is, when i "make", i didnot add _DTCC_IS_NATIVE? I don't know.
If i download tcc-0.9.27-win64-bin form web, '-run' works! Please help me , how to generate a tcc.exe can use '-run'.
Thanks!
Add CPPFLAGS or CFLAGS , also did not work:
$ ./configure CPPFLAGS="-DTCC_IS_NATIVE"
configure: WARNING: unrecognized option CPPFLAGS=-DTCC_IS_NATIVE
Binary directory C:/Program Files/tcc
TinyCC directory C:/Program Files/tcc
Library directory C:/Program Files/tcc/libtcc
Doc directory C:/Program Files/tcc/doc
Source path .
C compiler gcc (11.2)
Target OS CYGWIN_NT-10.0
CPU x86_64
Config WIN32
Creating config.mak and config.h
config.h is unchanged
Put CPPFLAGS before configure, also did not work:
Administrator#MS-QMYKYRDOTLFI /cygdrive/D/Download/tcc-0.9.27/tcc-0.9.27
$ CPPFLAGS=-DTCC_IS_NATIVE ./configure
Binary directory C:/Program Files/tcc
TinyCC directory C:/Program Files/tcc
Library directory C:/Program Files/tcc/libtcc
Doc directory C:/Program Files/tcc/doc
Source path .
C compiler gcc (11.2)
Target OS CYGWIN_NT-10.0
CPU x86_64
Config WIN32
Creating config.mak and config.h
config.h is unchanged
$ make
gcc -o tcc.o -c tcc.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o libtcc.o -c libtcc.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o tccpp.o -c tccpp.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o tccgen.o -c tccgen.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o tccelf.o -c tccelf.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o tccasm.o -c tccasm.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o tccrun.o -c tccrun.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o x86_64-gen.o -c x86_64-gen.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o x86_64-link.o -c x86_64-link.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o i386-asm.o -c i386-asm.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
gcc -o tccpe.o -c tccpe.c -DTCC_TARGET_X86_64 -DTCC_TARGET_PE -DLIBTCC_AS_DLL -DONE_SOURCE=0 -Wall -g -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
In function ‘pe_write’,
inlined from ‘pe_output_file’ at tccpe.c:1975:19:
tccpe.c:677:9: warning: ‘strncpy’ output may be truncated copying 8 bytes from a string of length 31 [-Wstringop-truncation]
677 | strncpy((char*)psh->Name, sh_name, sizeof psh->Name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -shared -o libtcc.dll libtcc.o tccpp.o tccgen.o tccelf.o tccasm.o tccrun.o x86_64-gen.o x86_64-link.o i386-asm.o tccpe.o -static
gcc -o tcc.exe tcc.o libtcc.dll -static
make[1]: Entering directory '/cygdrive/D/Download/tcc-0.9.27/tcc-0.9.27/lib'
../tcc.exe -c libtcc1.c -o libtcc1.o -B../win32 -I../include
../tcc.exe -c alloca86_64.S -o alloca86_64.o -B../win32 -I../include
../tcc.exe -c alloca86_64-bt.S -o alloca86_64-bt.o -B../win32 -I../include
../tcc.exe -c ../win32/lib/chkstk.S -o chkstk.o -B../win32 -I../include
../tcc.exe -c bcheck.c -o bcheck.o -B../win32 -I../include
../tcc.exe -c ../win32/lib/crt1.c -o crt1.o -B../win32 -I../include
../tcc.exe -c ../win32/lib/crt1w.c -o crt1w.o -B../win32 -I../include
../tcc.exe -c ../win32/lib/wincrt1.c -o wincrt1.o -B../win32 -I../include
../tcc.exe -c ../win32/lib/wincrt1w.c -o wincrt1w.o -B../win32 -I../include
../tcc.exe -c ../win32/lib/dllcrt1.c -o dllcrt1.o -B../win32 -I../include
../tcc.exe -c ../win32/lib/dllmain.c -o dllmain.o -B../win32 -I../include
../tcc.exe -ar rcs ../libtcc1.a libtcc1.o alloca86_64.o alloca86_64-bt.o chkstk.o bcheck.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
make[1]: Leaving directory '/cygdrive/D/Download/tcc-0.9.27/tcc-0.9.27/lib'
./tcc.exe -impdef libtcc.dll -o libtcc.def
makeinfo tcc-doc.texi || true
Can't locate Texinfo/ModulePath.pm in #INC (you may need to install the Texinfo::ModulePath module) (#INC contains: /mingw64/share/texinfo /usr/local/lib/perl5/site_perl/5.32/x86_64-cygwin-threads /usr/local/share/perl5/site_perl/5.32 /usr/lib/perl5/vendor_perl/5.32/x86_64-cygwin-threads /usr/share/perl5/vendor_perl/5.32 /usr/lib/perl5/5.32/x86_64-cygwin-threads /usr/share/perl5/5.32) at /cygdrive/d/Program Files/GNU Octave/Octave-6.3.0/mingw64/bin/makeinfo line 82.
BEGIN failed--compilation aborted at /cygdrive/d/Program Files/GNU Octave/Octave-6.3.0/mingw64/bin/makeinfo line 85.
$ make install
mkdir -p "C:/Program Files/tcc" && install -m755 tcc.exe libtcc.dll "C:/Program Files/tcc"
mkdir -p "C:/Program Files/tcc/lib" && install -m644 ./win32/lib/*.def "C:/Program Files/tcc/lib"
mkdir -p "C:/Program Files/tcc/lib" && install -m644 libtcc1.a "C:/Program Files/tcc/lib"
mkdir -p "C:/Program Files/tcc/include" && install -m644 ./include/*.h ./tcclib.h "C:/Program Files/tcc/include"
mkdir -p "C:/Program Files/tcc/include" && cp -r ./win32/include/. "C:/Program Files/tcc/include"
mkdir -p "C:/Program Files/tcc/examples" && cp -r ./win32/examples/. "C:/Program Files/tcc/examples"
mkdir -p "C:/Program Files/tcc/examples" && install -m644 ./tests/libtcc_test.c "C:/Program Files/tcc/examples"
mkdir -p "C:/Program Files/tcc/libtcc" && install -m644 ./libtcc.h libtcc.def "C:/Program Files/tcc/libtcc"
mkdir -p "C:/Program Files/tcc/doc" && install -m644 ./win32/tcc-win32.txt tcc-doc.html "C:/Program Files/tcc/doc"
Administrator#MS-QMYKYRDOTLFI /cygdrive/D/Download/tcc-0.9.27/tcc-0.9.27
$ cd -
/cygdrive/c/Program Files/tcc/examples
Administrator#MS-QMYKYRDOTLFI /cygdrive/c/Program Files/tcc/examples
$ pwd
/cygdrive/c/Program Files/tcc/examples
Administrator#MS-QMYKYRDOTLFI /cygdrive/c/Program Files/tcc/examples
$ ../tcc.exe -run fib.c 12
tcc: error: -run is not available in a cross compiler
Related
I've been having troubles with this Makefile :
SRCS = gnl/get_next_line.c \
$(wildcard parsing/*.c) \
$(wildcard libft/*.c) \
$(wildcard *.c) \
OBJS = ${SRCS:.c=.o}
FLAGS = -Wall -Wextra -Werror -g
NAME = cub3d
LIBS = -lm -lX11 -lXext -std=gnu99 $(wildcard mlx/*.a)
RM = rm -rf
all : ${NAME}
3DLIB : ${OBJS}
ar rcs cub3d.a ${OBJS}
ranlib cub3d.a
$(NAME) :
${3DLIB} && gcc -o cub3d ${FLAGS} cub3d.c cub3d.a -I. -g ${LIBS}
When I try to make, the terminal returns this error :
&& gcc -o cub3d -Wall -Wextra -Werror -g cub3d.c cub3d.a -I. -g -lm -lX11 -lXext -std=gnu99 mlx/libmlx_Linux.a mlx/libmlx.a
/bin/sh: 1: Syntax error: "&&" unexpected
Makefile:35: recipe for target 'cub3d' failed
make: *** [cub3d] Error 2
Which is weird because if I just run make 3DLIB && gcc -o cub3d -Wall -Wextra -Werror cub3d.c cub3d.a -I. -g -lm -lX11 -lXext -std=gnu99 mlx/*.a (which seems to me to be the same command) raw, it works just well. I've tried different syntaxes in the Makefile to try to make it work, but have come short.
Could someone show me the problem ?
${3DLIB} && gcc -o cub3d ${FLAGS} cub3d.c cub3d.a -I. -g ${LIBS} does not work because ${3DLIB} attempts to use the value of a symbol named 3DLIB in a command, but there is no symbol with that name.
The line 3DLIB : ${OBJS} introduces a rule that says a target named 3DLIB must be rebuilt if any of the files in ${OBJS} have later modifications than a file named 3DLIB (or if no such file exists). It does not define a symbol named 3DLIB.
To specify that the 3DLIB rule is a prerequisite to $(NAME), change the line:
$(NAME) :
to:
$(NAME) : 3DLIB
Then remove the ${3DLIB} && from ${3DLIB} && gcc -o cub3d ${FLAGS} cub3d.c cub3d.a -I. -g ${LIBS}, leaving gcc -o cub3d ${FLAGS} cub3d.c cub3d.a -I. -g ${LIBS}.
I'm trying to compile a simple project with .c and .s files using my Mac.
When I run 'make' it goes threw on the compilation, and I think it failed when its trying to link (not sure).
Here is the error it shows:
gcc -m32 -g -Wall -c -o main.o main.c
gcc -m32 -g -Wall -c -o numbers.o numbers.c
nasm -g -f macho -w+all -o add.o add.s
gcc -m32 -g -Wall -o run main.o numbers.o add.o
ld: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd:4:18: error: unknown enumerated scalar
platform: zippered
^~~~~~~~
file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [run] Error 1
and I'll add the makefile as well:
run: main.o numbers.o add.o
gcc -m32 -g -Wall -o run main.o numbers.o add.o
main.o: main.c
gcc -m32 -g -Wall -c -o main.o main.c
numbers.o: numbers.c
gcc -m32 -g -Wall -c -o numbers.o numbers.c
add.o: add.s
nasm -g -f macho -w+all -o add.o add.s
.PHONY: clean
clean:
rm -f *.o run
I have a file called wrapsock.c that has several wrapper functions for the socket.h header file. I have two executables, FTP_client and FTP_server who both need to use the wrapsock.c file. I am having trouble with my makefile to link the wrapsock.c file to both of these programs
Here is my makefile below:
all: ./bin/FTP_client ./bin/FTP_server
bin/FTP_client: main_client.o wrapsock.o
gcc -o bin/FTP_client main_client.o wrapsock.o -lpthread -g
mv main_client.o ./bin
mv wrapsock.o ./bin
bin/FTP_server: main_server.o wrapsock.o
gcc -o bin/FTP_server main_server.o wrapsock.o -lpthread -g
mv main_server.o ./bin
mv wrapsock.o ./bin
main_client.o: src/main_client.c
gcc -c src/main_client.c -g
wrapsock.o: src/wrapsock.c src/wrapsock.h
gcc -c src/wrapsock.c -g
main_server.o: src/main_server.c
gcc -c src/main_server.c -g
clean:
rm ./bin/*.o
rm ./bin/FTP_client
rm ./bin/FTP_server
This is the error I am receiving:
gcc -c src/main_client.c -g
gcc -c src/wrapsock.c -g
gcc -o bin/FTP_client main_client.o wrapsock.o -lpthread -g
mv main_client.o ./bin
mv wrapsock.o ./bin
gcc -o bin/FTP_server main_server.o wrapsock.o -lpthread -g
gcc: error: wrapsock.o: No such file or directory
make: *** [makefile:9: bin/FTP_server] Error 1
mv wrapsock.o ./bin
gcc -o bin/FTP_server main_server.o wrapsock.o -lpthread -g
gcc: error: wrapsock.o: No such file or directory
To move the object is not a good way, create the objects directly into the directory bin as you do for the executable :
all: ./bin/FTP_client ./bin/FTP_server
bin/FTP_client: bin/main_client.o bin/wrapsock.o
gcc -o bin/FTP_client bin/main_client.o bin/wrapsock.o -lpthread -g
bin/FTP_server: bin/main_server.o bin/wrapsock.o
gcc -o bin/FTP_server bin/main_server.o bin/wrapsock.o -lpthread -g
bin/main_client.o: src/main_client.c
gcc -c src/main_client.c -g -o bin/main_client.o
bin/wrapsock.o: src/wrapsock.c src/wrapsock.h
gcc -c src/wrapsock.c -g -o bin/wrapsock.o
bin/main_server.o: src/main_server.c
gcc -c src/main_server.c -g -o bin/main_server.o
clean:
rm ./bin/*.o
rm ./bin/FTP_client
rm ./bin/FTP_server
Not sure why are you moving the binary objects to bin/, but after you've built your client target wrapsock.o is no longer in project root and resides in bin/ instead, so when server target gets its turn, gcc can no longer find it. I would just ditch the moves or if there is a reason for performing them, do so in a separate target that is done only after both binaries have been built (i.e. lists them as prerequisites).
I'm trying to compile the TPC-H Benchmark and when I made make, is returned the following error:
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o build.o build.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o driver.o driver.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o bm_utils.o bm_utils.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o rnd.o rnd.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o print.o print.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o load_stub.o load_stub.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o bcd2.o bcd2.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o speed_seed.o speed_seed.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o text.o text.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o permute.o permute.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -c -o rng64.o rng64.c
gcc -g -DDBNAME=\"dss\" -DLINUX -DORACLE -DTPCH -DRNG_TEST -D_FILE_OFFSET_BITS=64 -O -o dbgen build.o driver.o bm_utils.o rnd.o print.o load_stub.o bcd2.o speed_seed.o text.o permute.o rng64.o -lm
ld: library not found for -lgcc
collect2: error: ld returned 1 exit status
make: *** [dbgen] Error 1
I made a search for trying to fix this and I don't found it any help yet. Somebody can help me please?
try using gcc-5 on your makefile. i had the same problem with tpc-h.
I'm trying to code a printf clone. I've built a library file called "libftprintf.a" but when I try to use it, I get the following error, on Mac OSX 10.8.5:
ld: warning: ignoring file ./libftprintf.a, file was built for archive which is not the architecture being linked (x86_64): ./libftprintf.a
Strangely this works fine (but I need only one lib called libftprintf, so this is not acceptable):
gcc -Wall -Wextra -Werror -I libft/includes/ -o ft_printf_test.bin -L libft -lft -L. -lftprintf ft_printf_test.c
I suspect I have misused the ar command to link both libs together. But I don't se my mistake yet.
What could be the cause of that?
Everything seems to compile just fine until I try to use the libftprintf.a file with the make test command. I've searched for a solution on Google, but most answers relate to XCode only. According to lipo -info, the files are x86_64.
My GCC version:
$> gcc --version
Configured with: --prefix=/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
Below is the full output of my makefile, for reference.
$> make re
make -C libft clean
rm -f src/ft_arrdel.o src/ft_atoi.o src/ft_bzero.o src/ft_isalnum.o src/ft_isalpha.o src/ft_isascii.o src/ft_isdigit.o src/ft_islower.o src/ft_isprint.o src/ft_isupper.o src/ft_itoa.o src/ft_lstadd.o src/ft_lstdel.o src/ft_lstdelone.o src/ft_lstiter.o src/ft_lstmap.o src/ft_lstnew.o src/ft_lstpush.o src/ft_malloc.o src/ft_memalloc.o src/ft_memccpy.o src/ft_memchr.o src/ft_memcmp.o src/ft_memcpy.o src/ft_memdel.o src/ft_memmove.o src/ft_memset.o src/ft_putchar.o src/ft_putchar_fd.o src/ft_putendl.o src/ft_putendl_fd.o src/ft_putnbr.o src/ft_putnbr_fd.o src/ft_putstr.o src/ft_putstr_fd.o src/ft_strcat.o src/ft_strchr.o src/ft_strclr.o src/ft_strcmp.o src/ft_strcpy.o src/ft_strdel.o src/ft_strdup.o src/ft_strequ.o src/ft_striter.o src/ft_striteri.o src/ft_strjoin.o src/ft_strlcat.o src/ft_strlen.o src/ft_strmap.o src/ft_strmapi.o src/ft_strncat.o src/ft_strncmp.o src/ft_strncpy.o src/ft_strnequ.o src/ft_strnew.o src/ft_strnstr.o src/ft_strrchr.o src/ft_strrev.o src/ft_strsplit.o src/ft_strstr.o src/ft_strsub.o src/ft_strtrim.o src/ft_tolower.o src/ft_toupper.o src/get_next_line.o
rm -f ft_printf.o
make -C libft fclean
rm -f src/ft_arrdel.o src/ft_atoi.o src/ft_bzero.o src/ft_isalnum.o src/ft_isalpha.o src/ft_isascii.o src/ft_isdigit.o src/ft_islower.o src/ft_isprint.o src/ft_isupper.o src/ft_itoa.o src/ft_lstadd.o src/ft_lstdel.o src/ft_lstdelone.o src/ft_lstiter.o src/ft_lstmap.o src/ft_lstnew.o src/ft_lstpush.o src/ft_malloc.o src/ft_memalloc.o src/ft_memccpy.o src/ft_memchr.o src/ft_memcmp.o src/ft_memcpy.o src/ft_memdel.o src/ft_memmove.o src/ft_memset.o src/ft_putchar.o src/ft_putchar_fd.o src/ft_putendl.o src/ft_putendl_fd.o src/ft_putnbr.o src/ft_putnbr_fd.o src/ft_putstr.o src/ft_putstr_fd.o src/ft_strcat.o src/ft_strchr.o src/ft_strclr.o src/ft_strcmp.o src/ft_strcpy.o src/ft_strdel.o src/ft_strdup.o src/ft_strequ.o src/ft_striter.o src/ft_striteri.o src/ft_strjoin.o src/ft_strlcat.o src/ft_strlen.o src/ft_strmap.o src/ft_strmapi.o src/ft_strncat.o src/ft_strncmp.o src/ft_strncpy.o src/ft_strnequ.o src/ft_strnew.o src/ft_strnstr.o src/ft_strrchr.o src/ft_strrev.o src/ft_strsplit.o src/ft_strstr.o src/ft_strsub.o src/ft_strtrim.o src/ft_tolower.o src/ft_toupper.o src/get_next_line.o
rm -f libft.a
rm -f libftprintf.a
rm -Rf ft_printf_test.bin*
gcc -Wall -Wextra -Werror -I libft/includes/ -c ft_printf.c -o ft_printf.o
make -C libft
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_arrdel.c -o src/ft_arrdel.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_atoi.c -o src/ft_atoi.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_bzero.c -o src/ft_bzero.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_isalnum.c -o src/ft_isalnum.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_isalpha.c -o src/ft_isalpha.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_isascii.c -o src/ft_isascii.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_isdigit.c -o src/ft_isdigit.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_islower.c -o src/ft_islower.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_isprint.c -o src/ft_isprint.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_isupper.c -o src/ft_isupper.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_itoa.c -o src/ft_itoa.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_lstadd.c -o src/ft_lstadd.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_lstdel.c -o src/ft_lstdel.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_lstdelone.c -o src/ft_lstdelone.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_lstiter.c -o src/ft_lstiter.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_lstmap.c -o src/ft_lstmap.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_lstnew.c -o src/ft_lstnew.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_lstpush.c -o src/ft_lstpush.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_malloc.c -o src/ft_malloc.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memalloc.c -o src/ft_memalloc.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memccpy.c -o src/ft_memccpy.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memchr.c -o src/ft_memchr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memcmp.c -o src/ft_memcmp.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memcpy.c -o src/ft_memcpy.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memdel.c -o src/ft_memdel.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memmove.c -o src/ft_memmove.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_memset.c -o src/ft_memset.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putchar.c -o src/ft_putchar.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putchar_fd.c -o src/ft_putchar_fd.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putendl.c -o src/ft_putendl.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putendl_fd.c -o src/ft_putendl_fd.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putnbr.c -o src/ft_putnbr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putnbr_fd.c -o src/ft_putnbr_fd.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putstr.c -o src/ft_putstr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_putstr_fd.c -o src/ft_putstr_fd.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strcat.c -o src/ft_strcat.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strchr.c -o src/ft_strchr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strclr.c -o src/ft_strclr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strcmp.c -o src/ft_strcmp.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strcpy.c -o src/ft_strcpy.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strdel.c -o src/ft_strdel.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strdup.c -o src/ft_strdup.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strequ.c -o src/ft_strequ.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_striter.c -o src/ft_striter.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_striteri.c -o src/ft_striteri.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strjoin.c -o src/ft_strjoin.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strlcat.c -o src/ft_strlcat.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strlen.c -o src/ft_strlen.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strmap.c -o src/ft_strmap.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strmapi.c -o src/ft_strmapi.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strncat.c -o src/ft_strncat.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strncmp.c -o src/ft_strncmp.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strncpy.c -o src/ft_strncpy.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strnequ.c -o src/ft_strnequ.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strnew.c -o src/ft_strnew.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strnstr.c -o src/ft_strnstr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strrchr.c -o src/ft_strrchr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strrev.c -o src/ft_strrev.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strsplit.c -o src/ft_strsplit.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strstr.c -o src/ft_strstr.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strsub.c -o src/ft_strsub.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_strtrim.c -o src/ft_strtrim.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_tolower.c -o src/ft_tolower.o
gcc -g -Wall -Wextra -Werror -I includes -c src/ft_toupper.c -o src/ft_toupper.o
gcc -g -Wall -Wextra -Werror -I includes -c src/get_next_line.c -o src/get_next_line.o
ar -rsv libft.a src/ft_arrdel.o src/ft_atoi.o src/ft_bzero.o src/ft_isalnum.o src/ft_isalpha.o src/ft_isascii.o src/ft_isdigit.o src/ft_islower.o src/ft_isprint.o src/ft_isupper.o src/ft_itoa.o src/ft_lstadd.o src/ft_lstdel.o src/ft_lstdelone.o src/ft_lstiter.o src/ft_lstmap.o src/ft_lstnew.o src/ft_lstpush.o src/ft_malloc.o src/ft_memalloc.o src/ft_memccpy.o src/ft_memchr.o src/ft_memcmp.o src/ft_memcpy.o src/ft_memdel.o src/ft_memmove.o src/ft_memset.o src/ft_putchar.o src/ft_putchar_fd.o src/ft_putendl.o src/ft_putendl_fd.o src/ft_putnbr.o src/ft_putnbr_fd.o src/ft_putstr.o src/ft_putstr_fd.o src/ft_strcat.o src/ft_strchr.o src/ft_strclr.o src/ft_strcmp.o src/ft_strcpy.o src/ft_strdel.o src/ft_strdup.o src/ft_strequ.o src/ft_striter.o src/ft_striteri.o src/ft_strjoin.o src/ft_strlcat.o src/ft_strlen.o src/ft_strmap.o src/ft_strmapi.o src/ft_strncat.o src/ft_strncmp.o src/ft_strncpy.o src/ft_strnequ.o src/ft_strnew.o src/ft_strnstr.o src/ft_strrchr.o src/ft_strrev.o src/ft_strsplit.o src/ft_strstr.o src/ft_strsub.o src/ft_strtrim.o src/ft_tolower.o src/ft_toupper.o src/get_next_line.o
ar: creating archive libft.a
a - src/ft_arrdel.o
a - src/ft_atoi.o
a - src/ft_bzero.o
a - src/ft_isalnum.o
a - src/ft_isalpha.o
a - src/ft_isascii.o
a - src/ft_isdigit.o
a - src/ft_islower.o
a - src/ft_isprint.o
a - src/ft_isupper.o
a - src/ft_itoa.o
a - src/ft_lstadd.o
a - src/ft_lstdel.o
a - src/ft_lstdelone.o
a - src/ft_lstiter.o
a - src/ft_lstmap.o
a - src/ft_lstnew.o
a - src/ft_lstpush.o
a - src/ft_malloc.o
a - src/ft_memalloc.o
a - src/ft_memccpy.o
a - src/ft_memchr.o
a - src/ft_memcmp.o
a - src/ft_memcpy.o
a - src/ft_memdel.o
a - src/ft_memmove.o
a - src/ft_memset.o
a - src/ft_putchar.o
a - src/ft_putchar_fd.o
a - src/ft_putendl.o
a - src/ft_putendl_fd.o
a - src/ft_putnbr.o
a - src/ft_putnbr_fd.o
a - src/ft_putstr.o
a - src/ft_putstr_fd.o
a - src/ft_strcat.o
a - src/ft_strchr.o
a - src/ft_strclr.o
a - src/ft_strcmp.o
a - src/ft_strcpy.o
a - src/ft_strdel.o
a - src/ft_strdup.o
a - src/ft_strequ.o
a - src/ft_striter.o
a - src/ft_striteri.o
a - src/ft_strjoin.o
a - src/ft_strlcat.o
a - src/ft_strlen.o
a - src/ft_strmap.o
a - src/ft_strmapi.o
a - src/ft_strncat.o
a - src/ft_strncmp.o
a - src/ft_strncpy.o
a - src/ft_strnequ.o
a - src/ft_strnew.o
a - src/ft_strnstr.o
a - src/ft_strrchr.o
a - src/ft_strrev.o
a - src/ft_strsplit.o
a - src/ft_strstr.o
a - src/ft_strsub.o
a - src/ft_strtrim.o
a - src/ft_tolower.o
a - src/ft_toupper.o
a - src/get_next_line.o
ar -rsv libftprintf.a libft/libft.a ft_printf.o
ar: creating archive libftprintf.a
a - libft/libft.a
a - ft_printf.o
ranlib libftprintf.a
$> make test
gcc -Wall -Wextra -Werror -I libft/includes/ -L. -lftprintf -o ft_printf_test.bin ft_printf_test.c
ld: warning: ignoring file ./libftprintf.a, file was built for archive which is not the architecture being linked (x86_64): ./libftprintf.a
Undefined symbols for architecture x86_64:
"_ft_printf_string", referenced from:
_test_printf_percent in ft_printf_test-jTXeph.o
"_ft_strcmp", referenced from:
_test_printf_percent in ft_printf_test-jTXeph.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1
[ ckleines ~/Projects/2013-2014/Algo-1/printf ] $> lipo -info libft/libft.a
input file libft/libft.a is not a fat file
Non-fat file: libft/libft.a is architecture: x86_64
[ ckleines ~/Projects/2013-2014/Algo-1/printf ] $> lipo -info libftprintf.a
input file libftprintf.a is not a fat file
Non-fat file: libftprintf.a is architecture: x86_64
[ ckleines ~/Projects/2013-2014/Algo-1/printf ] $> lipo -info ft_printf.o
Non-fat file: ft_printf.o is architecture: x86_64
Use libtool -static -o instead of ar.
Static library link issue with Mac OS X: symbol(s) not found for architecture x86_64
I've found a slightly dirty but working solution for now. I extract the libft/libft.a archive in a temporary directory. Link the new library with the extracted .o files and then remove the temporary directory.
$(NAME): $(OBJ) $(HEADER)
make -C libft
mkdir libft_o && cd libft_o && ar -x ../libft/libft.a && cd ..
$(AR) $(NAME) libft_o/*.o $(OBJ)
rm -Rf libft_o
ranlib $(NAME)
The drawback being that if an object file from libft at some point has the same name than one from the printf files, it will overwrite things. But that's not likely to happen.
If you have fat architecture object files you must make sure that you pass the s flag to ar. Without it the linker will refuse to take archive files that contain fat architecture .o files. For example:
$ ar rcs libprintf.a *.o
You should then see a warning about creating a 'fat archive'. Don't worry about this, it means that ar won't be able to update the archive file, but the linker will be able to use it to link properly.