Makefiles based codeblocks project for 007?

The makefile system is now really mature and easy to use:

  • If you want to add an addon, just put it in your addons folder and in your project add a line with it’s name in the addons.make file

  • To add search paths, just open config.make, and in USER_CFLAGS add:
    USER_CFLAGS = -Ipath1 -Ipath2

for each path, being a text file is much easier to edit than codeblocks options where you have to put things one by one. if you want to go fancy you can even do things like:
USER_CFLAGS = -I$(shell ls path -d)

to add all the directories inside path to the search paths

  • To add libraries the process is more or less the same:
    USER_LIBS = libs/libsomething.a libs/libanother.a

where libs is a folder inside your project

  • You can also put your projects wherever you want (not only in apps/*/project by modifying the OF_ROOT variable to the absolute path of the openFrameworks folder.

  • Since most IDEs have support for compiling with custom makefiles it makes easy to use any other compiler, like:

codelite: http://forum.openframeworks.cc/t/codelite-template/5940/0
eclipse: http://forum.openframeworks.cc/t/using-of-from-eclipse/5921/0

  • It makes importing projects from other platforms way easier, you don’t need to deal with cb horrible way of adding files, if you just want to test a project, copy any of the makefiles (all are exactly the same) and cbp (they’ll be the same except for the name of the file and internally the name of the project), add any search paths or addons to config.make and addons.make and it will work

  • Old projects won’t break with new versions of OF, just copy the new makefile to your old project and that’s it

If you want to test it emptyExample_linux64.cbp is working like that now, the config.make and addons.make files are in a build config folder in the codeblocks project. You can use it with linux32 too since the makefile is multiplatform

Arturo, this are a excellent news! This means openFramework could be IDE independent on unix based systems. Isn´t?! Thanks for all your hard work.

I just one question. I´m not getting ofxOsc addon to compile properly on Ubuntu 11.04.

This is my config.make

  
  
# add custom variables to this file  
  
# OF_ROOT allows to move projects outside apps/* just set this variable to the  
# absoulte path to the OF root folder  
  
OF_ROOT = ../../..  
  
  
# USER_CFLAGS allows to pass custom flags to the compiler  
# for example search paths like:  
# USER_CFLAGS = -I src/objects  
  
#USER_CFLAGS = -I $(shell ls ../../../addons/ofxOsc/libs/oscpack/include -d)  
USER_CFLAGS = -I../../../addons/ofxOsc/libs/oscpack/include/ip -I../../../addons/ofxOsc/libs/oscpack/include/osc  
  
# USER_LDFLAGS allows to pass custom flags to the linker  
# for example libraries like:  
# USER_LD_FLAGS = libs/libawesomelib.a  
  
USER_LD_FLAGS =  ../../../addons/ofxOsc/libs/oscpack/lib/linux/liboscpack.a  
  
# use this to add system libraries for example:  
# USER_LIBS = -lpango  
  
USER_LIBS =  
  
  
# change this to add different compiler optimizations to your project  
  
LINUX_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os  
  
ANDROID_COMPILER_OPTIMIZATION = -Os  
  
  
# you shouldn't need to change this for usual OF apps, it allows to include code from other directories  
# useful if you need to share a folder with code between 2 apps. The makefile will search recursively  
# you can only set 1 path here  
  
USER_SOURCE_DIR =  
  
# you shouldn't need to change this for usual OF apps, it allows to exclude code from some directories  
# useful if you have some code for reference in the project folder but don't want it to be compiled  
  
EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj"  
  

This is the error message

  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `ofxOscSender::sendBundle(ofxOscBundle&)':  
ofxOscSender.cpp:(.text+0x125): undefined reference to `osc::OutboundPacketStream::OutboundPacketStream(char*, unsigned long)'  
ofxOscSender.cpp:(.text+0x155): undefined reference to `osc::OutboundPacketStream::Size() const'  
ofxOscSender.cpp:(.text+0x165): undefined reference to `osc::OutboundPacketStream::Data() const'  
ofxOscSender.cpp:(.text+0x17f): undefined reference to `UdpSocket::Send(char const*, int)'  
ofxOscSender.cpp:(.text+0x18d): undefined reference to `osc::OutboundPacketStream::~OutboundPacketStream()'  
ofxOscSender.cpp:(.text+0x1ab): undefined reference to `osc::OutboundPacketStream::~OutboundPacketStream()'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `ofxOscSender::sendMessage(ofxOscMessage&)':  
ofxOscSender.cpp:(.text+0x20b): undefined reference to `osc::OutboundPacketStream::OutboundPacketStream(char*, unsigned long)'  
ofxOscSender.cpp:(.text+0x213): undefined reference to `osc::BeginBundleImmediate'  
ofxOscSender.cpp:(.text+0x221): undefined reference to `osc::OutboundPacketStream::operator<<(osc::BundleInitiator const&)'  
ofxOscSender.cpp:(.text+0x24b): undefined reference to `osc::EndBundle'  
ofxOscSender.cpp:(.text+0x259): undefined reference to `osc::OutboundPacketStream::operator<<(osc::BundleTerminator const&)'  
ofxOscSender.cpp:(.text+0x267): undefined reference to `osc::OutboundPacketStream::Size() const'  
ofxOscSender.cpp:(.text+0x277): undefined reference to `osc::OutboundPacketStream::Data() const'  
ofxOscSender.cpp:(.text+0x291): undefined reference to `UdpSocket::Send(char const*, int)'  
ofxOscSender.cpp:(.text+0x29f): undefined reference to `osc::OutboundPacketStream::~OutboundPacketStream()'  
ofxOscSender.cpp:(.text+0x2bd): undefined reference to `osc::OutboundPacketStream::~OutboundPacketStream()'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `ofxOscSender::appendBundle(ofxOscBundle&, osc::OutboundPacketStream&)':  
ofxOscSender.cpp:(.text+0x2e4): undefined reference to `osc::BeginBundleImmediate'  
ofxOscSender.cpp:(.text+0x2ef): undefined reference to `osc::OutboundPacketStream::operator<<(osc::BundleInitiator const&)'  
ofxOscSender.cpp:(.text+0x38b): undefined reference to `osc::EndBundle'  
ofxOscSender.cpp:(.text+0x396): undefined reference to `osc::OutboundPacketStream::operator<<(osc::BundleTerminator const&)'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `ofxOscSender::appendMessage(ofxOscMessage&, osc::OutboundPacketStream&)':  
ofxOscSender.cpp:(.text+0x3e0): undefined reference to `osc::OutboundPacketStream::operator<<(osc::BeginMessage const&)'  
ofxOscSender.cpp:(.text+0x47c): undefined reference to `osc::OutboundPacketStream::operator<<(float)'  
ofxOscSender.cpp:(.text+0x4d3): undefined reference to `osc::OutboundPacketStream::operator<<(char const*)'  
ofxOscSender.cpp:(.text+0x529): undefined reference to `osc::EndMessage'  
ofxOscSender.cpp:(.text+0x534): undefined reference to `osc::OutboundPacketStream::operator<<(osc::MessageTerminator const&)'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `osc::OutboundPacketStream::operator<<(int)':  
ofxOscSender.cpp:(.text._ZN3osc20OutboundPacketStreamlsEi[osc::OutboundPacketStream::operator<<(int)]+0x14): undefined reference to `osc::OutboundPacketStream::operator<<(long)'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `IpEndpointName::IpEndpointName(char const*, int)':  
ofxOscSender.cpp:(.text._ZN14IpEndpointNameC2EPKci[_ZN14IpEndpointNameC5EPKci]+0xd): undefined reference to `IpEndpointName::GetHostByName(char const*)'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `UdpTransmitSocket::UdpTransmitSocket(IpEndpointName const&)':  
ofxOscSender.cpp:(.text._ZN17UdpTransmitSocketC2ERK14IpEndpointName[_ZN17UdpTransmitSocketC5ERK14IpEndpointName]+0xe): undefined reference to `UdpSocket::UdpSocket()'  
ofxOscSender.cpp:(.text._ZN17UdpTransmitSocketC2ERK14IpEndpointName[_ZN17UdpTransmitSocketC5ERK14IpEndpointName]+0x29): undefined reference to `UdpSocket::Connect(IpEndpointName const&)'  
ofxOscSender.cpp:(.text._ZN17UdpTransmitSocketC2ERK14IpEndpointName[_ZN17UdpTransmitSocketC5ERK14IpEndpointName]+0x38): undefined reference to `UdpSocket::~UdpSocket()'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o: In function `UdpTransmitSocket::~UdpTransmitSocket()':  
ofxOscSender.cpp:(.text._ZN17UdpTransmitSocketD2Ev[_ZN17UdpTransmitSocketD5Ev]+0x16): undefined reference to `UdpSocket::~UdpSocket()'  
obj/i686Release/addons/ofxOsc/src/ofxOscSender.o:(.rodata._ZTI17UdpTransmitSocket[typeinfo for UdpTransmitSocket]+0x8): undefined reference to `typeinfo for UdpSocket'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `ofxOscReceiver::ProcessMessage(osc::ReceivedMessage const&, IpEndpointName const&)':  
ofxOscReceiver.cpp:(.text+0x666): undefined reference to `IpEndpointName::AddressAsString(char*) const'  
ofxOscReceiver.cpp:(.text+0x700): undefined reference to `osc::ReceivedMessageArgument::AsInt32Unchecked() const'  
ofxOscReceiver.cpp:(.text+0x740): undefined reference to `osc::ReceivedMessageArgument::AsFloatUnchecked() const'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `osc::ReceivedBundleElementIterator::Advance()':  
ofxOscReceiver.cpp:(.text._ZN3osc29ReceivedBundleElementIterator7AdvanceEv[osc::ReceivedBundleElementIterator::Advance()]+0x1b): undefined reference to `osc::ReceivedBundleElement::Size() const'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `osc::ReceivedMessageArgumentIterator::operator++()':  
ofxOscReceiver.cpp:(.text._ZN3osc31ReceivedMessageArgumentIteratorppEv[osc::ReceivedMessageArgumentIterator::operator++()]+0x11): undefined reference to `osc::ReceivedMessageArgumentIterator::Advance()'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `osc::OscPacketListener::ProcessBundle(osc::ReceivedBundle const&, IpEndpointName const&)':  
ofxOscReceiver.cpp:(.text._ZN3osc17OscPacketListener13ProcessBundleERKNS_14ReceivedBundleERK14IpEndpointName[osc::OscPacketListener::ProcessBundle(osc::ReceivedBundle const&, IpEndpointName const&)]+0x30): undefined reference to `osc::ReceivedBundleElement::IsBundle() const'  
ofxOscReceiver.cpp:(.text._ZN3osc17OscPacketListener13ProcessBundleERKNS_14ReceivedBundleERK14IpEndpointName[osc::OscPacketListener::ProcessBundle(osc::ReceivedBundle const&, IpEndpointName const&)]+0x58): undefined reference to `osc::ReceivedBundle::ReceivedBundle(osc::ReceivedBundleElement const&)'  
ofxOscReceiver.cpp:(.text._ZN3osc17OscPacketListener13ProcessBundleERKNS_14ReceivedBundleERK14IpEndpointName[osc::OscPacketListener::ProcessBundle(osc::ReceivedBundle const&, IpEndpointName const&)]+0x94): undefined reference to `osc::ReceivedMessage::ReceivedMessage(osc::ReceivedBundleElement const&)'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `osc::OscPacketListener::ProcessPacket(char const*, int, IpEndpointName const&)':  
ofxOscReceiver.cpp:(.text._ZN3osc17OscPacketListener13ProcessPacketEPKciRK14IpEndpointName[osc::OscPacketListener::ProcessPacket(char const*, int, IpEndpointName const&)]+0x27): undefined reference to `osc::ReceivedPacket::IsBundle() const'  
ofxOscReceiver.cpp:(.text._ZN3osc17OscPacketListener13ProcessPacketEPKciRK14IpEndpointName[osc::OscPacketListener::ProcessPacket(char const*, int, IpEndpointName const&)]+0x47): undefined reference to `osc::ReceivedBundle::ReceivedBundle(osc::ReceivedPacket const&)'  
ofxOscReceiver.cpp:(.text._ZN3osc17OscPacketListener13ProcessPacketEPKciRK14IpEndpointName[osc::OscPacketListener::ProcessPacket(char const*, int, IpEndpointName const&)]+0x7b): undefined reference to `osc::ReceivedMessage::ReceivedMessage(osc::ReceivedPacket const&)'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `UdpListeningReceiveSocket::UdpListeningReceiveSocket(IpEndpointName const&, PacketListener*)':  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketC2ERK14IpEndpointNameP14PacketListener[_ZN25UdpListeningReceiveSocketC5ERK14IpEndpointNameP14PacketListener]+0xe): undefined reference to `UdpSocket::UdpSocket()'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketC2ERK14IpEndpointNameP14PacketListener[_ZN25UdpListeningReceiveSocketC5ERK14IpEndpointNameP14PacketListener]+0x25): undefined reference to `SocketReceiveMultiplexer::SocketReceiveMultiplexer()'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketC2ERK14IpEndpointNameP14PacketListener[_ZN25UdpListeningReceiveSocketC5ERK14IpEndpointNameP14PacketListener]+0x40): undefined reference to `UdpSocket::Bind(IpEndpointName const&)'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketC2ERK14IpEndpointNameP14PacketListener[_ZN25UdpListeningReceiveSocketC5ERK14IpEndpointNameP14PacketListener]+0x5f): undefined reference to `SocketReceiveMultiplexer::AttachSocketListener(UdpSocket*, PacketListener*)'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketC2ERK14IpEndpointNameP14PacketListener[_ZN25UdpListeningReceiveSocketC5ERK14IpEndpointNameP14PacketListener]+0x71): undefined reference to `SocketReceiveMultiplexer::~SocketReceiveMultiplexer()'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketC2ERK14IpEndpointNameP14PacketListener[_ZN25UdpListeningReceiveSocketC5ERK14IpEndpointNameP14PacketListener]+0x80): undefined reference to `UdpSocket::~UdpSocket()'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `UdpListeningReceiveSocket::~UdpListeningReceiveSocket()':  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketD2Ev[_ZN25UdpListeningReceiveSocketD5Ev]+0x2b): undefined reference to `SocketReceiveMultiplexer::DetachSocketListener(UdpSocket*, PacketListener*)'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketD2Ev[_ZN25UdpListeningReceiveSocketD5Ev]+0x39): undefined reference to `SocketReceiveMultiplexer::~SocketReceiveMultiplexer()'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketD2Ev[_ZN25UdpListeningReceiveSocketD5Ev]+0x44): undefined reference to `UdpSocket::~UdpSocket()'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketD2Ev[_ZN25UdpListeningReceiveSocketD5Ev]+0x6d): undefined reference to `SocketReceiveMultiplexer::~SocketReceiveMultiplexer()'  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocketD2Ev[_ZN25UdpListeningReceiveSocketD5Ev]+0x7c): undefined reference to `UdpSocket::~UdpSocket()'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `UdpListeningReceiveSocket::Run()':  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocket3RunEv[UdpListeningReceiveSocket::Run()]+0x10): undefined reference to `SocketReceiveMultiplexer::Run()'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o: In function `UdpListeningReceiveSocket::AsynchronousBreak()':  
ofxOscReceiver.cpp:(.text._ZN25UdpListeningReceiveSocket17AsynchronousBreakEv[UdpListeningReceiveSocket::AsynchronousBreak()]+0x10): undefined reference to `SocketReceiveMultiplexer::AsynchronousBreak()'  
obj/i686Release/addons/ofxOsc/src/ofxOscReceiver.o:(.rodata._ZTI25UdpListeningReceiveSocket[typeinfo for UdpListeningReceiveSocket]+0x8): undefined reference to `typeinfo for UdpSocket'  
collect2: ld returned 1 exit status  
make: *** [bin/TUIOkeys] Error 1  
  

Any idea why?
One more time thanks for you time.

update: I found a solution. I notice that the problem was that doesn´t load liboscpack.a And looking at the Makefile I didn´t find USER_LD_FLAGS so I added at the end of LIB_STATIC on Makefile:

  
LIB_STATIC = $(shell ls $(OF_ROOT)/libs/*/lib/$(LIBSPATH)/*.a  2> /dev/null | grep -v openFrameworksCompiled | grep -v Poco)  
LIB_SHARED = $(shell ls $(OF_ROOT)/libs/*/lib/$(LIBSPATH)/*.so  2> /dev/null | grep -v openFrameworksCompiled | sed "s/.*\\/lib\([^/]*\)\.so/-l\1/")  
LIB_STATIC += $(OF_ROOT)/libs/poco/lib/$(LIBSPATH)/libPocoNet.a ../../../libs/poco/lib/$(LIBSPATH)/libPocoXML.a ../../../libs/poco/lib/$(LIBSPATH)/libPocoUtil.a ../../../libs/poco/lib/$(LIBSPATH)/libPocoFoundation.a $(USER_LD_FLAGS)  
LIB_PATHS_FLAGS = $(shell ls -d $(OF_ROOT)/libs/*/lib/$(LIBSPATH) | sed "s/\(\.*\)/-L\1/")  
  

