Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for X11/Xlib.h path on NetBSD #242

Closed
wants to merge 1 commit into from

Conversation

hellium6
Copy link

Solves #241

@MoAlyousef
Copy link
Owner

MoAlyousef commented Jan 31, 2025

I'm reluctant to accept this since the problem here lies really with the BSD's.
It also won't work if someone has an older X11 version on netbsd.
Their recommended way is to set CFLAGS, CXXFLAGS and LDFLAGS when building against X11 for some reason.
See here for example:
https://github.com/MoAlyousef/dillo/blob/c3ad276b8cd8c347c70bfdb154b525311e3419a9/.github/workflows/cmake.yml#L131

FreeBSD installs X11 in /usr/local, netbsd and openbsd install it in /usr/X11R6 or /usr/X11R7. Even their docs instruct devs to set these global flags:
https://www.netbsd.org/docs/x/#compile_basic

@MoAlyousef MoAlyousef closed this Feb 6, 2025
@hellium6
Copy link
Author

hellium6 commented Feb 8, 2025

Doing export CXXFLAGS=-I/usr/X11R7/include before zig build on NetBSD makes the build complete

FreeBSD installs X11 in /usr/local, netbsd and openbsd install it in /usr/X11R6 or /usr/X11R7.

I looked at the build output with more attention and it seems cmake is able to find the path:

-- Found X11: /usr/X11R7/include
-- Looking for XOpenDisplay in /usr/X11R7/lib/libX11.so;/usr/X11R7/lib/libXext.so
-- Looking for XOpenDisplay in /usr/X11R7/lib/libX11.so;/usr/X11R7/lib/libXext.so - found
...
-- Build configuration      Release
-- Installation prefix      /tmp/mktemp.toHXKcuK/zig-out/cfltk/lib

When it fails I ran the command again and those X11 related lines are not there. It seems when cfltk/lib is being built X11 is not being looked for?

I lazily added some lines in zig-out/cfltk/CMakeLists.txt:

@@ -143,6 +143,11 @@ set(pc_libs_private "-lfltk")
 set(other_c_flags)
 
 if(CFLTK_LINK_IMAGES)
+  # test!
+  find_package(X11 REQUIRED)
+  link_libraries(${X11_LIBRARIES})
+  include_directories(${X11_INCLUDE_DIR})
+
   set(CFLTK_LIBS ${CFLTK_LIBS} fltk_images fltk_z fltk_jpeg fltk_png)
   string(APPEND pc_libs_private
          " -lfltk_images -lfltk_z -lfltk_jpeg -lfltk_png")

And it no longer shows the file missing error!

I deleted zig-out/cfltk/lib, commented link_libraries line and ran the build again. It completed.

So I think this is the real cause. It needs to look for X11 for lib build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants