-
Notifications
You must be signed in to change notification settings - Fork 620
How to use the static library? #337
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
Comments
You'll need to link both the You'll need to use these link options:
(At present, the order is important. If I find I don't need For package ui, I also use Finally, I want to clean up this whole mess, because it is a mess — see #308 and andlabs/ui#281. |
@andlabs Thanks for your quick reply
However, the binary does not work. When I run it through the double-click, it flashes a cmd window and closed. When I run it with the command line, it gives the following runtime error:
Since I am not as nearly familiar with c++ (or g++) as I am for c, I have a hard time debugging these errors. Can you help me with it? |
I don't understand that error message. What is (That weird string did expose another random bug in libui when I used it in a test run; thanks. If |
… long: we wanted utf16UTF8Count(), not utf16RuneCount(), in toUTF8(); any non-ASCII text had the wrong number of bytes, and thus random heap corruption. The string "鎿嶄綔鎴愬姛瀹屾垚銆" (taken from the completely unrelated #337) and the Set Button Text button was enough to trigger this.
I tried to rebuild the library with the same configuration of the latest source (which is currently 465 commits ahead of the Alpha 3.5 release) and the build was failed on Windows.
I record the errors into a log file that shows some weird errors seem to be in
|
In current master msys2 build almost works: set PATH=C:\msys64\mingw64\bin;%PATH%
md build && cd build
cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=OFF ..
mingw32-make Result:
After I change one line, build finished successfully: diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt
index eab9ca9..bb5a306 100644
--- a/windows/CMakeLists.txt
+++ b/windows/CMakeLists.txt
@@ -75,7 +75,7 @@ macro(_handle_static)
add_custom_command(
TARGET libui POST_BUILD
COMMAND
- ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:libui,BINARY_DIR>/CMakeFiles/libui.dir/windows/resources.rc.* ${_LIBUI_STATIC_RES}
+ ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:libui,BINARY_DIR>/CMakeFiles/libui.dir/windows/resources.rc.obj ${_LIBUI_STATIC_RES}
COMMENT "Copying libui.res")
endmacro()
But I'm unsure if it is correct fix, |
Well, I guess that asterisk should be replaced by |
What's the difference here? Does I want to get rid of these kludges entirely, but I don't have an ETA on that. In the meantime, I can accept these fixes, subject to the minimum version of |
I still need an explanation of why that change makes things behave differently. IIRC I had no problems with my own MSYS build a few days ago (though that was from within MSYS using |
I decided to just fix the problem by not having it in the first place: there is no more .res file to copy out or link in. Do things work now? |
Thanks, now static build works. Just one thing I'm not entirely happy - contents of
Why all that |
I think that's cmake's doing; I'm not sure. What happens on a dynamic build? |
Without
Result:
|
Oh right, you're building on MinGW-w64. Yeah, DLLs aren't supported with that yet... I wonder when they will add isolation awareness support (if at all). |
Hm. I tried to remove last |
Yes, because isolation awareness is needed for the DLL to get Common Controls 6. Otherwise, you would have to apply the respective manifest to the whole application. Side-by-Side Assemblies is weird. |
Any updates? |
I have started properly documenting libui, and there will now be a page for how to properly use libui as a static library. The page will not be relevant to the current release, but it will be to the next. |
After reading this problem, I finally succeeded in using a static library, so I can record it. Is it useful to you, I use mingw32 under msys2 I download static lib from here: libs testlui.c
lui.static.manifest
resource.rc
Makefile
|
I know this question may be dumb, but I just can't figure out how to do it.
I successfully compiled the program with
CMake 3.11
onWindows 7 x86
withmingw32 gcc 7.2.0
and it gives two files: onelibui.a
and anotherlibui.res
. I want to test this library so I build the examples withmingw32-make -f Makefile examples
using theMakefile
generated byCMake
, and it works as well.But I wonder how I can use this library in my own project without
CMake
since I am not an expert on CMake and I don't want to mess up with it. So I copy themain.c
inside theexamples\histogram
as well asui.h
and the two library files listed above to another location and run the following command in the folder containingmain.c
I am expecting this to work since
main.c
only includesui.h
besides standard library andui.h
does not include other external headers as well. but it does work and throws me a bunch of undefined references.The stderr is attached:
Before I compile the library myself, I use the prebuild static library for mingw in the
Alpha 3.5
release andtdm-gcc 5.1.0
to buildmain.c
. The compiler throw me something similar:And now I am frustrated of what I should do. I really love this project since this seemed to be the only lightweight crossplatform GUI library for C on the Internet. So it is highly appreciated if any one can help.
The text was updated successfully, but these errors were encountered: