Page 1 of 1

Mac makefile made from scratch

Posted: Mon Dec 26, 2016 5:34 am
by pvn
Hi all

I made a wxWidgets C++ appplication for Linux using a Makefile made from scratch, instead of using the build system/makefiles
supplied by wxWidgets

to get the compiler and link flags I used
wx-config --cxxflags
wx-config --libs

I did the same for Mac, but it builds an executable that opens a terminal (and then the GUI app), but not directly the GUI, and also
it does not have an icon.

How can I add to the Makefile the creation of the Mac icon image and GUI app?


Re: Mac makefile made from scratch

Posted: Mon Dec 26, 2016 9:35 am
by doublemax
You need to create an App bundle under OS X. This might help: viewtopic.php?p=30345#p30345

Re: Mac makefile made from scratch

Posted: Mon Dec 26, 2016 12:43 pm
by xaviou

As doublemax said, you need to creare an application bundle.

But if you want to make some tests without creating a bundle, you just need to make a call to "SetFile" :

Code: Select all

SetFile -t APPL YourExecutableFile
Note that you will also have to make this call if you create a bundle.


Edit: this is for the "non-terminal" part of your message. For the application icon, you'll have to make a bundle.

Re: Mac makefile made from scratch

Posted: Tue Dec 27, 2016 7:39 am
by pvn
With the minimal app link I modified my Makefile to have this simpler modified version.
Here "Explorer" is the executable name and it has to match the strings for keys

Code: Select all

in Info_cocoa.plist

the $(OBJs) part is missing , these are object files generated by g++ from C++ source files

Code: Select all

CXX = g++
CXX_FLAG = -DHAVE_PLPLOT -stdlib=libc++ -std=c++11 -Wall -D_FILE_OFFSET_BITS=64 -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__
LINK_FLAG = -stdlib=libc++

# Bundle
PROGRAM = Explorer
ICONFILE = wxmac.icns

all:  $(BUNDLE)

# This builds the executable and makes the bundle
$(BUNDLE): $(OBJs) 
	@echo "Building: $(BUNDLE)"
	mkdir -p $(BUNDLE)/Contents/MacOS
	$(CXX) $(LINK_FLAG) -o $(BUNDLE)/Contents/MacOS/$(PROGRAM) $(OBJs) $(LIB) 
	mkdir -p $(BUNDLE)/Contents
	mkdir -p $(BUNDLE)/Contents/Resources
	cp Info_cocoa.plist $(BUNDLE)/Contents/Info.plist
	cp -f $(ICONFILE) $(BUNDLE)/Contents/Resources/$(ICONFILE)