Jump to content

Example makefile yields linker error on Mac: Wrong architecture!


dswl

Recommended Posts

I'm trying to get one of the demos to work on OS X. I followed every step on the "Getting Started" page and created a `os_osx64.mk` file as suggested by inmarket in this post to compile on x64 OS X.

Unfortunately ld yields errors about many ignored files that were built for i386 instead of x86_64.

ld: warning: ld: warning: ignoring file .build/obj/GFXLIB/src/gfile/gfile_fs_native.o, file was built for i386 which is not the architecture being linked (x86_64): .build/obj/GFXLIB/src/gfile/gfile_fs_native.oignoring file .build/obj/GFXLIB/src/gfile/gfile_fs_ram.o, file was built for i386 which is not the architecture being linked (x86_64): .build/obj/GFXLIB/src/gfile/gfile_fs_ram.old: warning:

The linking ultimately fails.

The C compiler options (Note the -m64 flag, which should to my understanding prevent the files from being compiled for i386):

gcc -c -L/usr/local/lib -lSDL2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -I/usr/local/include/SDL2 -D_THREAD_SAFE -I/usr/local/include/SDL2 -D_THREAD_SAFE -ggdb -O0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.11 -m64 -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm -MMD -MP -MF .build/dep/fakefile.o.d -I. -I../ugfx -I../ugfx/3rdparty/tinygl-0.4-ugfx/include -I../ugfx/boards/base/OSX -I../ugfx/drivers/multiple/SDL -I../ugfx/demos/modules/gdisp/basics -I../ugfx/demos/modules/gdisp/basics -I../ugfx -I../ugfx/3rdparty/tinygl-0.4-ugfx/include -I../ugfx/boards/base/OSX -I../ugfx/drivers/multiple/SDL -I../ugfx/demos/modules/gdisp/basics -DGFX_USE_OS_OSX=TRUE -DGFX_OS_PRE_INIT_FUNCTION=sdl_driver_init -DGFX_USE_OS_OSX=TRUE -DGFX_OS_PRE_INIT_FUNCTION=sdl_driver_init fakefile.c -o .build/obj/fakefile.o

The linker command:

Linker Options........
gcc -L/usr/local/lib -lSDL2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -L/usr/local/lib -lSDL2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -pthread -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.11 -m64 -nostartfiles .build/obj/fakefile.o -o .build/demotest.elf

I modified the example makefile from `ugfx/boards/base/OSX/example` as follows:

# Possible Targets:	all clean Debug cleanDebug Release cleanRelease

##############################################################################################
# Settings
#

# General settings
	# See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables
	OPT_OS					= osx64
	OPT_LINK_OPTIMIZE		= no

# uGFX settings
	# See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables
	GFXLIB					= ../ugfx
	GFXBOARD				= OSX
	GFXDEMO					= modules/gdisp/basics

# OSX settings
	# See $(GFXLIB)/tools/gmake_scripts/os_osx.mk for the list of variables
	OSX_SDK = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
	OSX_ARCH = -mmacosx-version-min=10.11

##############################################################################################
# Set these for your project
#

ARCH     =
SRCFLAGS = -ggdb -O0
CFLAGS   = `sdl2-config --libs --cflags`	# removed "--libs" flag, because of linker complaint
CXXFLAGS =
ASFLAGS  =
LDFLAGS  =

SRC      =
OBJS     =
DEFS     =
LIBS     =
INCPATH  =
LIBPATH  =

##############################################################################################
# These should be at the end
#

include $(GFXLIB)/gfx.mk
include $(GFXLIB)/demos/modules/gwin/widgets/demo.mk
include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk
include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk
include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk
# *** EOF ***

I use uGFX 2.7 on OS X 10.11.6. `gfxconf.example.h` is copied to my project folder, renamed to `gfxconf.h` and further untouched.

I appreciate any help pointing me out to what I'm doing wrong.

Regards

Link to comment
Share on other sites

Thank you very much. This solved this problem. To my defense, I'm quite new to make.

Unfortunately my series of problems with compiling this demo doesn’t stop. Could you please have a look at the follow up problem I described here?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...