-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Compilation issues with single file builds (Unity Builds) #2561
Comments
Just to give a bit more info. I have tried to undefine the 4 NULL functions to no avail. I'm using GCC 13.2 ( MinGWx64 ) on windows. Windows 10 Home 22H2 EDIT : |
I compile GLFW in Windows with the files added manually to my project, including the Could you report the errors you are seeing when you include the Note that when compiling GLFW manually there are a number of compile options you need to set, these are generated in |
Yes, I am using the #define _GLFW_WIN32. I'm not making a DLL so the other define has no baring on this problem. I did report the problem when I DO include those 4 NULL files. Older versions 3.8.8 and 3.3.10 work fine as I posted in my original post. So this problem is with the NULL being required... Here is the error if I do NOT add the NULL files. glfw-3.4\src\platform.c:79 undefined reference to _glfwConnectNull If I ADD the 4 required NULL files, then as my original post shows, I get redefine errors for those 4 functions. Only way I found around it is for me to just block them out in the null_windows.c file. I can't even undefine them. |
Which four functions? Could you paste the output error message text from your compile? Re-reading your initial post I realise you are literally GLFW does not currently support Unity Builds, so this will fail. You should include the source files one by one in your build script/system. There was a PR for re-naming functions so unity build would work, but for some reason the author closed it. |
Just dawned on me that you are talking about adding files within a file, (UNITY BUILD) kind of like the library RAYLIB does. I have done the same thing with all previous versions of GLFW without problems. The latest 3.4 release version however is different. Since you no longer are supporting that, then I will just edit the files anytime I update to get it to work. Sorry to waste your time. |
I've reopened this issue as single file (Unity Build) is something we probably should support, it's just that we do not do so explicitly at the moment (so the fact that it worked in the past was a happy accident). Could you post the error message you get when compiling or the names of the four function names which clash? If you don't have that information to hand then do not worry as we can easily figure that out once I take a look at this issue, but it would speed things up. |
I ran into this same issue yesterday and a simple fix is to redefine conflicting names and include the null platform in the build. I think you would need to do a similar thing if you were compiling with both X11/Wayland for Linux. For reference this is how I build it as part of a unity build: /***** GLFW *****/
// Enable extensions, mostly because GLFW uses ppoll
// and doesn't do this before they include poll.h
#define _GNU_SOURCE
#define _GLFW_X11
#include "dependencies/glfw-3.4/src/context.c"
#include "dependencies/glfw-3.4/src/egl_context.c"
#include "dependencies/glfw-3.4/src/glx_context.c"
#include "dependencies/glfw-3.4/src/init.c"
#include "dependencies/glfw-3.4/src/input.c"
#include "dependencies/glfw-3.4/src/linux_joystick.c"
#include "dependencies/glfw-3.4/src/monitor.c"
#include "dependencies/glfw-3.4/src/osmesa_context.c"
#include "dependencies/glfw-3.4/src/platform.c"
#include "dependencies/glfw-3.4/src/posix_module.c"
#include "dependencies/glfw-3.4/src/posix_poll.c"
#include "dependencies/glfw-3.4/src/posix_thread.c"
#include "dependencies/glfw-3.4/src/posix_time.c"
#include "dependencies/glfw-3.4/src/vulkan.c"
#include "dependencies/glfw-3.4/src/window.c"
#include "dependencies/glfw-3.4/src/wl_init.c"
#include "dependencies/glfw-3.4/src/wl_monitor.c"
#include "dependencies/glfw-3.4/src/wl_window.c"
#include "dependencies/glfw-3.4/src/x11_init.c"
#include "dependencies/glfw-3.4/src/x11_monitor.c"
#include "dependencies/glfw-3.4/src/x11_window.c"
#include "dependencies/glfw-3.4/src/xkb_unicode.c"
// we need to rename these functions as the "null" platform is
// always linked by platform.c and it defines some static
// functions that conflict with the ones in the other platforms
#define acquireMonitor acquireMonitorNull
#define releaseMonitor releaseMonitorNull
#define createNativeWindow createNativeWindowNull
#include "dependencies/glfw-3.4/src/null_init.c"
#include "dependencies/glfw-3.4/src/null_joystick.c"
#include "dependencies/glfw-3.4/src/null_monitor.c"
#include "dependencies/glfw-3.4/src/null_window.c"
#undef acquireMonitor
#undef releaseMonitor
#undef createNativeWindow A better solution for me personally would be to give those static functions a unique name per platform and possibly make the null platform optionally included with defines like the other platforms. |
The only other name that I see that conflicts with null and win32 is fitToMonitor |
Yea the 4 names that clash are : acquireMonitor It shows that they are redefined. Hope this helps. |
Many thanks to you both for that list of functions, that helps. |
Is this similar to having an amalgamated build ? I'd be very interested in that, thank you |
Yes, this is similar / the same. |
Epic 👌🏼 |
If I include these files....
#include "../external/glfw-3.3.8/src/osmesa_context.c"
#include "../external/glfw-3.3.8/src/platform.c" // Added for version GLFW 3.4, wasn't needed in 3.3.8 / 3.3.10
#include "../external/glfw-3.3.8/src/context.c"
#include "../external/glfw-3.3.8/src/egl_context.c"
#include "../external/glfw-3.3.8/src/init.c"
#include "../external/glfw-3.3.8/src/input.c"
#include "../external/glfw-3.3.8/src/monitor.c"
#include "../external/glfw-3.3.8/src/vulkan.c"
#include "../external/glfw-3.3.8/src/window.c"
#include "../external/glfw-3.3.8/src/win32_init.c"
#include "../external/glfw-3.3.8/src/win32_joystick.c"
#include "../external/glfw-3.3.8/src/win32_module.c" // Added for version GLFW 3.4, wasn't needed in 3.3.8 / 3.3.10
#include "../external/glfw-3.3.8/src/win32_thread.c"
#include "../external/glfw-3.3.8/src/win32_time.c"
#include "../external/glfw-3.3.8/src/win32_window.c"
#include "../external/glfw-3.3.8/src/win32_monitor.c"
#include "../external/glfw-3.3.8/src/wgl_context.c"
I get an undefined reference to _glfwConnectNull
So I include the NULL files
#include "../external/glfw-3.4/src/null_init.c"
#include "../external/glfw-3.4/src/null_joystick.c"
#include "../external/glfw-3.4/src/null_monitor.c"
#include "../external/glfw-3.4/src/null_window.c"
But as soon as I include those, then I get 4 functions with the same name, redefined. I only want to use _GLFW_WIN32 for windows platforms. But the code is forcing me to add NULL files when they are not needed.
Is there a way around this ?
EDIT:
Only way around it I have found so far is just to simply comment those four functions out in the null_windows.c file. I'm hoping a more official way is found.
The text was updated successfully, but these errors were encountered: