Problem Linking with custom GLFW Install on Fedora 34 running X11

Short explanation:

Getting /usr/bin/ld.gold: error: cannot find -lglfw. Linker can’t find my custom glfw install even though I added export LD_LIBRARY_PATH=/usr/local:${LD_LIBRARY_PATH} to ~/.bashrc and ran source on it.

Advice welcome

Been banging my head against the keyboard from this problem for a little while now. Any suggestions would be much appricated. Have a feeling maybe chaning a makefile would fix this but I’m more farmilar with cmake and not really sure where to start chaning things in the openFrameworks makefiles.

Long explaination:

Runninng x11 on Fedora 34 because as far as I know you need to be running x11 for nvidia drivers to work. The GLFW package on Fedora 34 is compiled with the intention of being run on wayland because that’s the default on Fedora 34. So here’s the steps I followed to try to fix this problem.

Initial Bug

Ran install_codecs.sh and install_dependencies.sh from fedora folder.

Then ran ./compileOF.sh without problems

The first error I was getting: (See first error in first comment on this thread. I exceeded the character limit.)

Trying again with custom build of GLFW

I realized the x11 wayland problem after some duckduckgoing.

So I first followed instructions to make x11 the default session. Configuring Xorg as the default GNOME session :: Fedora Docs

After that I rebooted and ran sudo dnf remove glfw glfw-devel

Then I did a manual install of glfw from source the steps for that were:

  1. download source from Download | GLFW
  2. unzip
  3. mkdir cmake-build
  4. cd cmake-build
  5. cmake -DBUILD_SHARED_LIBS=ON ..
  6. make
  7. sudo cmake -P cmake_install.cmake

The output was:

(base) [duskvirkus@fedora cmake-build]$ sudo cmake -P cmake_install.cmake 
-- Install configuration: ""
-- Up-to-date: /usr/local/include/GLFW
-- Installing: /usr/local/include/GLFW/glfw3.h
-- Installing: /usr/local/include/GLFW/glfw3native.h
-- Installing: /usr/local/lib64/cmake/glfw3/glfw3Config.cmake
-- Installing: /usr/local/lib64/cmake/glfw3/glfw3ConfigVersion.cmake
-- Installing: /usr/local/lib64/cmake/glfw3/glfw3Targets.cmake
-- Installing: /usr/local/lib64/cmake/glfw3/glfw3Targets-noconfig.cmake
-- Installing: /usr/local/lib64/pkgconfig/glfw3.pc
-- Installing: /usr/local/lib64/libglfw.so.3.3
-- Installing: /usr/local/lib64/libglfw.so.3
-- Installing: /usr/local/lib64/libglfw.so

Then I added export LD_LIBRARY_PATH=/usr/local:${LD_LIBRARY_PATH} to ~/.bashrc and ran source ~/.bashrc. This was after another install attempt and more duckduckgoing about installing glfw on linux.

You can see it worked.

(base) [duskvirkus@fedora linux]$ echo $LD_LIBRARY_PATH
/usr/local:/usr/local/lib:

Deleted my previous version of openFrameworks and started fresh with a new unzip. Didn’t run install_codecs.sh and install_dependencies.sh. But did run compileOF.sh. And got the following bug when running compilePG.sh. Same problem when running buildAllExamples.sh.

(See second error in second comment on this thread. I exceeded the character limit.)

(base) [duskvirkus@fedora linux]$ ./compilePG.sh
make: Entering directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine'
Compiling OF library for Release
make[1]: Entering directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/project'
Done!
make[1]: Leaving directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/project'

