728x90

출처 : 안드로이드 c/c++ 개발환경 구축

Mac 환경에서 make-standalone-toolchain.sh 로 toolchain 사용해서 openssl 컴파일 해보았습니다.

컴파일 버전

openssl-1.0.1e.tar.gz

환경

Makefile 수정

추가

CROSS  = $(TOOLCHAIN)/bin/arm-linux-androideabi-
INCDIR = $(TOOLCHAIN)/sysroot/usr/include
LIBDIR = $(TOOLCHAIN)/sysroot/usr/lib

수정

CC= $(CROSS)gcc
AR= $(CROSS)ar $(ARFLAGS) r
RANLIB= $(CROSS)ranlib
NM= $(CROSS)nm

결과

테스트

Makefile

Makefile

-----------------------

libjson 파일컴파일

추가

CROSS  = $(TOOLCHAIN)/bin/arm-linux-androideabi-
INCDIR = $(TOOLCHAIN)/sysroot/usr/include
LIBDIR = $(TOOLCHAIN)/sysroot/usr/lib

수정

# Variables
prefix          = $(TOOLCHAIN)/sysroot/usr
exec_prefix     = $(prefix)
libdir          = lib
includedir      = include
srcdir          = _internal/Source
CXX             = $(CROSS)c++
AR              = $(CROSS)ar
PIC             = PIC
BUILD_TYPE      = "default"

728x90
728x90

출처

main.c 파일

#include <stdio.h>

int main(int argc, char* argv[])
{
	printf("Hello Android NDK! \n");	

	return 0;
}

Makefile 파일

TARGET = hello

TOOLCHAIN = D:/Windows/cygwin/opt/android-8-toolchain

CROSS  = $(TOOLCHAIN)/bin/arm-linux-androideabi-
INCDIR = $(TOOLCHAIN)/sysroot/usr/include
LIBDIR = $(TOOLCHAIN)/sysroot/usr/lib

CC 	= $(CROSS)gcc
AR 	= $(CROSS)ar
LD 	= $(CROSS)ld
NM 	= $(CROSS)nm
RANLIB 	= $(CROSS)ranlib
STRIP = $(CROSS)strip

INCLUDE = -I. -I$(INCDIR) 

CFLAGS = -Wall
LDFLAGS = -nostdlib -Wl,--dynamic-linker,"//system/bin/linker" -L$(LIBDIR) -lc -lm -lstdc++ -ldl
#LDFLAGS = -static -lc -lm -lstdc++

# crt 
CRTOBJ = $(LIBDIR)/crtbegin_dynamic.o

# application file
APPSOURCES = main.c
APPOBJS = $(APPSOURCES:.c=.o)

# define the rule
.SUFFIXES:.c .o 

.c.o:
	@echo Compiling: $< 
	$(CC) -c $(CFLAGS)  $(INCLUDE) -o $@ $<

all: app

app: $(APPOBJS)
	@echo Linking: $(TARGET) 
	$(CC) -o $(TARGET) $(APPOBJS) $(CRTOBJ) $(LDFLAGS)
	$(STRIP) -s $(TARGET)

clean:
	@rm -vf $(APPOBJS) $(TARGET) 
	

테스트

 

728x90

+ Recent posts