Jump to content
  • Advertisement
Sign in to follow this  
wood_brian

Switching to newer compiler on OSX

This topic is 2497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a PPC G4 that has OSX 10.5.8 on it. Iirc, there isn't a newer version of OSX for this hardware. Gcc 4.2.1 is installed and I'd like to figure out how to install a more recent C++ compiler on the machine. I hope to stick with OSX on this machine, but if that doesn't work out, I'll consider a different OS. Thoughts? Tia.

Share this post


Link to post
Share on other sites
Advertisement
To expand upon my post above:

Clang works exceptionally well on OS-X, its actually one of the default choices for xcode if you so choose. The compiler is written in C++ and is quite mature considering how new it is. It has most C++11 support, but not everything that the latest GCC build does. Its error messages are, quite literally, a century or more ahead of GCC in clarity AND usefulness. It has extensive static-analysis options which can easily point out trivial bugs that are commonly encountered in code. Clang is ALSO designed to be easily extended and/or embedded for use in tools and other applications, unlike GCC which was intentionally developed to be hard to use in that fashion.

Share this post


Link to post
Share on other sites
OK, I've downloaded it and it's building. Now I'd like to find out about porting this makefile to use clang


CPPFLAGS= -std=c++0x -O3 -s -Wreorder -W -Wall -I. -DMAKEFILES -DSYSLOG_AVAILABLE

CC=g++
AR=ar
LIBS=-L./ -L/usr/lib

all: libhome.a cmwAmbassador direct

get_socket.o: get_socket.hh
common_functions.o: common_functions.hh
server_functionsTCP.o: server_functionsTCP.hh
server_functionsUDP.o: server_functionsUDP.hh
marshalling_integer.o: marshalling_integer.hh
quicklz.o: quicklz.h
Counter.o: Counter.hh
IO.o: IO.hh
SendBuffer.o: SendBuffer.hh
SendBufferCompressed.o: SendBufferCompressed.hh
SendBufferFile.o: SendBufferFile.hh
File.o: File.hh
FILEWrapper.o: FILEWrapper.hh
objects = get_socket.o common_functions.o server_functionsTCP.o server_functionsUDP.o marshalling_integer.o quicklz.o Counter.o IO.o SendBuffer.o SendBufferCompressed.o SendBufferFile.o File.o FILEWrapper.o

libhome.a: $(objects)
ar r $@ $(objects)

cmw_user_input.o: cmw_user_input.hh
cmwa_config_data.o: cmwa_config_data.hh
local_messages_middle.cg.o: local_messages_middle.cg.hh
remote_messages_middle.cg.o: remote_messages_middle.cg.hh
amb_objects = cmw_user_input.o cmwa_config_data.o local_messages_middle.cg.o remote_messages_middle.cg.o

cmwAmbassador: cmwAmbassador.cc cmwAmbassador.hh $(amb_objects) libhome.a
g++ -o $@ $(CPPFLAGS) cmwAmbassador.cc $(amb_objects) libhome.a
ls -l $@

local_messages_front.cg.o: local_messages_front.cg.hh

direct: direct.cc local_messages_front.cg.o libhome.a
g++ -o $@ $(CPPFLAGS) direct.cc local_messages_front.cg.o libhome.a
ls -l $@


Tia.

Share this post


Link to post
Share on other sites


CPPFLAGS= -std=c++0x -O3 -s -Wreorder -W -Wall -I. -DMAKEFILES -DSYSLOG_AVAILABLE
CC=g++
AR=ar
LIBS=-L./ -L/usr/lib


You define a bunch of nice variables here, but you don't actually use several of them them in your make file.



all: libhome.a cmwAmbassador direct

get_socket.o: get_socket.hh
common_functions.o: common_functions.hh
server_functionsTCP.o: server_functionsTCP.hh
server_functionsUDP.o: server_functionsUDP.hh
marshalling_integer.o: marshalling_integer.hh
quicklz.o: quicklz.h
Counter.o: Counter.hh
IO.o: IO.hh
SendBuffer.o: SendBuffer.hh
SendBufferCompressed.o: SendBufferCompressed.hh
SendBufferFile.o: SendBufferFile.hh
File.o: File.hh
FILEWrapper.o: FILEWrapper.hh
objects = get_socket.o common_functions.o server_functionsTCP.o server_functionsUDP.o marshalling_integer.o quicklz.o Counter.o IO.o SendBuffer.o SendBufferCompressed.o SendBufferFile.o File.o FILEWrapper.o

[/quote]
You define a bunch of objects, and their dependencies, but don't actually build them...


libhome.a: $(objects)
ar r $@ $(objects)

[/quote]
Didn't use AR variable


