Skip to content

ofUtils: don't link the renderer / ofImage / app into tools that only use ofUtils (Linux depends) - #8605

Open
danoli3 wants to merge 1 commit into
openframeworks:masterfrom
danoli3:core-deps-ofutils
Open

danoli3 wants to merge 1 commit into
openframeworks:masterfrom
danoli3:core-deps-ofutils

Conversation

@danoli3

@danoli3 danoli3 commented Oct 25, 2026

Copy link
Copy Markdown
Member

Linking only ofUtils (e.g. ofGetElapsedTimef, string / file helpers) from libopenFrameworks.a pulled in most of the core, and on Linux every system library behind it. A static library links whole object files:

  • ofUtils.o: ofSaveScreen / ofSaveViewport / ofSaveFrame -> ofGetGLRenderer() + ofSaveImage() -> GL renderer, fonts, FreeImage (-> OpenEXR)
  • ofUtils.o: ofSetTimeMode* / ofGetTimeMode -> ofGetMainLoop() -> ofAppGLFWWindow -> GLFW, X11, GL
  • ofUtils.o -> ofEvents.o (only for the clock listener's AbstractEventToken / StdFunctionId out-of-line dtors and nextId) -> ofEvents() -> ofAppRunner.o -> sound (OpenAL, libsndfile, mpg123), GStreamer, curl

That's why the Linux projectGenerator binary needs ~20 desktop libraries it never uses, and fails to start on distros with newer ones, e.g. Arch: libOpenEXR-3_3.so.32: cannot open shared object file (openframeworks/projectGenerator#639, #8472). The existing FIXME at the top of ofUtils.cpp asks for this split.

Moved, no API change (declarations stay in ofUtils.h):

  • ofSaveScreen / ofSaveViewport / ofSaveFrame -> ofGraphics.cpp
  • ofGetTimeMode / ofSetTimeModeSystem / ofSetTimeModeFixedRate / ofSetTimeModeFiltered -> ofAppRunner.cpp (they call the clock through two of::priv setters left in ofUtils.cpp)
  • AbstractEventToken, BaseFunctionId, StdFunctionId dtors = default and StdFunctionId::nextId inline static in ofEvent.h

projectGenerator commandLine on Linux (Ubuntu 24.04 arm64, current master, readelf -d NEEDED):

  • before: gstapp, gstvideo, gstbase, gstreamer, fontconfig, freetype, sndfile, openal, crypto, curl, glfw, GLEW, GL, X11, gobject, glib, mpg123, freeimage, pugixml, uriparser, stdc++, m, gcc_s, c
  • after: pugixml, uriparser, stdc++, gcc_s, c (only ofLog.o, ofFileUtils.o, ofUtils.o linked from the core)

Tested: core builds on Linux (make) and macOS (Xcode); a generated linux64 app with ofxGui builds and links; projectGenerator runs and generates linux64 / vs projects.

…that only use ofUtils (ofSaveScreen etc to ofGraphics.cpp, ofSetTimeMode* to ofAppRunner.cpp, event token / function id inline)
@danoli3

danoli3 commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

This should help unbind un-needed binary links and connections when not needed. Shall reduce final binary size if no functions used.

@danoli3

danoli3 commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

All-examples build: no regressions

Every desktop example (157: everything except android, ios, tvOS, gles) built with the makefiles in Release, with this PR (08ae1047a) and with its base (master a7ede0a5d).

Where This PR Base Broken by this PR
Local, macOS (Apple Silicon) ✅ 157/157 ✅ 157/157 none
CI, macOS (macos-latest) ✅ 157/157 ✅ 157/157 none
CI, Ubuntu 24.04 155/157 155/157 none

The CI side was a temporary workflow (run). It built each tree, then a compare job failed only on examples that build on the base but not with the PR. It's been removed again, so the PR is back to its single commit.

The two Linux failures are already on master and unrelated to this PR:

  • graphics/linesExample: std::sinf / std::cosf aren't in std with GCC.
  • input_output/pdfExample: ofBeginSaveScreenAsPDF / ofEndSaveScreenAsPDF aren't declared on Linux.

Issues and fixes for both are coming separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant