Mac makefile made from scratch

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
pvn
Experienced Solver
Experienced Solver
Posts: 62
Joined: Mon Dec 26, 2016 5:21 am
Contact:

Mac makefile made from scratch

Post by pvn » Mon Dec 26, 2016 5:34 am

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?

thanks

User avatar
doublemax
Moderator
Moderator
Posts: 14992
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Mac makefile made from scratch

Post by doublemax » Mon Dec 26, 2016 9:35 am

You need to create an App bundle under OS X. This might help: viewtopic.php?p=30345#p30345
Use the source, Luke!

User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 430
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Mac makefile made from scratch

Post by xaviou » Mon Dec 26, 2016 12:43 pm

Hi.

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.

Regards
Xav'

Edit: this is for the "non-terminal" part of your message. For the application icon, you'll have to make a bundle.
My wxWidgets stuff web page : [email protected]'s wxStuff

pvn
Experienced Solver
Experienced Solver
Posts: 62
Joined: Mon Dec 26, 2016 5:21 am
Contact:

Re: Mac makefile made from scratch

Post by pvn » Tue Dec 27, 2016 7:39 am

thanks
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

<key>CFBundleExecutable</key>
<key>CFBundleName</key>
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
SETFILE = SetFile
PROGRAM = Explorer
ICONFILE = wxmac.icns
BUNDLESIGNATURE=????
BUNDLE=$(PROGRAM).app
MACPACKAGEINFO=$(BUNDLE)/Contents/PkgInfo

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
	$(SETFILE) -t APPL $(BUNDLE)/Contents/MacOS/$(PROGRAM)
	cp Info_cocoa.plist $(BUNDLE)/Contents/Info.plist
	echo -n "APPL$(BUNDLESIGNATURE)" > $(MACPACKAGEINFO)
	cp -f $(ICONFILE) $(BUNDLE)/Contents/Resources/$(ICONFILE)

Post Reply