cmw_user_input.o: cmw_user_input.hh
cmwa_config_data.o: cmwa_config_data.hh
local_messages_middle.cg.o: local_messages_middle.cg.hh
remote_messages_middle.cg.o: remote_messages_middle.cg.hh
amb_objects = cmw_user_input.o cmwa_config_data.o local_messages_middle.cg.o remote_messages_middle.cg.o

[/quote]
More random objects


cmwAmbassador: cmwAmbassador.cc cmwAmbassador.hh $(amb_objects) libhome.a
g++ -o $@ $(CPPFLAGS) cmwAmbassador.cc $(amb_objects) libhome.a
ls -l $@

[/quote]
Not using CC variable


local_messages_front.cg.o: local_messages_front.cg.hh

[/quote]
more random objects

direct: direct.cc local_messages_front.cg.o libhome.a
g++ -o $@ $(CPPFLAGS) direct.cc local_messages_front.cg.o libhome.a
ls -l $@

[/quote]
Again, not using CC variable.

Share this post


Link to post
Share on other sites
Here's a modified version.


CPPFLAGS= -std=c++0x -O3 -s -Wreorder -W -Wall -I. -DMAKEFILES -DSYSLOG_AVAILABLE

CC=g++
AR=ar
LIBS=-L./ -L/usr/lib

all: libhome.a cmwAmbassador direct

get_socket.o: get_socket.hh
common_functions.o: common_functions.hh
server_functionsTCP.o: server_functionsTCP.hh
server_functionsUDP.o: server_functionsUDP.hh
marshalling_integer.o: marshalling_integer.hh
quicklz.o: quicklz.h
Counter.o: Counter.hh
IO.o: IO.hh
SendBuffer.o: SendBuffer.hh
SendBufferCompressed.o: SendBufferCompressed.hh
SendBufferFile.o: SendBufferFile.hh
File.o: File.hh
FILEWrapper.o: FILEWrapper.hh
objects = get_socket.o common_functions.o server_functionsTCP.o server_functionsUDP.o marshalling_integer.o quicklz.o Counter.o IO.o SendBuffer.o SendBufferCompressed.o SendBufferFile.o File.o FILEWrapper.o

libhome.a: $(objects)
$(AR) r $@ $(objects)

cmw_user_input.o: cmw_user_input.hh
cmwa_config_data.o: cmwa_config_data.hh
local_messages_middle.cg.o: local_messages_middle.cg.hh
remote_messages_middle.cg.o: remote_messages_middle.cg.hh
amb_objects = cmw_user_input.o cmwa_config_data.o local_messages_middle.cg.o remote_messages_middle.cg.o

cmwAmbassador: cmwAmbassador.cc cmwAmbassador.hh $(amb_objects) libhome.a
$(CC) -o $@ $(CPPFLAGS) cmwAmbassador.cc $(amb_objects) libhome.a
ls -l $@

local_messages_front.cg.o: local_messages_front.cg.hh

direct: direct.cc local_messages_front.cg.o libhome.a
$(CC) -o $@ $(CPPFLAGS) direct.cc local_messages_front.cg.o libhome.a
ls -l $@



The files all get built based on dependencies. Now I'm interested in how to port this to clang.

Share this post


Link to post
Share on other sites
FINAL-ARCHIVE: clang_darwin/profile_ios: /Users/Admin/direct/clang/build/tools/clang/runtime/compiler-rt/clang_darwin/profile_ios/libcompiler_rt.a
MKDIR: /Users/Admin/direct/clang/build/tools/clang/runtime/compiler-rt/clang_darwin/asan_osx/i386/SubDir.lib__asan
COMPILE: clang_darwin/asan_osx/i386: /Users/Admin/direct/clang/llvm/projects/compiler-rt/lib/asan/asan_allocator.cc
COMPILE: clang_darwin/asan_osx/i386: /Users/Admin/direct/clang/llvm/projects/compiler-rt/lib/asan/asan_globals.cc
COMPILE: clang_darwin/asan_osx/i386: /Users/Admin/direct/clang/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc
In file included from /Users/Admin/direct/clang/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:19:
/Users/Admin/direct/clang/llvm/projects/compiler-rt/lib/asan/asan_mac.h:22:10: fatal error:
'dispatch/dispatch.h' file not found
#include <dispatch/dispatch.h>
^
1 error generated.
make[5]: *** [/Users/Admin/direct/clang/build/tools/clang/runtime/compiler-rt/clang_darwin/asan_osx/i386/SubDir.lib__asan/asan_interceptors.o] Error 1
make[4]: *** [BuildRuntimeLibraries] Error 2
make[3]: *** [compiler-rt/.makeall] Error 2
make[2]: *** [all] Error 1
make[1]: *** [clang/.makeall] Error 2
make: *** [all] Error 1


After about 3 hours of building I got that. Haven't checked yet what was built, but the version I got may have a problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!