It compiles but I´m not sure if it´s the best way of doing it
Any way thanks! Makefile it´s awesome

you just need to edit addons.make and add a line for each addon that you want to use, take a look at addons.make in the osc examples. With addons that comply with the standard file system distribution there’s no need for search paths or library config in the makefile.

[quote=“patriciogonzalezvivo, post:2, topic:5976”]
This means openFramework could be IDE independent on unix based systems.[/quote]
yes! and this is the reason for voting yes! thanks arturo!

[quote=“benben, post:4, topic:5976”]

that’s great! but… there’s something I don’t understand: if I run ‘make’ from command line, my project is built and I can run it from shell; if I want to modify and compile it in code::blocks, I get makefile error (“no rules for make target” or something similar…) what’s going wrong?

(I’m sorry for this dummy question, I’m not so good in c/c++ programming)

maui

ps. I’m on kubuntu 11.04 (2.6.38-8-generic kernel) with code::blocks 10.05

are you using the version from github? have you run the createProjects.py script as it’s explained in the readme.txt file?

hi Arturo, thanks for your quick response!
I solved: it was a bad code::bloks’ configuration in Project > Properties > Makefile (file name was makefile instead of Makefile )

thanks and sorry again, bye
m.

ps. yes, I’m using version cec0549 from github because of videodev problem

oh, thanks, didn’t realized about that it’s fixed now in the repo

@patriciogonzalezvivo About the USER_LD_FLAGS not working. I found that in the Makefile there is actually a USER_LDFLAGS. So if you change your config to that, it will work as expected.

oops, thanks, i was totally convinced of having fixed that one : )

it’s in the main repo now too

Just moved to 007 and loving the makefile-basedness of it all! Just one question: do you guys have auto-completion working for the of-libs? I created a test project with createProjects.py and CB will only auto-complete of*-commands that have already been entered. Can’t find the spot where this should go in CB. Any advice?

have you tried opening the workspace instead of the cbp so it opens also the openFrameworks project?

That indeed solves the problem. Thanks :slight_smile:

I’m just curious. Would it also be possible to have an optional config.make for addons to link a system library for example? I guess it’s doable (then again, I don’t know too much about the makefiels yet…), but does it also make sense?

The reason, I’m asking this: for ofxFenster, there’s a need to link -lX11 on 32 bit. Since the Xlib can’t be provided with the addon, I had to add the linker to the config.make of the example project. This is ok but it also means, if you want to use the addon, you’d have to check the example to see why it’s not compiling, instead of just adding ofxFenster to addons.make.