Build errors with openFrameworks:master from GitHub

I’d like to use the development version of openFrameworks from GitHub. First, because I need some of the recently added features. Second, because I want to submit a bug and the contribution guidelines ask to doublecheck against the development build to make sure the issue hasn’t already been fixed.

I’ve had no problems at all using the 0.8.4. version of OF in CB 13.12 on Windows 8 64-bit. I have forked/cloned the master branch from github, am even with the most recent commits and have made no changes to the folder structure. When I try to compile an emptyExample, I run into trouble with the OF libs. Every fix I try, leads to more problems, see my attemps below.

ATTEMPT 1 (7 errors)

Error: ofSoundStream.h => error: 'UINT_MAX' was not declared in this scope (x7)
Solution: #include <climits>

ATTEMPT 2 (1 error)

Error:  ..\..\..\libs\glew\lib\win_cb\glew32s.lib||No such file or directory
Solution: copy glew32s.lib from libs\glew\lib\vs\ to libs\glew\lib\win_cb\

ATTEMPT 3 (21 errors)

obj\Release\src\main.o:main.cpp:(.text$_ZN17ofBaseSoundOutput8audioOutER13ofSoundBuffer[__ZN17ofBaseSoundOutput8audioOutER13ofSoundBuffer]+0x40)||undefined reference to `ofSoundBuffer::operator[](unsigned int)'|
obj\Release\src\main.o:main.cpp:(.text$_ZN16ofBaseSoundInput7audioInER13ofSoundBuffer[__ZN16ofBaseSoundInput7audioInER13ofSoundBuffer]+0x40)||undefined reference to `ofSoundBuffer::operator[](unsigned int)'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::ofMainLoop()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::run(std::tr1::shared_ptr<ofBaseApp>)'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::loop()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::run(std::tr1::shared_ptr<ofAppBaseWindow>, std::tr1::shared_ptr<ofBaseApp>)'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::createWindow(ofWindowSettings const&)'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::createWindow(ofWindowSettings const&)'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::setEscapeQuitsLoop(bool)'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentWindow()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentApp()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentWindow()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::shouldClose(int)'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentWindow()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentWindow()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentWindow()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentWindow()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::getCurrentWindow()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| more undefined references to `ofMainLoop::getCurrentWindow()' follow|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::loop()'|
..\..\..\libs\openFrameworksCompiled\lib\win_cb\openFrameworks.lib(ofAppRunner.o):ofAppRunner.cpp|| undefined reference to `ofMainLoop::events()'|

So I would really appreciate some help with a more structural solution…

With your last one, it looks like code::blocks isn’t picking up on the new .cpp files in OF 0.9.0. Namely, ofSoundBuffer.cpp and ofMainLoop.cpp. If you add those files to the internal OF code::blocks project (along with all the other OF files like ofFbo.cpp, ofEvents.cpp etc…) it should fix those errors.

We’d appreciate a pull request on the github repo that gets the code::blocks files in order as well!

Thanks for your reply. I added those two files. I am applying these fixes in a separate branch to submit a pull request at some point for the github repo. After applying all the fixes mentioned so far, I did a complete rebuild and all the previous errors are gone. Definite progress!

However I get another more compiler-related error. There is C++ 11 code in the new OF files. So to compile these I must turn on “Have g++ follow the C++ 11 ISO C++ language standard” in CB’s compiler settings. Then the mentioned code compiles, but I get the following two errors:

ofUtils.cpp|800|error: '_popen' was not declared in this scope
ofUtils.cpp|817|error: '_pclose' was not declared in this scope

This issue has been mentioned on the forum before here and here, but without a working solution. A dirty workaround I found is to switch back-and-forth between compiler settings while building. Another workaround is to add -U__STRICT_ANSI__ to CB’s Settings > Compiler > Other options. But neither are structural solutions in the source code itself. Is there an alternative for _popen and _pclose that is compatible with C++ 11 compilation (in Code::Blocks)?

Thoughts? Suggestions?

Edit
Some things I tried in the source code that didn’t solve the issue:

// adding any of the following lines to ofUtils.cpp

#include<stdio.h>
#define _XOPEN_SOURCE 400
#define _XOPEN_SOURCE 500
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700

All right, I have sent a pull request that fixes the issues here. I suppose the C++ 11 compilation problems are a different issue and for the time being I can use the strict ansi workaround.

it seems using: -std=gnu++11 instead of the default codeblocks c++11 adds support for popen. can you try if that works and send a PR if it does? that would make windows codeblocks c++11 compatible already.

Yes, that works indeed. Pull request sent! :smile: