Reputation: 141
I am trying to compile an application for WxWidgets using wxWidgets 2.9.3. I compiled the same source under Linux pretty fine and I think the main error is :
#error "Carbon does not support 64bit"
and I did not get how to set this correctly. to compile I used the follow command:
g++ hellomac.cpp -o hellomac `/opt/bin/wx-config --cxxflags --libs`
Could someone help me on this? /opt/bin is where my wxWidget is installed. My OSX is version 10.6.8
Upvotes: 0
Views: 2619
Reputation: 3070
A while ago on Snow Leopard I used the following configuration settings to build wxWidgets for OSX:
../configure --with-cocoa --with-macosx-version-min=10.6 --enable-unicode --disable-shared --enable-debug --enable-universal-binaries
The important options are --with-cocoa
and --enable-universal-binaries
to make it work under 64bit OSX.
After this just do make
to compile wxWidgets again.
Be aware there could be an older version of wxWidgets in /opt/bin/
. Because of new wxWidget upgrades I prefer to put the compiled version of wxWidgets in my home folder to keep an eye on all files. If you install it in your system paths you might lose the overview. Now it could happen you're not using the wx-config version you wanted to use.
To compile your own wxWidget apps I recommend to create your own Makefile.
Your compiling command looks already good, but let me give you an advice. After --libs
try using flags like core
and base
to keep save all OSX Frameworks will be added to your compilation.
Here a simple Makefile example you can use if you want to. It also creates an OSX executable.
APP = $(shell basename $(shell pwd))
CC = g++
CFLAGS = -Wall `wx-config --cppflags`
LFLAGS = `wx-config --libs core,base`
BUIDIR = build
OBJDIR = obj
OSXDIR = osx
SRCDIR = src
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
OBJECTS := $(patsubst $(SRCDIR)/%,%,$(patsubst %.cpp,%.o,$(SOURCES)))
NO_COLOR = \033[0m
O1_COLOR = \033[0;01m
O2_COLOR = \033[32;01m
PREFIX = "$(O2_COLOR)==>$(O1_COLOR)"
SUFFIX = "$(NO_COLOR)"
all: clean linking osx
@echo $(PREFIX) Build finished $(SUFFIX)
clean:
@echo $(PREFIX) Cleaning up $(SUFFIX)
rm -rfv $(BUIDIR) $(OBJDIR)
$(BUIDIR)/:
mkdir -p $@
$(OBJDIR)/:
mkdir -p $@
%.o: $(SRCDIR)/%.cpp
@echo $(PREFIX) Compiling $< $(SUFFIX)
$(CC) $(CFLAGS) -c $< -o $(OBJDIR)/$@
linking: $(BUIDIR)/ $(OBJDIR)/ $(OBJECTS)
@echo $(PREFIX) Linking $(SUFFIX)
$(CC) $(CFLAGS) $(OBJDIR)/*.o -o $(BUIDIR)/$(APP) $(LFLAGS)
osx: $(BUIDIR)/$(APP) $(OSXDIR)/Info.plist
@echo $(PREFIX) Creating Mac OS X executable file $(SUFFIX)
-mkdir $(BUIDIR)/$(APP).app
-mkdir $(BUIDIR)/$(APP).app/Contents
-mkdir $(BUIDIR)/$(APP).app/Contents/MacOS
-mkdir $(BUIDIR)/$(APP).app/Contents/Resources
-mkdir $(BUIDIR)/$(APP).app/Contents/Resources/English.lproj
cp $(OSXDIR)/Info.plist $(BUIDIR)/$(APP).app/Contents/
@#cp $(OSXDIR)/version.plist $(APP).app/Contents/
@#cp $(OSXDIR)/InfoPlist.strings $(APP).app/Contents/Resources/English.lproj/
@#cp $(OSXDIR)/Icons.icns AnotherResource.txt $(APP).app/Contents/Resources/
cp $(BUIDIR)/$(APP) $(BUIDIR)/$(APP).app/Contents/MacOS/$(APP)
echo -n 'APPL????' > $(BUIDIR)/$(APP).app/Contents/PkgInfo
.PHONY: all clean linking osx
.SILENT: $(BUIDIR)/ $(OBJDIR)/
Upvotes: 7