Compiling projectGenerator for Release
make[1]: Entering directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine'
Linking bin/projectGenerator for linux64
g++ -o bin/projectGenerator  obj/linux64/Release/src/main.o obj/linux64/Release/src/ofApp.o  /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/obj/linux64/Release/ofxPoco/src/ofxXmlPoco.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/addons/ofAddon.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/utils/LibraryBinary.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/utils/Utils.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/androidStudioProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/baseProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/qtcreatorproject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/CBWinProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/visualStudioProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/CBLinuxProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/xcodeProject.o  /home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoJSON.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoEncodings.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoXML.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoRedis.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoCrypto.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoNet.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoFoundation.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoNetSSL.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoZip.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoUtil.a  -Wl,-rpath=./libs:./bin/libs -Wl,--as-needed -Wl,--gc-sections -fuse-ld=gold -L/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/fmod/lib/linux64/ -lfmod -lPocoNetSSL -lPocoNet -lPocoCrypto -lPocoUtil -lPocoXML -lPocoFoundation -lcrypto -lssl /home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/kiss/lib/linux64/libkiss.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/tess2/lib/linux64/libtess2.a -lz -lgstapp-1.0 -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -ludev -lfontconfig -lfreetype -lsndfile -lopenal -lcurl -lglfw -L/usr/lib -lrtaudio -lpulse-simple -lpulse -lasound -lGLEW -lGLU -lGL -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lmpg123  -lglut -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -ldl -lpthread -lfreeimage -lboost_filesystem -lboost_system -lpugixml -luriparser -lXinerama
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setFullscreen(bool) [clone .part.0]: error: undefined reference to 'glfwGetX11Window'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setFullscreen(bool) [clone .part.0]: error: undefined reference to 'glfwGetX11Display'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setWindowIcon(ofPixels_<unsigned char> const&): error: undefined reference to 'glfwGetX11Display'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setWindowIcon(ofPixels_<unsigned char> const&): error: undefined reference to 'glfwGetX11Window'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setWindowIcon(ofPixels_<unsigned char> const&): error: undefined reference to 'glfwGetX11Display'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setWindowIcon(ofPixels_<unsigned char> const&): error: undefined reference to 'glfwGetX11Display'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setup(ofGLFWWindowSettings const&): error: undefined reference to 'glfwGetX11Window'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::setup(ofGLFWWindowSettings const&): error: undefined reference to 'glfwGetX11Window'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::getGLXContext(): error: undefined reference to 'glfwGetGLXContext'
collect2: error: ld returned 1 exit status
make[1]: *** [/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:405: bin/projectGenerator] Error 1
make[1]: Leaving directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine'
make: *** [/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:129: Release] Error 2
make: Leaving directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine'
There has been a problem compiling the command line projectGenerator.
Please report this problem in the forums.
Linking bin/projectGenerator for linux64
g++ -o bin/projectGenerator  obj/linux64/Release/src/main.o obj/linux64/Release/src/ofApp.o  /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/obj/linux64/Release/ofxPoco/src/ofxXmlPoco.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/addons/ofAddon.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/utils/LibraryBinary.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/utils/Utils.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/androidStudioProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/baseProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/qtcreatorproject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/CBWinProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/visualStudioProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/CBLinuxProject.o /home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine/obj/linux64/Release/addons/ofxProjectGenerator/src/projects/xcodeProject.o  /home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoJSON.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoEncodings.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoXML.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoRedis.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoCrypto.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoNet.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoFoundation.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoNetSSL.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoZip.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/addons/ofxPoco/libs/poco/lib/linux64/libPocoUtil.a  -Wl,-rpath=./libs:./bin/libs -Wl,--as-needed -Wl,--gc-sections -fuse-ld=gold -L/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/fmod/lib/linux64/ -lfmod -lPocoNetSSL -lPocoNet -lPocoCrypto -lPocoUtil -lPocoXML -lPocoFoundation -lcrypto -lssl /home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/kiss/lib/linux64/libkiss.a /home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/tess2/lib/linux64/libtess2.a -lz -lgstapp-1.0 -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -ludev -lfontconfig -lfreetype -lsndfile -lopenal -lcurl -lglfw -L/usr/lib -lrtaudio -lpulse-simple -lpulse -lasound -lGLEW -lGLU -lGL -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lmpg123  -lglut -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -ldl -lpthread -lfreeimage -lboost_filesystem -lboost_system -lpugixml -luriparser -lXinerama
/usr/bin/ld.gold: error: cannot find -lglfw
...
# output abridged
...
ofAppGLFWWindow::iconify(bool): error: undefined reference to 'glfwIconifyWindow'
/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a(ofAppGLFWWindow.o):ofAppGLFWWindow.cpp:function ofAppGLFWWindow::iconify(bool): error: undefined reference to 'glfwRestoreWindow'
collect2: error: ld returned 1 exit status
make[1]: *** [/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:405: bin/projectGenerator] Error 1
make[1]: Leaving directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine'
make: *** [/home/duskvirkus/of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:129: Release] Error 2
make: Leaving directory '/home/duskvirkus/of_v0.11.2_linux64gcc6_release/apps/projectGenerator/commandLine'
There has been a problem compiling the command line projectGenerator.
Please report this problem in the forums.

Running into the same thing. I’m tinkering with the makefiles, trying to force it to find glfw in /usr/local/lib64, but no luck so far.

The solution to this was to add the path to the additional libraries in the platform makefile.

In of_v0.11.2_linux64gcc6_release/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk, line 431, I had to add:
PLATFORM_LIBRARY_SEARCH_PATHS = /usr/local/lib64 for glfw3 and PLATFORM_LIBRARY_SEARCH_PATHS += /usr/local/boost_1_69_0/install/lib for boost. For some reason, the system boost (1.75) was causing a linker error with the cxx11 abi tag, and I already had 1.69 built from source, which worked fine.

Thanks for letting me know! I’ll have to give it a shot sometime in the next few days and see if it works for me.